Skip to content

Commit 52a9c15

Browse files
committed
rustc_ast: (Nested)MetaItem::check_name -> has_name
For consistency with `Attribute::has_name` which doesn't mark the attribute as used either. Replace all uses of `check_name` with `has_name` outside of rustc
1 parent 24a6130 commit 52a9c15

11 files changed

+19
-19
lines changed

clippy_lints/src/attrs.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,14 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
286286
},
287287
_ => {},
288288
}
289-
if items.is_empty() || !attr.check_name(sym!(deprecated)) {
289+
if items.is_empty() || !attr.has_name(sym!(deprecated)) {
290290
return;
291291
}
292292
for item in items {
293293
if_chain! {
294294
if let NestedMetaItem::MetaItem(mi) = &item;
295295
if let MetaItemKind::NameValue(lit) = &mi.kind;
296-
if mi.check_name(sym!(since));
296+
if mi.has_name(sym!(since));
297297
then {
298298
check_semver(cx, item.span(), lit);
299299
}
@@ -309,7 +309,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
309309
}
310310
match item.kind {
311311
ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
312-
let skip_unused_imports = item.attrs.iter().any(|attr| attr.check_name(sym!(macro_use)));
312+
let skip_unused_imports = item.attrs.iter().any(|attr| attr.has_name(sym!(macro_use)));
313313

314314
for attr in item.attrs {
315315
if in_external_macro(cx.sess(), attr.span) {
@@ -524,7 +524,7 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Name, attrs: &[Attribute]
524524

525525
for attr in attrs {
526526
if let Some(values) = attr.meta_item_list() {
527-
if values.len() != 1 || !attr.check_name(sym!(inline)) {
527+
if values.len() != 1 || !attr.has_name(sym!(inline)) {
528528
continue;
529529
}
530530
if is_word(&values[0], sym!(always)) {
@@ -558,7 +558,7 @@ fn check_semver(cx: &LateContext<'_>, span: Span, lit: &Lit) {
558558

559559
fn is_word(nmi: &NestedMetaItem, expected: Symbol) -> bool {
560560
if let NestedMetaItem::MetaItem(mi) = &nmi {
561-
mi.is_word() && mi.check_name(expected)
561+
mi.is_word() && mi.has_name(expected)
562562
} else {
563563
false
564564
}
@@ -618,15 +618,15 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::as
618618
fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute) {
619619
if_chain! {
620620
// check cfg_attr
621-
if attr.check_name(sym!(cfg_attr));
621+
if attr.has_name(sym!(cfg_attr));
622622
if let Some(items) = attr.meta_item_list();
623623
if items.len() == 2;
624624
// check for `rustfmt`
625625
if let Some(feature_item) = items[0].meta_item();
626-
if feature_item.check_name(sym!(rustfmt));
626+
if feature_item.has_name(sym!(rustfmt));
627627
// check for `rustfmt_skip` and `rustfmt::skip`
628628
if let Some(skip_item) = &items[1].meta_item();
629-
if skip_item.check_name(sym!(rustfmt_skip)) ||
629+
if skip_item.has_name(sym!(rustfmt_skip)) ||
630630
skip_item.path.segments.last().expect("empty path in attribute").ident.name == sym!(skip);
631631
// Only lint outer attributes, because custom inner attributes are unstable
632632
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
@@ -685,7 +685,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
685685
}
686686

687687
if_chain! {
688-
if attr.check_name(sym!(cfg));
688+
if attr.has_name(sym!(cfg));
689689
if let Some(list) = attr.meta_item_list();
690690
let mismatched = find_mismatched_target_os(&list);
691691
if !mismatched.is_empty();

clippy_lints/src/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs
323323
let (comment, current_spans) = strip_doc_comment_decoration(&comment, attr.span);
324324
spans.extend_from_slice(&current_spans);
325325
doc.push_str(&comment);
326-
} else if attr.check_name(sym!(doc)) {
326+
} else if attr.has_name(sym!(doc)) {
327327
// ignore mix of sugared and non-sugared doc
328328
// don't trigger the safety or errors check
329329
return DocHeaders {

clippy_lints/src/inline_fn_without_body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for InlineFnWithoutBody {
4141

4242
fn check_attrs(cx: &LateContext<'_>, name: Symbol, attrs: &[Attribute]) {
4343
for attr in attrs {
44-
if !attr.check_name(sym!(inline)) {
44+
if !attr.has_name(sym!(inline)) {
4545
continue;
4646
}
4747

clippy_lints/src/manual_non_exhaustive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn check_manual_non_exhaustive_enum(cx: &EarlyContext<'_>, item: &Item, variants
8383
}
8484

8585
fn is_doc_hidden(attr: &Attribute) -> bool {
86-
attr.check_name(sym!(doc))
86+
attr.has_name(sym!(doc))
8787
&& match attr.meta_item_list() {
8888
Some(l) => attr::list_contains_name(&l, sym!(hidden)),
8989
None => false,

clippy_lints/src/missing_doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
105105
fn enter_lint_attrs(&mut self, _: &LateContext<'tcx>, attrs: &'tcx [ast::Attribute]) {
106106
let doc_hidden = self.doc_hidden()
107107
|| attrs.iter().any(|attr| {
108-
attr.check_name(sym!(doc))
108+
attr.has_name(sym!(doc))
109109
&& match attr.meta_item_list() {
110110
None => false,
111111
Some(l) => attr::list_contains_name(&l[..], sym!(hidden)),

clippy_lints/src/missing_inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ declare_clippy_lint! {
5757
}
5858

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

clippy_lints/src/needless_borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrow {
112112
}
113113

114114
fn check_item(&mut self, _: &LateContext<'tcx>, item: &'tcx Item<'_>) {
115-
if item.attrs.iter().any(|a| a.check_name(sym!(automatically_derived))) {
115+
if item.attrs.iter().any(|a| a.has_name(sym!(automatically_derived))) {
116116
debug_assert!(self.derived_item.is_none());
117117
self.derived_item = Some(item.hir_id);
118118
}

clippy_lints/src/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ fn requires_exact_signature(attrs: &[Attribute]) -> bool {
312312
attrs.iter().any(|attr| {
313313
[sym!(proc_macro), sym!(proc_macro_attribute), sym!(proc_macro_derive)]
314314
.iter()
315-
.any(|&allow| attr.check_name(allow))
315+
.any(|&allow| attr.has_name(allow))
316316
})
317317
}
318318

clippy_lints/src/returns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl EarlyLintPass for Return {
235235
}
236236

237237
fn attr_is_cfg(attr: &ast::Attribute) -> bool {
238-
attr.meta_item_list().is_some() && attr.check_name(sym!(cfg))
238+
attr.meta_item_list().is_some() && attr.has_name(sym!(cfg))
239239
}
240240

241241
// get the def site

clippy_lints/src/trivially_copy_pass_by_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl<'tcx> LateLintPass<'tcx> for TriviallyCopyPassByRef {
155155
return;
156156
}
157157
for a in attrs {
158-
if a.meta_item_list().is_some() && a.check_name(sym!(proc_macro_derive)) {
158+
if a.meta_item_list().is_some() && a.has_name(sym!(proc_macro_derive)) {
159159
return;
160160
}
161161
}

clippy_lints/src/utils/conf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{env, fmt, fs, io};
1313
/// Gets the configuration file from arguments.
1414
pub fn file_from_args(args: &[NestedMetaItem]) -> Result<Option<PathBuf>, (&'static str, Span)> {
1515
for arg in args.iter().filter_map(NestedMetaItem::meta_item) {
16-
if arg.check_name(sym!(conf_file)) {
16+
if arg.has_name(sym!(conf_file)) {
1717
return match arg.kind {
1818
MetaItemKind::Word | MetaItemKind::List(_) => Err(("`conf_file` must be a named value", arg.span)),
1919
MetaItemKind::NameValue(ref value) => {

0 commit comments

Comments
 (0)