-
Notifications
You must be signed in to change notification settings - Fork 847
attributes: fix tracing::instrument regression around shadowing #3311
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
16c5859
Use glob for compile-fail UI tests
jplatte 7ba7273
Add a test for #1366
jplatte 1d2ae9b
Add extra braces to avoid shadowing issues in instrumented fn
jplatte 4425d13
Move compile-fail tests to ui/fail
jplatte 1817e6e
Add a regression test for shadowing bug
jplatte 1ae0e00
Update tracing-attributes/tests/ui/pass/type_shadowing.rs
hds 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| // Only test on nightly, since UI tests are bound to change over time | ||
| // Only test on stable, since UI tests are bound to change over time | ||
|
|
||
| #[rustversion::stable] | ||
| #[test] | ||
| fn async_instrument() { | ||
| fn pass() { | ||
| let t = trybuild::TestCases::new(); | ||
| t.compile_fail("tests/ui/async_instrument.rs"); | ||
| t.pass("tests/ui/pass/*.rs"); | ||
| } | ||
|
|
||
| #[rustversion::stable] | ||
| #[test] | ||
| fn const_instrument() { | ||
| fn compile_fail() { | ||
| let t = trybuild::TestCases::new(); | ||
| t.compile_fail("tests/ui/const_instrument.rs"); | ||
| t.compile_fail("tests/ui/fail/*.rs"); | ||
| } |
File renamed without changes.
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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...tributes/tests/ui/const_instrument.stderr → ...tes/tests/ui/fail/const_instrument.stderr
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,6 @@ | ||
| #![deny(dead_code)] | ||
|
|
||
| #[tracing::instrument] | ||
| fn never_used() {} | ||
|
|
||
| fn main() {} |
11 changes: 11 additions & 0 deletions
11
tracing-attributes/tests/ui/fail/unused_instrumented_fn.stderr
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 @@ | ||
| error: function `never_used` is never used | ||
| --> tests/ui/fail/unused_instrumented_fn.rs:4:4 | ||
| | | ||
| 4 | fn never_used() {} | ||
| | ^^^^^^^^^^ | ||
| | | ||
| note: the lint level is defined here | ||
| --> tests/ui/fail/unused_instrumented_fn.rs:1:9 | ||
| | | ||
| 1 | #![deny(dead_code)] | ||
| | ^^^^^^^^^ |
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,17 @@ | ||
| //! This program is a regression test for [#3306], where shadowing | ||
| //! caused compilation failure in certain cases due to the original | ||
| //! function body not getting its own scope. | ||
| //! | ||
| //! [#3306]: https://github.com/tokio-rs/tracing/issues/3306 | ||
| type Foo = (); | ||
hds marked this conversation as resolved.
Show resolved
Hide resolved
hds marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| enum Bar { | ||
| Foo, | ||
| } | ||
|
|
||
| #[tracing::instrument] | ||
| fn this_is_fine() -> Foo { | ||
| // glob import imports Bar::Foo, shadowing Foo | ||
| use Bar::*; | ||
| } | ||
|
|
||
| fn main() {} | ||
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.