diff options
| -rw-r--r-- | src/librustc/lint/levels.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/lint/empty-lint-attributes.rs | 17 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index d44facedc8b..732b32cc35d 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -216,9 +216,14 @@ impl<'a> LintLevelsBuilder<'a> { } else { let mut err = bad_attr(meta.span); err.emit(); - continue + continue; }; + if metas.is_empty() { + // FIXME (#55112): issue unused-attributes lint for `#[level()]` + continue; + } + // Before processing the lint names, look for a reason (RFC 2383) // at the end. let mut reason = None; @@ -231,6 +236,8 @@ impl<'a> LintLevelsBuilder<'a> { if item.ident == "reason" { // found reason, reslice meta list to exclude it metas = &metas[0..metas.len()-1]; + // FIXME (#55112): issue unused-attributes lint if we thereby + // don't have any lint names (`#[level(reason = "foo")]`) if let ast::LitKind::Str(rationale, _) = name_value.node { if gate_reasons { feature_gate::emit_feature_err( diff --git a/src/test/ui/lint/empty-lint-attributes.rs b/src/test/ui/lint/empty-lint-attributes.rs new file mode 100644 index 00000000000..1f0a9538d88 --- /dev/null +++ b/src/test/ui/lint/empty-lint-attributes.rs @@ -0,0 +1,17 @@ +#![feature(lint_reasons)] + +// run-pass + +// Empty (and reason-only) lint attributes are legal—although we may want to +// lint them in the future (Issue #55112). + +#![allow()] +#![warn(reason = "observationalism")] + +#[forbid()] +fn devoir() {} + +#[deny(reason = "ultion")] +fn waldgrave() {} + +fn main() {} |
