From 0ea5e38a9e188304e5ad7819139a9f2988483446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Mon, 18 Mar 2019 12:15:23 +0100 Subject: [PATCH] name -> check_name --- clippy_lints/src/attrs.rs | 16 ++++++++-------- clippy_lints/src/doc.rs | 2 +- clippy_lints/src/inline_fn_without_body.rs | 2 +- clippy_lints/src/missing_doc.rs | 2 +- clippy_lints/src/missing_inline.rs | 2 +- clippy_lints/src/needless_pass_by_value.rs | 2 +- clippy_lints/src/returns.rs | 2 +- clippy_lints/src/trivially_copy_pass_by_ref.rs | 2 +- clippy_lints/src/utils/conf.rs | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 3f5f1da424a..e7810152dc1 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -215,14 +215,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { }, _ => {}, } - if items.is_empty() || attr.name() != "deprecated" { + if items.is_empty() || !attr.check_name("deprecated") { return; } for item in items { if_chain! { if let NestedMetaItem::MetaItem(mi) = &item; if let MetaItemKind::NameValue(lit) = &mi.node; - if mi.name() == "since"; + if mi.check_name("since"); then { check_semver(cx, item.span(), lit); } @@ -238,7 +238,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { } match item.node { ItemKind::ExternCrate(..) | ItemKind::Use(..) => { - let skip_unused_imports = item.attrs.iter().any(|attr| attr.name() == "macro_use"); + let skip_unused_imports = item.attrs.iter().any(|attr| attr.check_name("macro_use")); for attr in &item.attrs { if let Some(lint_list) = &attr.meta_item_list() { @@ -447,7 +447,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib } if let Some(values) = attr.meta_item_list() { - if values.len() != 1 || attr.name() != "inline" { + if values.len() != 1 || !attr.check_name("inline") { continue; } if is_word(&values[0], "always") { @@ -481,7 +481,7 @@ fn check_semver(cx: &LateContext<'_, '_>, span: Span, lit: &Lit) { fn is_word(nmi: &NestedMetaItem, expected: &str) -> bool { if let NestedMetaItem::MetaItem(mi) = &nmi { - mi.is_word() && mi.name() == expected + mi.is_word() && mi.check_name(expected) } else { false } @@ -518,15 +518,15 @@ impl EarlyLintPass for CfgAttrPass { fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) { if_chain! { // check cfg_attr - if attr.name() == "cfg_attr"; + if attr.check_name("cfg_attr"); if let Some(items) = attr.meta_item_list(); if items.len() == 2; // check for `rustfmt` if let Some(feature_item) = items[0].meta_item(); - if feature_item.name() == "rustfmt"; + if feature_item.check_name("rustfmt"); // check for `rustfmt_skip` and `rustfmt::skip` if let Some(skip_item) = &items[1].meta_item(); - if skip_item.name() == "rustfmt_skip" || skip_item.name() == "skip"; + if skip_item.check_name("rustfmt_skip") || skip_item.check_name("skip"); // Only lint outer attributes, because custom inner attributes are unstable // Tracking issue: https://github.com/rust-lang/rust/issues/54726 if let AttrStyle::Outer = attr.style; diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index 0e8d47384f1..413645a091f 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -152,7 +152,7 @@ pub fn check_attrs<'a>(cx: &EarlyContext<'_>, valid_idents: &FxHashSet, spans.extend_from_slice(¤t_spans); doc.push_str(¤t); } - } else if attr.name() == "doc" { + } else if attr.check_name("doc") { // ignore mix of sugared and non-sugared doc return; } diff --git a/clippy_lints/src/inline_fn_without_body.rs b/clippy_lints/src/inline_fn_without_body.rs index cced334f43a..3e13d0073fe 100644 --- a/clippy_lints/src/inline_fn_without_body.rs +++ b/clippy_lints/src/inline_fn_without_body.rs @@ -51,7 +51,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) { for attr in attrs { - if attr.name() != "inline" { + if !attr.check_name("inline") { continue; } diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index 1cff51d1948..ed984f16db5 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -91,7 +91,7 @@ impl MissingDoc { let has_doc = attrs .iter() - .any(|a| a.name() == "doc" && (a.is_value_str() || Self::has_include(a.meta()))); + .any(|a| a.check_name("doc") && (a.is_value_str() || Self::has_include(a.meta()))); if !has_doc { span_lint( cx, diff --git a/clippy_lints/src/missing_inline.rs b/clippy_lints/src/missing_inline.rs index 87bf3b5485f..d6711900093 100644 --- a/clippy_lints/src/missing_inline.rs +++ b/clippy_lints/src/missing_inline.rs @@ -59,7 +59,7 @@ declare_clippy_lint! { pub struct MissingInline; fn check_missing_inline_attrs(cx: &LateContext<'_, '_>, attrs: &[ast::Attribute], sp: Span, desc: &'static str) { - let has_inline = attrs.iter().any(|a| a.name() == "inline"); + let has_inline = attrs.iter().any(|a| a.check_name("inline")); if !has_inline { span_lint( cx, diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index a07b8f4942b..2300456d4c3 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -324,7 +324,7 @@ fn requires_exact_signature(attrs: &[Attribute]) -> bool { attrs.iter().any(|attr| { ["proc_macro", "proc_macro_attribute", "proc_macro_derive"] .iter() - .any(|&allow| attr.name() == allow) + .any(|&allow| attr.check_name(allow)) }) } diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 5458fa51c7c..3995d9f2819 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -263,7 +263,7 @@ impl EarlyLintPass for ReturnPass { } fn attr_is_cfg(attr: &ast::Attribute) -> bool { - attr.meta_item_list().is_some() && attr.name() == "cfg" + attr.meta_item_list().is_some() && attr.check_name("cfg") } // get the def site diff --git a/clippy_lints/src/trivially_copy_pass_by_ref.rs b/clippy_lints/src/trivially_copy_pass_by_ref.rs index d246a791166..e0f19a14654 100644 --- a/clippy_lints/src/trivially_copy_pass_by_ref.rs +++ b/clippy_lints/src/trivially_copy_pass_by_ref.rs @@ -176,7 +176,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef { return; } for a in attrs { - if a.meta_item_list().is_some() && a.name() == "proc_macro_derive" { + if a.meta_item_list().is_some() && a.check_name("proc_macro_derive") { return; } } diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index ca860a5d30d..ce382da6e02 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -15,7 +15,7 @@ pub fn file_from_args( args: &[ast::NestedMetaItem], ) -> Result, (&'static str, source_map::Span)> { for arg in args.iter().filter_map(syntax::ast::NestedMetaItem::meta_item) { - if arg.name() == "conf_file" { + if arg.check_name("conf_file") { return match arg.node { ast::MetaItemKind::Word | ast::MetaItemKind::List(_) => { Err(("`conf_file` must be a named value", arg.span))