Lint non-meta doc attributes

E.g., `#[doc(123)]`.
This commit is contained in:
Camelid 2021-03-13 13:25:27 -08:00
parent 9613a88db5
commit 7189c05bf8
3 changed files with 37 additions and 1 deletions

View File

@ -605,6 +605,16 @@ impl CheckAttrVisitor<'tcx> {
return false;
}
}
} else {
self.tcx.struct_span_lint_hir(
INVALID_DOC_ATTRIBUTES,
hir_id,
meta.span(),
|lint| {
lint.build(&format!("unknown `doc` attribute")).emit();
},
);
return false;
}
}
}

View File

@ -8,3 +8,11 @@
//~^ ERROR unknown `doc` attribute
//~^^ WARN
pub fn foo() {}
#[doc(123)]
//~^ ERROR unknown `doc` attribute
//~| WARN
#[doc("hello", "bar")]
//~^ ERROR unknown `doc` attribute
//~| WARN
fn bar() {}

View File

@ -13,6 +13,24 @@ LL | #![deny(warnings)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
error: unknown `doc` attribute
--> $DIR/doc-attr.rs:12:7
|
LL | #[doc(123)]
| ^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
error: unknown `doc` attribute
--> $DIR/doc-attr.rs:15:7
|
LL | #[doc("hello", "bar")]
| ^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:3:8
|
@ -22,5 +40,5 @@ LL | #![doc(as_ptr)]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730>
error: aborting due to 2 previous errors
error: aborting due to 4 previous errors