Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change error about unknown attributes to a warning #82702

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,16 +567,23 @@ impl CheckAttrVisitor<'tcx> {
.iter()
.any(|m| i_meta.has_name(*m))
{
self.tcx
.sess
.struct_span_err(
meta.span(),
&format!(
self.tcx.struct_span_lint_hir(
UNUSED_ATTRIBUTES,
hir_id,
i_meta.span,
|lint| {
lint.build(&format!(
"unknown `doc` attribute `{}`",
i_meta.name_or_empty(),
),
)
.emit();
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();
},
);
return false;
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/test/rustdoc-ui/doc-attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#![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() {}
13 changes: 11 additions & 2 deletions src/test/rustdoc-ui/doc-attr.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:4:7
--> $DIR/doc-attr.rs:8:7
|
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`
--> $DIR/doc-attr.rs:2:8
--> $DIR/doc-attr.rs:4: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!

error: aborting due to 2 previous errors

10 changes: 8 additions & 2 deletions src/test/ui/attributes/doc-attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#![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() {}
13 changes: 11 additions & 2 deletions src/test/ui/attributes/doc-attr.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
error: unknown `doc` attribute `as_ptr`
--> $DIR/doc-attr.rs:4:7
--> $DIR/doc-attr.rs:8:7
|
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`
--> $DIR/doc-attr.rs:2:8
--> $DIR/doc-attr.rs:4: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!

error: aborting due to 2 previous errors