]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/attrs.rs
Auto merge of #89404 - Kobzol:hash-stable-sort, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / clippy_lints / src / attrs.rs
1 //! checks for attributes
2
3 use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
4 use clippy_utils::msrvs;
5 use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments};
6 use clippy_utils::{extract_msrv_attr, match_panic_def_id, meets_msrv};
7 use if_chain::if_chain;
8 use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
9 use rustc_errors::Applicability;
10 use rustc_hir::{
11     Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
12 };
13 use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
14 use rustc_middle::lint::in_external_macro;
15 use rustc_middle::ty;
16 use rustc_semver::RustcVersion;
17 use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
18 use rustc_span::source_map::Span;
19 use rustc_span::sym;
20 use rustc_span::symbol::{Symbol, SymbolStr};
21 use semver::Version;
22
23 static UNIX_SYSTEMS: &[&str] = &[
24     "android",
25     "dragonfly",
26     "emscripten",
27     "freebsd",
28     "fuchsia",
29     "haiku",
30     "illumos",
31     "ios",
32     "l4re",
33     "linux",
34     "macos",
35     "netbsd",
36     "openbsd",
37     "redox",
38     "solaris",
39     "vxworks",
40 ];
41
42 // NOTE: windows is excluded from the list because it's also a valid target family.
43 static NON_UNIX_SYSTEMS: &[&str] = &["hermit", "none", "wasi"];
44
45 declare_clippy_lint! {
46     /// ### What it does
47     /// Checks for items annotated with `#[inline(always)]`,
48     /// unless the annotated function is empty or simply panics.
49     ///
50     /// ### Why is this bad?
51     /// While there are valid uses of this annotation (and once
52     /// you know when to use it, by all means `allow` this lint), it's a common
53     /// newbie-mistake to pepper one's code with it.
54     ///
55     /// As a rule of thumb, before slapping `#[inline(always)]` on a function,
56     /// measure if that additional function call really affects your runtime profile
57     /// sufficiently to make up for the increase in compile time.
58     ///
59     /// ### Known problems
60     /// False positives, big time. This lint is meant to be
61     /// deactivated by everyone doing serious performance work. This means having
62     /// done the measurement.
63     ///
64     /// ### Example
65     /// ```ignore
66     /// #[inline(always)]
67     /// fn not_quite_hot_code(..) { ... }
68     /// ```
69     #[clippy::version = "pre 1.29.0"]
70     pub INLINE_ALWAYS,
71     pedantic,
72     "use of `#[inline(always)]`"
73 }
74
75 declare_clippy_lint! {
76     /// ### What it does
77     /// Checks for `extern crate` and `use` items annotated with
78     /// lint attributes.
79     ///
80     /// This lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]`,
81     /// `#[allow(unreachable_pub)]`, `#[allow(clippy::wildcard_imports)]` and
82     /// `#[allow(clippy::enum_glob_use)]` on `use` items and `#[allow(unused_imports)]` on
83     /// `extern crate` items with a `#[macro_use]` attribute.
84     ///
85     /// ### Why is this bad?
86     /// Lint attributes have no effect on crate imports. Most
87     /// likely a `!` was forgotten.
88     ///
89     /// ### Example
90     /// ```ignore
91     /// // Bad
92     /// #[deny(dead_code)]
93     /// extern crate foo;
94     /// #[forbid(dead_code)]
95     /// use foo::bar;
96     ///
97     /// // Ok
98     /// #[allow(unused_imports)]
99     /// use foo::baz;
100     /// #[allow(unused_imports)]
101     /// #[macro_use]
102     /// extern crate baz;
103     /// ```
104     #[clippy::version = "pre 1.29.0"]
105     pub USELESS_ATTRIBUTE,
106     correctness,
107     "use of lint attributes on `extern crate` items"
108 }
109
110 declare_clippy_lint! {
111     /// ### What it does
112     /// Checks for `#[deprecated]` annotations with a `since`
113     /// field that is not a valid semantic version.
114     ///
115     /// ### Why is this bad?
116     /// For checking the version of the deprecation, it must be
117     /// a valid semver. Failing that, the contained information is useless.
118     ///
119     /// ### Example
120     /// ```rust
121     /// #[deprecated(since = "forever")]
122     /// fn something_else() { /* ... */ }
123     /// ```
124     #[clippy::version = "pre 1.29.0"]
125     pub DEPRECATED_SEMVER,
126     correctness,
127     "use of `#[deprecated(since = \"x\")]` where x is not semver"
128 }
129
130 declare_clippy_lint! {
131     /// ### What it does
132     /// Checks for empty lines after outer attributes
133     ///
134     /// ### Why is this bad?
135     /// Most likely the attribute was meant to be an inner attribute using a '!'.
136     /// If it was meant to be an outer attribute, then the following item
137     /// should not be separated by empty lines.
138     ///
139     /// ### Known problems
140     /// Can cause false positives.
141     ///
142     /// From the clippy side it's difficult to detect empty lines between an attributes and the
143     /// following item because empty lines and comments are not part of the AST. The parsing
144     /// currently works for basic cases but is not perfect.
145     ///
146     /// ### Example
147     /// ```rust
148     /// // Good (as inner attribute)
149     /// #![allow(dead_code)]
150     ///
151     /// fn this_is_fine() { }
152     ///
153     /// // Bad
154     /// #[allow(dead_code)]
155     ///
156     /// fn not_quite_good_code() { }
157     ///
158     /// // Good (as outer attribute)
159     /// #[allow(dead_code)]
160     /// fn this_is_fine_too() { }
161     /// ```
162     #[clippy::version = "pre 1.29.0"]
163     pub EMPTY_LINE_AFTER_OUTER_ATTR,
164     nursery,
165     "empty line after outer attribute"
166 }
167
168 declare_clippy_lint! {
169     /// ### What it does
170     /// Checks for `warn`/`deny`/`forbid` attributes targeting the whole clippy::restriction category.
171     ///
172     /// ### Why is this bad?
173     /// Restriction lints sometimes are in contrast with other lints or even go against idiomatic rust.
174     /// These lints should only be enabled on a lint-by-lint basis and with careful consideration.
175     ///
176     /// ### Example
177     /// Bad:
178     /// ```rust
179     /// #![deny(clippy::restriction)]
180     /// ```
181     ///
182     /// Good:
183     /// ```rust
184     /// #![deny(clippy::as_conversions)]
185     /// ```
186     #[clippy::version = "1.47.0"]
187     pub BLANKET_CLIPPY_RESTRICTION_LINTS,
188     suspicious,
189     "enabling the complete restriction group"
190 }
191
192 declare_clippy_lint! {
193     /// ### What it does
194     /// Checks for `#[cfg_attr(rustfmt, rustfmt_skip)]` and suggests to replace it
195     /// with `#[rustfmt::skip]`.
196     ///
197     /// ### Why is this bad?
198     /// Since tool_attributes ([rust-lang/rust#44690](https://github.com/rust-lang/rust/issues/44690))
199     /// are stable now, they should be used instead of the old `cfg_attr(rustfmt)` attributes.
200     ///
201     /// ### Known problems
202     /// This lint doesn't detect crate level inner attributes, because they get
203     /// processed before the PreExpansionPass lints get executed. See
204     /// [#3123](https://github.com/rust-lang/rust-clippy/pull/3123#issuecomment-422321765)
205     ///
206     /// ### Example
207     /// Bad:
208     /// ```rust
209     /// #[cfg_attr(rustfmt, rustfmt_skip)]
210     /// fn main() { }
211     /// ```
212     ///
213     /// Good:
214     /// ```rust
215     /// #[rustfmt::skip]
216     /// fn main() { }
217     /// ```
218     #[clippy::version = "1.32.0"]
219     pub DEPRECATED_CFG_ATTR,
220     complexity,
221     "usage of `cfg_attr(rustfmt)` instead of tool attributes"
222 }
223
224 declare_clippy_lint! {
225     /// ### What it does
226     /// Checks for cfg attributes having operating systems used in target family position.
227     ///
228     /// ### Why is this bad?
229     /// The configuration option will not be recognised and the related item will not be included
230     /// by the conditional compilation engine.
231     ///
232     /// ### Example
233     /// Bad:
234     /// ```rust
235     /// #[cfg(linux)]
236     /// fn conditional() { }
237     /// ```
238     ///
239     /// Good:
240     /// ```rust
241     /// #[cfg(target_os = "linux")]
242     /// fn conditional() { }
243     /// ```
244     ///
245     /// Or:
246     /// ```rust
247     /// #[cfg(unix)]
248     /// fn conditional() { }
249     /// ```
250     /// Check the [Rust Reference](https://doc.rust-lang.org/reference/conditional-compilation.html#target_os) for more details.
251     #[clippy::version = "1.45.0"]
252     pub MISMATCHED_TARGET_OS,
253     correctness,
254     "usage of `cfg(operating_system)` instead of `cfg(target_os = \"operating_system\")`"
255 }
256
257 declare_lint_pass!(Attributes => [
258     INLINE_ALWAYS,
259     DEPRECATED_SEMVER,
260     USELESS_ATTRIBUTE,
261     BLANKET_CLIPPY_RESTRICTION_LINTS,
262 ]);
263
264 impl<'tcx> LateLintPass<'tcx> for Attributes {
265     fn check_attribute(&mut self, cx: &LateContext<'tcx>, attr: &'tcx Attribute) {
266         if let Some(items) = &attr.meta_item_list() {
267             if let Some(ident) = attr.ident() {
268                 if is_lint_level(ident.name) {
269                     check_clippy_lint_names(cx, ident.name, items);
270                 }
271                 if items.is_empty() || !attr.has_name(sym::deprecated) {
272                     return;
273                 }
274                 for item in items {
275                     if_chain! {
276                         if let NestedMetaItem::MetaItem(mi) = &item;
277                         if let MetaItemKind::NameValue(lit) = &mi.kind;
278                         if mi.has_name(sym::since);
279                         then {
280                             check_semver(cx, item.span(), lit);
281                         }
282                     }
283                 }
284             }
285         }
286     }
287
288     fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
289         let attrs = cx.tcx.hir().attrs(item.hir_id());
290         if is_relevant_item(cx, item) {
291             check_attrs(cx, item.span, item.ident.name, attrs);
292         }
293         match item.kind {
294             ItemKind::ExternCrate(..) | ItemKind::Use(..) => {
295                 let skip_unused_imports = attrs.iter().any(|attr| attr.has_name(sym::macro_use));
296
297                 for attr in attrs {
298                     if in_external_macro(cx.sess(), attr.span) {
299                         return;
300                     }
301                     if let Some(lint_list) = &attr.meta_item_list() {
302                         if attr.ident().map_or(false, |ident| is_lint_level(ident.name)) {
303                             // permit `unused_imports`, `deprecated`, `unreachable_pub`,
304                             // `clippy::wildcard_imports`, and `clippy::enum_glob_use` for `use` items
305                             // and `unused_imports` for `extern crate` items with `macro_use`
306                             for lint in lint_list {
307                                 match item.kind {
308                                     ItemKind::Use(..) => {
309                                         if is_word(lint, sym!(unused_imports))
310                                             || is_word(lint, sym::deprecated)
311                                             || is_word(lint, sym!(unreachable_pub))
312                                             || is_word(lint, sym!(unused))
313                                             || extract_clippy_lint(lint).map_or(false, |s| s == "wildcard_imports")
314                                             || extract_clippy_lint(lint).map_or(false, |s| s == "enum_glob_use")
315                                         {
316                                             return;
317                                         }
318                                     },
319                                     ItemKind::ExternCrate(..) => {
320                                         if is_word(lint, sym!(unused_imports)) && skip_unused_imports {
321                                             return;
322                                         }
323                                         if is_word(lint, sym!(unused_extern_crates)) {
324                                             return;
325                                         }
326                                     },
327                                     _ => {},
328                                 }
329                             }
330                             let line_span = first_line_of_span(cx, attr.span);
331
332                             if let Some(mut sugg) = snippet_opt(cx, line_span) {
333                                 if sugg.contains("#[") {
334                                     span_lint_and_then(
335                                         cx,
336                                         USELESS_ATTRIBUTE,
337                                         line_span,
338                                         "useless lint attribute",
339                                         |diag| {
340                                             sugg = sugg.replacen("#[", "#![", 1);
341                                             diag.span_suggestion(
342                                                 line_span,
343                                                 "if you just forgot a `!`, use",
344                                                 sugg,
345                                                 Applicability::MaybeIncorrect,
346                                             );
347                                         },
348                                     );
349                                 }
350                             }
351                         }
352                     }
353                 }
354             },
355             _ => {},
356         }
357     }
358
359     fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
360         if is_relevant_impl(cx, item) {
361             check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
362         }
363     }
364
365     fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
366         if is_relevant_trait(cx, item) {
367             check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
368         }
369     }
370 }
371
372 /// Returns the lint name if it is clippy lint.
373 fn extract_clippy_lint(lint: &NestedMetaItem) -> Option<SymbolStr> {
374     if_chain! {
375         if let Some(meta_item) = lint.meta_item();
376         if meta_item.path.segments.len() > 1;
377         if let tool_name = meta_item.path.segments[0].ident;
378         if tool_name.name == sym::clippy;
379         then {
380             let lint_name = meta_item.path.segments.last().unwrap().ident.name;
381             return Some(lint_name.as_str());
382         }
383     }
384     None
385 }
386
387 fn check_clippy_lint_names(cx: &LateContext<'_>, name: Symbol, items: &[NestedMetaItem]) {
388     for lint in items {
389         if let Some(lint_name) = extract_clippy_lint(lint) {
390             if lint_name == "restriction" && name != sym::allow {
391                 span_lint_and_help(
392                     cx,
393                     BLANKET_CLIPPY_RESTRICTION_LINTS,
394                     lint.span(),
395                     "restriction lints are not meant to be all enabled",
396                     None,
397                     "try enabling only the lints you really need",
398                 );
399             }
400         }
401     }
402 }
403
404 fn is_relevant_item(cx: &LateContext<'_>, item: &Item<'_>) -> bool {
405     if let ItemKind::Fn(_, _, eid) = item.kind {
406         is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value)
407     } else {
408         true
409     }
410 }
411
412 fn is_relevant_impl(cx: &LateContext<'_>, item: &ImplItem<'_>) -> bool {
413     match item.kind {
414         ImplItemKind::Fn(_, eid) => is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value),
415         _ => false,
416     }
417 }
418
419 fn is_relevant_trait(cx: &LateContext<'_>, item: &TraitItem<'_>) -> bool {
420     match item.kind {
421         TraitItemKind::Fn(_, TraitFn::Required(_)) => true,
422         TraitItemKind::Fn(_, TraitFn::Provided(eid)) => {
423             is_relevant_expr(cx, cx.tcx.typeck_body(eid), &cx.tcx.hir().body(eid).value)
424         },
425         _ => false,
426     }
427 }
428
429 fn is_relevant_block(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, block: &Block<'_>) -> bool {
430     block.stmts.first().map_or(
431         block
432             .expr
433             .as_ref()
434             .map_or(false, |e| is_relevant_expr(cx, typeck_results, e)),
435         |stmt| match &stmt.kind {
436             StmtKind::Local(_) => true,
437             StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(cx, typeck_results, expr),
438             StmtKind::Item(_) => false,
439         },
440     )
441 }
442
443 fn is_relevant_expr(cx: &LateContext<'_>, typeck_results: &ty::TypeckResults<'_>, expr: &Expr<'_>) -> bool {
444     match &expr.kind {
445         ExprKind::Block(block, _) => is_relevant_block(cx, typeck_results, block),
446         ExprKind::Ret(Some(e)) => is_relevant_expr(cx, typeck_results, e),
447         ExprKind::Ret(None) | ExprKind::Break(_, None) => false,
448         ExprKind::Call(path_expr, _) => {
449             if let ExprKind::Path(qpath) = &path_expr.kind {
450                 typeck_results
451                     .qpath_res(qpath, path_expr.hir_id)
452                     .opt_def_id()
453                     .map_or(true, |fun_id| !match_panic_def_id(cx, fun_id))
454             } else {
455                 true
456             }
457         },
458         _ => true,
459     }
460 }
461
462 fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribute]) {
463     if span.from_expansion() {
464         return;
465     }
466
467     for attr in attrs {
468         if let Some(values) = attr.meta_item_list() {
469             if values.len() != 1 || !attr.has_name(sym::inline) {
470                 continue;
471             }
472             if is_word(&values[0], sym::always) {
473                 span_lint(
474                     cx,
475                     INLINE_ALWAYS,
476                     attr.span,
477                     &format!(
478                         "you have declared `#[inline(always)]` on `{}`. This is usually a bad idea",
479                         name
480                     ),
481                 );
482             }
483         }
484     }
485 }
486
487 fn check_semver(cx: &LateContext<'_>, span: Span, lit: &Lit) {
488     if let LitKind::Str(is, _) = lit.kind {
489         if Version::parse(&is.as_str()).is_ok() {
490             return;
491         }
492     }
493     span_lint(
494         cx,
495         DEPRECATED_SEMVER,
496         span,
497         "the since field must contain a semver-compliant version",
498     );
499 }
500
501 fn is_word(nmi: &NestedMetaItem, expected: Symbol) -> bool {
502     if let NestedMetaItem::MetaItem(mi) = &nmi {
503         mi.is_word() && mi.has_name(expected)
504     } else {
505         false
506     }
507 }
508
509 pub struct EarlyAttributes {
510     pub msrv: Option<RustcVersion>,
511 }
512
513 impl_lint_pass!(EarlyAttributes => [
514     DEPRECATED_CFG_ATTR,
515     MISMATCHED_TARGET_OS,
516     EMPTY_LINE_AFTER_OUTER_ATTR,
517 ]);
518
519 impl EarlyLintPass for EarlyAttributes {
520     fn check_item(&mut self, cx: &EarlyContext<'_>, item: &rustc_ast::Item) {
521         check_empty_line_after_outer_attr(cx, item);
522     }
523
524     fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) {
525         check_deprecated_cfg_attr(cx, attr, self.msrv);
526         check_mismatched_target_os(cx, attr);
527     }
528
529     extract_msrv_attr!(EarlyContext);
530 }
531
532 fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::Item) {
533     for attr in &item.attrs {
534         let attr_item = if let AttrKind::Normal(ref attr, _) = attr.kind {
535             attr
536         } else {
537             return;
538         };
539
540         if attr.style == AttrStyle::Outer {
541             if attr_item.args.inner_tokens().is_empty() || !is_present_in_source(cx, attr.span) {
542                 return;
543             }
544
545             let begin_of_attr_to_item = Span::new(attr.span.lo(), item.span.lo(), item.span.ctxt(), item.span.parent());
546             let end_of_attr_to_item = Span::new(attr.span.hi(), item.span.lo(), item.span.ctxt(), item.span.parent());
547
548             if let Some(snippet) = snippet_opt(cx, end_of_attr_to_item) {
549                 let lines = snippet.split('\n').collect::<Vec<_>>();
550                 let lines = without_block_comments(lines);
551
552                 if lines.iter().filter(|l| l.trim().is_empty()).count() > 2 {
553                     span_lint(
554                         cx,
555                         EMPTY_LINE_AFTER_OUTER_ATTR,
556                         begin_of_attr_to_item,
557                         "found an empty line after an outer attribute. \
558                         Perhaps you forgot to add a `!` to make it an inner attribute?",
559                     );
560                 }
561             }
562         }
563     }
564 }
565
566 fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute, msrv: Option<RustcVersion>) {
567     if_chain! {
568         if meets_msrv(msrv.as_ref(), &msrvs::TOOL_ATTRIBUTES);
569         // check cfg_attr
570         if attr.has_name(sym::cfg_attr);
571         if let Some(items) = attr.meta_item_list();
572         if items.len() == 2;
573         // check for `rustfmt`
574         if let Some(feature_item) = items[0].meta_item();
575         if feature_item.has_name(sym::rustfmt);
576         // check for `rustfmt_skip` and `rustfmt::skip`
577         if let Some(skip_item) = &items[1].meta_item();
578         if skip_item.has_name(sym!(rustfmt_skip)) ||
579             skip_item.path.segments.last().expect("empty path in attribute").ident.name == sym::skip;
580         // Only lint outer attributes, because custom inner attributes are unstable
581         // Tracking issue: https://github.com/rust-lang/rust/issues/54726
582         if attr.style == AttrStyle::Outer;
583         then {
584             span_lint_and_sugg(
585                 cx,
586                 DEPRECATED_CFG_ATTR,
587                 attr.span,
588                 "`cfg_attr` is deprecated for rustfmt and got replaced by tool attributes",
589                 "use",
590                 "#[rustfmt::skip]".to_string(),
591                 Applicability::MachineApplicable,
592             );
593         }
594     }
595 }
596
597 fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
598     fn find_os(name: &str) -> Option<&'static str> {
599         UNIX_SYSTEMS
600             .iter()
601             .chain(NON_UNIX_SYSTEMS.iter())
602             .find(|&&os| os == name)
603             .copied()
604     }
605
606     fn is_unix(name: &str) -> bool {
607         UNIX_SYSTEMS.iter().any(|&os| os == name)
608     }
609
610     fn find_mismatched_target_os(items: &[NestedMetaItem]) -> Vec<(&str, Span)> {
611         let mut mismatched = Vec::new();
612
613         for item in items {
614             if let NestedMetaItem::MetaItem(meta) = item {
615                 match &meta.kind {
616                     MetaItemKind::List(list) => {
617                         mismatched.extend(find_mismatched_target_os(list));
618                     },
619                     MetaItemKind::Word => {
620                         if_chain! {
621                             if let Some(ident) = meta.ident();
622                             if let Some(os) = find_os(&*ident.name.as_str());
623                             then {
624                                 mismatched.push((os, ident.span));
625                             }
626                         }
627                     },
628                     MetaItemKind::NameValue(..) => {},
629                 }
630             }
631         }
632
633         mismatched
634     }
635
636     if_chain! {
637         if attr.has_name(sym::cfg);
638         if let Some(list) = attr.meta_item_list();
639         let mismatched = find_mismatched_target_os(&list);
640         if !mismatched.is_empty();
641         then {
642             let mess = "operating system used in target family position";
643
644             span_lint_and_then(cx, MISMATCHED_TARGET_OS, attr.span, mess, |diag| {
645                 // Avoid showing the unix suggestion multiple times in case
646                 // we have more than one mismatch for unix-like systems
647                 let mut unix_suggested = false;
648
649                 for (os, span) in mismatched {
650                     let sugg = format!("target_os = \"{}\"", os);
651                     diag.span_suggestion(span, "try", sugg, Applicability::MaybeIncorrect);
652
653                     if !unix_suggested && is_unix(os) {
654                         diag.help("did you mean `unix`?");
655                         unix_suggested = true;
656                     }
657                 }
658             });
659         }
660     }
661 }
662
663 fn is_lint_level(symbol: Symbol) -> bool {
664     matches!(symbol, sym::allow | sym::warn | sym::deny | sym::forbid)
665 }