mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 11:34:11 +00:00
Fix dogfood errors
This commit is contained in:
parent
3af09b8cf1
commit
a6aa0acbea
@ -8,6 +8,7 @@ use rustc_lint::LintContext;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:**
|
||||
@ -51,7 +52,7 @@ impl LateLintPass<'_> for ManualOkOr {
|
||||
if args.len() == 3;
|
||||
let method_receiver = &args[0];
|
||||
let ty = cx.typeck_results().expr_ty(method_receiver);
|
||||
if is_type_diagnostic_item(cx, ty, sym!(option_type));
|
||||
if is_type_diagnostic_item(cx, ty, sym::option_type);
|
||||
let or_expr = &args[1];
|
||||
if is_ok_wrapping(cx, &args[2]);
|
||||
if let ExprKind::Call(Expr { kind: ExprKind::Path(err_path), .. }, &[ref err_arg]) = or_expr.kind;
|
||||
|
@ -1568,7 +1568,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
lint_expect_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args);
|
||||
|
||||
let self_ty = cx.typeck_results().expr_ty_adjusted(&args[0]);
|
||||
if args.len() == 1 && method_call.ident.name == sym!(clone) {
|
||||
if args.len() == 1 && method_call.ident.name == sym::clone {
|
||||
lint_clone_on_copy(cx, expr, &args[0], self_ty);
|
||||
lint_clone_on_ref_ptr(cx, expr, &args[0]);
|
||||
}
|
||||
@ -1592,7 +1592,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||
}
|
||||
}
|
||||
},
|
||||
ty::Ref(..) if method_call.ident.name == sym!(into_iter) => {
|
||||
ty::Ref(..) if method_call.ident.name == sym::into_iter => {
|
||||
lint_into_iter(cx, expr, self_ty, *method_span);
|
||||
},
|
||||
_ => (),
|
||||
@ -2638,9 +2638,9 @@ fn lint_unwrap(cx: &LateContext<'_>, expr: &hir::Expr<'_>, unwrap_args: &[hir::E
|
||||
fn lint_expect(cx: &LateContext<'_>, expr: &hir::Expr<'_>, expect_args: &[hir::Expr<'_>]) {
|
||||
let obj_ty = cx.typeck_results().expr_ty(&expect_args[0]).peel_refs();
|
||||
|
||||
let mess = if is_type_diagnostic_item(cx, obj_ty, sym!(option_type)) {
|
||||
let mess = if is_type_diagnostic_item(cx, obj_ty, sym::option_type) {
|
||||
Some((EXPECT_USED, "an Option", "None"))
|
||||
} else if is_type_diagnostic_item(cx, obj_ty, sym!(result_type)) {
|
||||
} else if is_type_diagnostic_item(cx, obj_ty, sym::result_type) {
|
||||
Some((EXPECT_USED, "a Result", "Err"))
|
||||
} else {
|
||||
None
|
||||
@ -3133,7 +3133,7 @@ fn lint_search_is_some<'tcx>(
|
||||
else if search_method == "find" {
|
||||
let is_string_or_str_slice = |e| {
|
||||
let self_ty = cx.typeck_results().expr_ty(e).peel_refs();
|
||||
if is_type_diagnostic_item(cx, self_ty, sym!(string_type)) {
|
||||
if is_type_diagnostic_item(cx, self_ty, sym::string_type) {
|
||||
true
|
||||
} else {
|
||||
*self_ty.kind() == ty::Str
|
||||
|
@ -2,6 +2,7 @@ use crate::utils::{last_path_segment, snippet, span_lint_and_sugg};
|
||||
use rustc_hir::{GenericArg, Mutability, Ty, TyKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
use if_chain::if_chain;
|
||||
use rustc_errors::Applicability;
|
||||
@ -41,7 +42,7 @@ impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
|
||||
if let Some(res) = last.res;
|
||||
if let Some(def_id) = res.opt_def_id();
|
||||
|
||||
if cx.tcx.is_diagnostic_item(sym!(option_type), def_id);
|
||||
if cx.tcx.is_diagnostic_item(sym::option_type, def_id);
|
||||
if let Some(ref params) = last_path_segment(qpath).args ;
|
||||
if !params.parenthesized;
|
||||
if let Some(inner_ty) = params.args.iter().find_map(|arg| match arg {
|
||||
|
@ -372,7 +372,7 @@ impl LateLintPass<'_> for StringToString {
|
||||
if let ExprKind::MethodCall(path, _, args, _) = &expr.kind;
|
||||
if path.ident.name == sym!(to_string);
|
||||
let ty = cx.typeck_results().expr_ty(&args[0]);
|
||||
if is_type_diagnostic_item(cx, ty, sym!(string_type));
|
||||
if is_type_diagnostic_item(cx, ty, sym::string_type);
|
||||
then {
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
|
@ -9,6 +9,7 @@ use rustc_hir::{Body, ExprKind, FnDecl, HirId, ItemKind, Node};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Span;
|
||||
|
||||
declare_clippy_lint! {
|
||||
@ -82,9 +83,9 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
|
||||
}
|
||||
}
|
||||
|
||||
let (return_type, path) = if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym!(option_type)) {
|
||||
let (return_type, path) = if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::option_type) {
|
||||
("Option", &paths::OPTION_SOME)
|
||||
} else if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym!(result_type)) {
|
||||
} else if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::result_type) {
|
||||
("Result", &paths::RESULT_OK)
|
||||
} else {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user