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