Skip to content

Commit

Permalink
Also use INVALID_DOC_ATTRIBUTE for "unknown doc attribute" warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Mar 4, 2021
1 parent 85c3d10 commit 55cec90
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
7 changes: 1 addition & 6 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,19 +585,14 @@ impl CheckAttrVisitor<'tcx> {
.any(|m| i_meta.has_name(*m))
{
self.tcx.struct_span_lint_hir(
UNUSED_ATTRIBUTES,
INVALID_DOC_ATTRIBUTE,
hir_id,
i_meta.span,
|lint| {
lint.build(&format!(
"unknown `doc` attribute `{}`",
i_meta.name_or_empty()
))
.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
)
.emit();
},
);
Expand Down
7 changes: 3 additions & 4 deletions src/test/rustdoc-ui/doc-attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#![crate_type = "lib"]
#![deny(unused_attributes)]
//~^ NOTE lint level is defined here
#![deny(warnings)]
#![doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
//~^^ WARN

#[doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
//~^^ WARN
pub fn foo() {}
11 changes: 7 additions & 4 deletions src/test/rustdoc-ui/doc-attr.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:8:7
--> $DIR/doc-attr.rs:7:7
|
LL | #[doc(as_ptr)]
| ^^^^^^
|
note: the lint level is defined here
--> $DIR/doc-attr.rs:2:9
|
LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
LL | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(invalid_doc_attribute)]` implied by `#[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 `as_ptr`
--> $DIR/doc-attr.rs:4:8
--> $DIR/doc-attr.rs:3:8
|
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

7 changes: 3 additions & 4 deletions src/test/ui/attributes/doc-attr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#![crate_type = "lib"]
#![deny(unused_attributes)]
//~^ NOTE lint level is defined here
#![deny(warnings)]
#![doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
//~^^ WARN

#[doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
//~^^ WARN
pub fn foo() {}
11 changes: 7 additions & 4 deletions src/test/ui/attributes/doc-attr.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:8:7
--> $DIR/doc-attr.rs:7:7
|
LL | #[doc(as_ptr)]
| ^^^^^^
|
note: the lint level is defined here
--> $DIR/doc-attr.rs:2:9
|
LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
LL | #![deny(warnings)]
| ^^^^^^^^
= note: `#[deny(invalid_doc_attribute)]` implied by `#[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 `as_ptr`
--> $DIR/doc-attr.rs:4:8
--> $DIR/doc-attr.rs:3:8
|
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

0 comments on commit 55cec90

Please sign in to comment.