Skip to content

Commit

Permalink
Fix dogfood errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wright committed Dec 13, 2020
1 parent 3af09b8 commit a6aa0ac
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion clippy_lints/src/manual_ok_or.rs
Expand Up @@ -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:**
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/methods/mod.rs
Expand Up @@ -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]);
}
Expand All @@ -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);
},
_ => (),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/ref_option_ref.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/strings.rs
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions clippy_lints/src/unnecessary_wraps.rs
Expand Up @@ -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! {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a6aa0ac

Please sign in to comment.