1
Fork 0

Rollup merge of #94580 - xFrednet:55112-only-reason-in-lint-attr, r=lcnr

Emit `unused_attributes` if a level attr only has a reason

Fixes a comment from `compiler/rustc_lint/src/levels.rs`. Lint level attributes that only contain a reason will also trigger the `unused_attribute` lint. The lint now also checks for the `expect` lint level.

That's it, have a great rest of the day for everyone reasoning this 🙃

cc: #55112
This commit is contained in:
Matthias Krüger 2022-03-08 11:04:52 +01:00 committed by GitHub
commit 83ed227a8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 133 additions and 41 deletions

View file

@ -258,7 +258,7 @@ impl<'s> LintLevelsBuilder<'s> {
};
if metas.is_empty() {
// FIXME (#55112): issue unused-attributes lint for `#[level()]`
// This emits the unused_attributes lint for `#[level()]`
continue;
}
@ -271,8 +271,6 @@ impl<'s> LintLevelsBuilder<'s> {
ast::MetaItemKind::Word => {} // actual lint names handled later
ast::MetaItemKind::NameValue(ref name_value) => {
if item.path == sym::reason {
// 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.kind {
if !self.sess.features_untracked().lint_reasons {
feature_err(