-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow #![doc(test(attr(..)))]
everywhere
#140560
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
Open
Urgau
wants to merge
6
commits into
rust-lang:master
Choose a base branch
from
Urgau:test_attr-module-level
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+704
−101
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
eec894d
Fix future-incompatible lint group test
Urgau 80c6a08
Allow `#![doc(test(attr(..)))]` at module level too
Urgau 9d9705f
Collect and use `#![doc(test(attr(..)))]` at module level too
Urgau 041d95d
Allow `#![doc(test(attr(..)))]` doctests to be again merged together
Urgau 316e62a
Allow `#![doc(test(attr(..)))]` at every level
Urgau d96d3be
Collect and use `#[doc(test(attr(..)))]` at every level
Urgau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,116 @@ | ||
// Same test as dead-code-module but with 2 doc(test(attr())) at different levels. | ||
|
||
//@ edition: 2024 | ||
//@ compile-flags:--test --test-args=--test-threads=1 | ||
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" | ||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
//@ failure-status: 101 | ||
|
||
#![doc(test(attr(deny(warnings))))] | ||
|
||
#[doc(test(attr(allow(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait OnlyWarning { fn no_deny_warnings(); } | ||
/// ``` | ||
static S: u32 = 5; | ||
|
||
#[doc(test(attr(allow(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// let unused_error = 5; | ||
/// | ||
/// fn dead_code_but_no_error() {} | ||
/// ``` | ||
const C: u32 = 5; | ||
|
||
#[doc(test(attr(allow(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait OnlyWarningAtA { fn no_deny_warnings(); } | ||
/// ``` | ||
struct A { | ||
#[doc(test(attr(deny(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait DeadCodeInField {} | ||
/// ``` | ||
field: u32 | ||
} | ||
|
||
#[doc(test(attr(allow(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait OnlyWarningAtU { fn no_deny_warnings(); } | ||
/// ``` | ||
union U { | ||
#[doc(test(attr(deny(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait DeadCodeInUnionField {} | ||
/// ``` | ||
field: u32, | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait NotDeadCodeInUnionField {} | ||
/// ``` | ||
field2: u64, | ||
} | ||
|
||
#[doc(test(attr(deny(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// let not_dead_code_but_unused = 5; | ||
/// ``` | ||
enum Enum { | ||
#[doc(test(attr(allow(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait NotDeadCodeInVariant {} | ||
/// | ||
/// fn main() { let unused_in_variant = 5; } | ||
/// ``` | ||
Variant1, | ||
} | ||
|
||
#[doc(test(attr(allow(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait OnlyWarningAtImplA { fn no_deny_warnings(); } | ||
/// ``` | ||
impl A { | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait NotDeadCodeInImplMethod {} | ||
/// ``` | ||
fn method() {} | ||
} | ||
|
||
#[doc(test(attr(deny(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait StillDeadCodeAtMyTrait { } | ||
/// ``` | ||
trait MyTrait { | ||
#[doc(test(attr(allow(dead_code))))] | ||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait NotDeadCodeAtImplFn {} | ||
/// | ||
/// fn main() { let unused_in_impl = 5; } | ||
/// ``` | ||
fn my_trait_fn(); | ||
} |
This file contains hidden or 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,146 @@ | ||
|
||
running 13 tests | ||
test $DIR/dead-code-items.rs - A (line 32) - compile ... ok | ||
test $DIR/dead-code-items.rs - A (line 88) - compile ... ok | ||
test $DIR/dead-code-items.rs - A::field (line 39) - compile ... FAILED | ||
test $DIR/dead-code-items.rs - A::method (line 94) - compile ... ok | ||
test $DIR/dead-code-items.rs - C (line 22) - compile ... FAILED | ||
test $DIR/dead-code-items.rs - Enum (line 70) - compile ... FAILED | ||
test $DIR/dead-code-items.rs - Enum::Variant1 (line 77) - compile ... FAILED | ||
test $DIR/dead-code-items.rs - MyTrait (line 103) - compile ... FAILED | ||
test $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) - compile ... FAILED | ||
test $DIR/dead-code-items.rs - S (line 14) - compile ... ok | ||
test $DIR/dead-code-items.rs - U (line 48) - compile ... ok | ||
test $DIR/dead-code-items.rs - U::field (line 55) - compile ... FAILED | ||
test $DIR/dead-code-items.rs - U::field2 (line 61) - compile ... ok | ||
|
||
failures: | ||
|
||
---- $DIR/dead-code-items.rs - A::field (line 39) stdout ---- | ||
error: trait `DeadCodeInField` is never used | ||
--> $DIR/dead-code-items.rs:40:7 | ||
| | ||
LL | trait DeadCodeInField {} | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-items.rs:38:9 | ||
| | ||
LL | #![deny(dead_code)] | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
---- $DIR/dead-code-items.rs - C (line 22) stdout ---- | ||
error: unused variable: `unused_error` | ||
--> $DIR/dead-code-items.rs:23:5 | ||
| | ||
LL | let unused_error = 5; | ||
| ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_error` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-items.rs:20:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
---- $DIR/dead-code-items.rs - Enum (line 70) stdout ---- | ||
error: unused variable: `not_dead_code_but_unused` | ||
--> $DIR/dead-code-items.rs:71:5 | ||
| | ||
LL | let not_dead_code_but_unused = 5; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_not_dead_code_but_unused` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-items.rs:68:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
---- $DIR/dead-code-items.rs - Enum::Variant1 (line 77) stdout ---- | ||
error: unused variable: `unused_in_variant` | ||
--> $DIR/dead-code-items.rs:80:17 | ||
| | ||
LL | fn main() { let unused_in_variant = 5; } | ||
| ^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_in_variant` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-items.rs:75:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
---- $DIR/dead-code-items.rs - MyTrait (line 103) stdout ---- | ||
error: trait `StillDeadCodeAtMyTrait` is never used | ||
--> $DIR/dead-code-items.rs:104:7 | ||
| | ||
LL | trait StillDeadCodeAtMyTrait { } | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-items.rs:102:9 | ||
| | ||
LL | #![deny(dead_code)] | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
---- $DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) stdout ---- | ||
error: unused variable: `unused_in_impl` | ||
--> $DIR/dead-code-items.rs:113:17 | ||
| | ||
LL | fn main() { let unused_in_impl = 5; } | ||
| ^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_unused_in_impl` | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-items.rs:108:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
---- $DIR/dead-code-items.rs - U::field (line 55) stdout ---- | ||
error: trait `DeadCodeInUnionField` is never used | ||
--> $DIR/dead-code-items.rs:56:7 | ||
| | ||
LL | trait DeadCodeInUnionField {} | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-items.rs:54:9 | ||
| | ||
LL | #![deny(dead_code)] | ||
| ^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
|
||
failures: | ||
$DIR/dead-code-items.rs - A::field (line 39) | ||
$DIR/dead-code-items.rs - C (line 22) | ||
$DIR/dead-code-items.rs - Enum (line 70) | ||
$DIR/dead-code-items.rs - Enum::Variant1 (line 77) | ||
$DIR/dead-code-items.rs - MyTrait (line 103) | ||
$DIR/dead-code-items.rs - MyTrait::my_trait_fn (line 110) | ||
$DIR/dead-code-items.rs - U::field (line 55) | ||
|
||
test result: FAILED. 6 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
This file contains hidden or 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,27 @@ | ||
// Same test as dead-code-module but with 2 doc(test(attr())) at different levels. | ||
|
||
//@ edition: 2024 | ||
//@ compile-flags:--test | ||
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" | ||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
//@ failure-status: 101 | ||
|
||
#![doc(test(attr(allow(unused_variables))))] | ||
|
||
mod my_mod { | ||
#![doc(test(attr(deny(warnings))))] | ||
|
||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait T { fn f(); } | ||
/// ``` | ||
pub fn f() {} | ||
} | ||
|
||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait OnlyWarning { fn no_deny_warnings(); } | ||
/// ``` | ||
pub fn g() {} |
This file contains hidden or 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,35 @@ | ||
|
||
running 1 test | ||
test $DIR/dead-code-module-2.rs - g (line 24) - compile ... ok | ||
|
||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
||
|
||
running 1 test | ||
test $DIR/dead-code-module-2.rs - my_mod::f (line 16) - compile ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/dead-code-module-2.rs - my_mod::f (line 16) stdout ---- | ||
error: trait `T` is never used | ||
--> $DIR/dead-code-module-2.rs:17:7 | ||
| | ||
LL | trait T { fn f(); } | ||
| ^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-module-2.rs:15:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(dead_code)]` implied by `#[deny(warnings)]` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
|
||
failures: | ||
$DIR/dead-code-module-2.rs - my_mod::f (line 16) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
This file contains hidden or 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,18 @@ | ||
// Same test as dead-code but inside a module. | ||
|
||
//@ edition: 2024 | ||
//@ compile-flags:--test | ||
//@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" | ||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
//@ failure-status: 101 | ||
|
||
mod my_mod { | ||
#![doc(test(attr(allow(unused_variables), deny(warnings))))] | ||
|
||
/// Example | ||
/// | ||
/// ```rust,no_run | ||
/// trait T { fn f(); } | ||
/// ``` | ||
pub fn f() {} | ||
} |
This file contains hidden or 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,29 @@ | ||
|
||
running 1 test | ||
test $DIR/dead-code-module.rs - my_mod::f (line 14) - compile ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/dead-code-module.rs - my_mod::f (line 14) stdout ---- | ||
error: trait `T` is never used | ||
--> $DIR/dead-code-module.rs:15:7 | ||
| | ||
LL | trait T { fn f(); } | ||
| ^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/dead-code-module.rs:13:9 | ||
| | ||
LL | #![deny(warnings)] | ||
| ^^^^^^^^ | ||
= note: `#[deny(dead_code)]` implied by `#[deny(warnings)]` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
Couldn't compile the test. | ||
|
||
failures: | ||
$DIR/dead-code-module.rs - my_mod::f (line 14) | ||
|
||
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
This file contains hidden or 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 @@ | ||
//@ check-pass | ||
|
||
#![crate_type = "lib"] | ||
#![deny(invalid_doc_attributes)] | ||
#![doc(test(no_crate_inject))] | ||
|
||
mod my_mod { | ||
#![doc(test(attr(deny(warnings))))] | ||
|
||
pub fn foo() {} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.