Fix dogfood after MatchTypeOnDiagItem

This commit is contained in:
Eduardo Broto 2020-09-06 23:48:04 +02:00
parent 8afa7ed6ae
commit 332c2dcb4d
3 changed files with 4 additions and 4 deletions

View file

@ -1114,7 +1114,7 @@ fn get_vec_push<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) -> Option<(&
if let Some(self_expr) = args.get(0); if let Some(self_expr) = args.get(0);
if let Some(pushed_item) = args.get(1); if let Some(pushed_item) = args.get(1);
// Check that the method being called is push() on a Vec // Check that the method being called is push() on a Vec
if match_type(cx, cx.typeck_results().expr_ty(self_expr), &paths::VEC); if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(self_expr), sym!(vec_type));
if path.ident.name.as_str() == "push"; if path.ident.name.as_str() == "push";
then { then {
return Some((self_expr, pushed_item)) return Some((self_expr, pushed_item))

View file

@ -1808,7 +1808,7 @@ fn lint_or_fun_call<'tcx>(
_ => (), _ => (),
} }
if match_type(cx, ty, &paths::VEC) { if is_type_diagnostic_item(cx, ty, sym!(vec_type)) {
return; return;
} }
} }

View file

@ -1,6 +1,6 @@
use crate::utils; use crate::utils;
use crate::utils::sugg::Sugg; use crate::utils::sugg::Sugg;
use crate::utils::{match_type, paths, span_lint_and_sugg}; use crate::utils::{is_type_diagnostic_item, paths, span_lint_and_sugg};
use if_chain::if_chain; use if_chain::if_chain;
use rustc_errors::Applicability; use rustc_errors::Applicability;
@ -73,7 +73,7 @@ declare_lint_pass!(OptionIfLetElse => [OPTION_IF_LET_ELSE]);
fn is_result_ok(cx: &LateContext<'_>, expr: &'_ Expr<'_>) -> bool { fn is_result_ok(cx: &LateContext<'_>, expr: &'_ Expr<'_>) -> bool {
if let ExprKind::MethodCall(ref path, _, &[ref receiver], _) = &expr.kind { if let ExprKind::MethodCall(ref path, _, &[ref receiver], _) = &expr.kind {
path.ident.name.to_ident_string() == "ok" path.ident.name.to_ident_string() == "ok"
&& match_type(cx, &cx.typeck_results().expr_ty(&receiver), &paths::RESULT) && is_type_diagnostic_item(cx, &cx.typeck_results().expr_ty(&receiver), sym!(result_type))
} else { } else {
false false
} }