forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#82708 - GuillaumeGomez:doc-test-attr-check,…
… r=Manishearth Warn on `#![doc(test(...))]` on items other than the crate root and use future incompatible lint Part of rust-lang#82672. This PR does multiple things: * Create a new `INVALID_DOC_ATTRIBUTE` lint which is also "future incompatible", allowing us to use it as a warning for the moment until it turns (eventually) into a hard error. * Use this link when `#![doc(test(...))]` isn't used at the crate level. * Make rust-lang#82702 use this new lint as well. r? ``@jyn514``
- Loading branch information
Showing
10 changed files
with
143 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_attributes)]` 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![crate_type = "lib"] | ||
#![deny(warnings)] | ||
|
||
#[doc(test(no_crate_inject))] //~ ERROR | ||
//~^ WARN | ||
pub fn foo() {} | ||
|
||
pub mod bar { | ||
#![doc(test(no_crate_inject))] //~ ERROR | ||
//~^ WARN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error: `#![doc(test(...)]` is only allowed as a crate level attribute | ||
--> $DIR/doc-attr2.rs:4:7 | ||
| | ||
LL | #[doc(test(no_crate_inject))] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/doc-attr2.rs:2:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(invalid_doc_attributes)]` 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: `#![doc(test(...)]` is only allowed as a crate level attribute | ||
--> $DIR/doc-attr2.rs:9:12 | ||
| | ||
LL | #![doc(test(no_crate_inject))] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_attributes)]` 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#![crate_type = "lib"] | ||
#![deny(warnings)] | ||
|
||
#[doc(test(no_crate_inject))] //~ ERROR | ||
//~^ WARN | ||
pub fn foo() {} | ||
|
||
pub mod bar { | ||
#![doc(test(no_crate_inject))] //~ ERROR | ||
//~^ WARN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error: `#![doc(test(...)]` is only allowed as a crate level attribute | ||
--> $DIR/doc-attr2.rs:4:7 | ||
| | ||
LL | #[doc(test(no_crate_inject))] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/doc-attr2.rs:2:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(invalid_doc_attributes)]` 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: `#![doc(test(...)]` is only allowed as a crate level attribute | ||
--> $DIR/doc-attr2.rs:9:12 | ||
| | ||
LL | #![doc(test(no_crate_inject))] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= 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 | ||
|