1
Fork 0

Change error about unknown doc attributes to a warning

This prevents breakage across the ecosystem, since the error was just
introduced recently without first having a warning period.
This commit is contained in:
Joshua Nelson 2021-03-02 09:42:32 -05:00
parent edeee915b1
commit 4b2e4e69df
5 changed files with 54 additions and 17 deletions

View file

@ -567,16 +567,23 @@ impl CheckAttrVisitor<'tcx> {
.iter() .iter()
.any(|m| i_meta.has_name(*m)) .any(|m| i_meta.has_name(*m))
{ {
self.tcx self.tcx.struct_span_lint_hir(
.sess UNUSED_ATTRIBUTES,
.struct_span_err( hir_id,
meta.span(), i_meta.span,
&format!( |lint| {
lint.build(&format!(
"unknown `doc` attribute `{}`", "unknown `doc` attribute `{}`",
i_meta.name_or_empty(), i_meta.name_or_empty()
), ))
) .warn(
.emit(); "this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
)
.emit();
},
);
return false; return false;
} }
} }

View file

@ -1,5 +1,11 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#![doc(as_ptr)] //~ ERROR #![deny(unused_attributes)]
//~^ NOTE lint level is defined here
#![doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
#[doc(as_ptr)] //~ ERROR #[doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
pub fn foo() {} pub fn foo() {}

View file

@ -1,14 +1,23 @@
error: unknown `doc` attribute `as_ptr` error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:4:7 --> $DIR/doc-attr.rs:8:7
| |
LL | #[doc(as_ptr)] LL | #[doc(as_ptr)]
| ^^^^^^ | ^^^^^^
|
note: the lint level is defined here
--> $DIR/doc-attr.rs:2:9
|
LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
error: unknown `doc` attribute `as_ptr` error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:2:8 --> $DIR/doc-attr.rs:4:8
| |
LL | #![doc(as_ptr)] 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!
error: aborting due to 2 previous errors error: aborting due to 2 previous errors

View file

@ -1,5 +1,11 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#![doc(as_ptr)] //~ ERROR #![deny(unused_attributes)]
//~^ NOTE lint level is defined here
#![doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
#[doc(as_ptr)] //~ ERROR #[doc(as_ptr)]
//~^ ERROR unknown `doc` attribute
//~| WARNING will become a hard error in a future release
pub fn foo() {} pub fn foo() {}

View file

@ -1,14 +1,23 @@
error: unknown `doc` attribute `as_ptr` error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:4:7 --> $DIR/doc-attr.rs:8:7
| |
LL | #[doc(as_ptr)] LL | #[doc(as_ptr)]
| ^^^^^^ | ^^^^^^
|
note: the lint level is defined here
--> $DIR/doc-attr.rs:2:9
|
LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
error: unknown `doc` attribute `as_ptr` error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:2:8 --> $DIR/doc-attr.rs:4:8
| |
LL | #![doc(as_ptr)] 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!
error: aborting due to 2 previous errors error: aborting due to 2 previous errors