Skip to content

Commit

Permalink
Add tests for #[doc(test(...)] check
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Mar 4, 2021
1 parent a66bf52 commit 85c3d10
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test/rustdoc-ui/doc-attr2.rs
@@ -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
}
26 changes: 26 additions & 0 deletions src/test/rustdoc-ui/doc-attr2.stderr
@@ -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_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: `#![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

11 changes: 11 additions & 0 deletions src/test/ui/attributes/doc-attr2.rs
@@ -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
}
26 changes: 26 additions & 0 deletions src/test/ui/attributes/doc-attr2.stderr
@@ -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_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: `#![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

0 comments on commit 85c3d10

Please sign in to comment.