Skip to content

Commit 0ea5e38

Browse files
committed
name -> check_name
1 parent 4bb6c87 commit 0ea5e38

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

clippy_lints/src/attrs.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
215215
},
216216
_ => {},
217217
}
218-
if items.is_empty() || attr.name() != "deprecated" {
218+
if items.is_empty() || !attr.check_name("deprecated") {
219219
return;
220220
}
221221
for item in items {
222222
if_chain! {
223223
if let NestedMetaItem::MetaItem(mi) = &item;
224224
if let MetaItemKind::NameValue(lit) = &mi.node;
225-
if mi.name() == "since";
225+
if mi.check_name("since");
226226
then {
227227
check_semver(cx, item.span(), lit);
228228
}
@@ -238,7 +238,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
238238
}
239239
match item.node {
240240
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
241-
let skip_unused_imports = item.attrs.iter().any(|attr| attr.name() == "macro_use");
241+
let skip_unused_imports = item.attrs.iter().any(|attr| attr.check_name("macro_use"));
242242

243243
for attr in &item.attrs {
244244
if let Some(lint_list) = &attr.meta_item_list() {
@@ -447,7 +447,7 @@ fn check_attrs(cx: &LateContext<'_, '_>, span: Span, name: Name, attrs: &[Attrib
447447
}
448448

449449
if let Some(values) = attr.meta_item_list() {
450-
if values.len() != 1 || attr.name() != "inline" {
450+
if values.len() != 1 || !attr.check_name("inline") {
451451
continue;
452452
}
453453
if is_word(&values[0], "always") {
@@ -481,7 +481,7 @@ fn check_semver(cx: &LateContext<'_, '_>, span: Span, lit: &Lit) {
481481

482482
fn is_word(nmi: &NestedMetaItem, expected: &str) -> bool {
483483
if let NestedMetaItem::MetaItem(mi) = &nmi {
484-
mi.is_word() && mi.name() == expected
484+
mi.is_word() && mi.check_name(expected)
485485
} else {
486486
false
487487
}
@@ -518,15 +518,15 @@ impl EarlyLintPass for CfgAttrPass {
518518
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) {
519519
if_chain! {
520520
// check cfg_attr
521-
if attr.name() == "cfg_attr";
521+
if attr.check_name("cfg_attr");
522522
if let Some(items) = attr.meta_item_list();
523523
if items.len() == 2;
524524
// check for `rustfmt`
525525
if let Some(feature_item) = items[0].meta_item();
526-
if feature_item.name() == "rustfmt";
526+
if feature_item.check_name("rustfmt");
527527
// check for `rustfmt_skip` and `rustfmt::skip`
528528
if let Some(skip_item) = &items[1].meta_item();
529-
if skip_item.name() == "rustfmt_skip" || skip_item.name() == "skip";
529+
if skip_item.check_name("rustfmt_skip") || skip_item.check_name("skip");
530530
// Only lint outer attributes, because custom inner attributes are unstable
531531
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
532532
if let AttrStyle::Outer = attr.style;

clippy_lints/src/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ pub fn check_attrs<'a>(cx: &EarlyContext<'_>, valid_idents: &FxHashSet<String>,
152152
spans.extend_from_slice(&current_spans);
153153
doc.push_str(&current);
154154
}
155-
} else if attr.name() == "doc" {
155+
} else if attr.check_name("doc") {
156156
// ignore mix of sugared and non-sugared doc
157157
return;
158158
}

clippy_lints/src/inline_fn_without_body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
5151

5252
fn check_attrs(cx: &LateContext<'_, '_>, name: Name, attrs: &[Attribute]) {
5353
for attr in attrs {
54-
if attr.name() != "inline" {
54+
if !attr.check_name("inline") {
5555
continue;
5656
}
5757

clippy_lints/src/missing_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl MissingDoc {
9191

9292
let has_doc = attrs
9393
.iter()
94-
.any(|a| a.name() == "doc" && (a.is_value_str() || Self::has_include(a.meta())));
94+
.any(|a| a.check_name("doc") && (a.is_value_str() || Self::has_include(a.meta())));
9595
if !has_doc {
9696
span_lint(
9797
cx,

clippy_lints/src/missing_inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ declare_clippy_lint! {
5959
pub struct MissingInline;
6060

6161
fn check_missing_inline_attrs(cx: &LateContext<'_, '_>, attrs: &[ast::Attribute], sp: Span, desc: &'static str) {
62-
let has_inline = attrs.iter().any(|a| a.name() == "inline");
62+
let has_inline = attrs.iter().any(|a| a.check_name("inline"));
6363
if !has_inline {
6464
span_lint(
6565
cx,

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ fn requires_exact_signature(attrs: &[Attribute]) -> bool {
324324
attrs.iter().any(|attr| {
325325
["proc_macro", "proc_macro_attribute", "proc_macro_derive"]
326326
.iter()
327-
.any(|&allow| attr.name() == allow)
327+
.any(|&allow| attr.check_name(allow))
328328
})
329329
}
330330

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl EarlyLintPass for ReturnPass {
263263
}
264264

265265
fn attr_is_cfg(attr: &ast::Attribute) -> bool {
266-
attr.meta_item_list().is_some() && attr.name() == "cfg"
266+
attr.meta_item_list().is_some() && attr.check_name("cfg")
267267
}
268268

269269
// get the def site

clippy_lints/src/trivially_copy_pass_by_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
176176
return;
177177
}
178178
for a in attrs {
179-
if a.meta_item_list().is_some() && a.name() == "proc_macro_derive" {
179+
if a.meta_item_list().is_some() && a.check_name("proc_macro_derive") {
180180
return;
181181
}
182182
}

clippy_lints/src/utils/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn file_from_args(
1515
args: &[ast::NestedMetaItem],
1616
) -> Result<Option<path::PathBuf>, (&'static str, source_map::Span)> {
1717
for arg in args.iter().filter_map(syntax::ast::NestedMetaItem::meta_item) {
18-
if arg.name() == "conf_file" {
18+
if arg.check_name("conf_file") {
1919
return match arg.node {
2020
ast::MetaItemKind::Word | ast::MetaItemKind::List(_) => {
2121
Err(("`conf_file` must be a named value", arg.span))

0 commit comments

Comments
 (0)