name -> check_name
This commit is contained in:
parent
4bb6c87b08
commit
0ea5e38a9e
@ -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;
|
||||
|
@ -152,7 +152,7 @@ pub fn check_attrs<'a>(cx: &EarlyContext<'_>, valid_idents: &FxHashSet<String>,
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ pub fn file_from_args(
|
||||
args: &[ast::NestedMetaItem],
|
||||
) -> Result<Option<path::PathBuf>, (&'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))
|
||||
|
Loading…
Reference in New Issue
Block a user