Let dead_code lint work on #[instrument]ed functions#3108
Merged
jplatte merged 1 commit intotokio-rs:masterfrom May 30, 2025
Merged
Let dead_code lint work on #[instrument]ed functions#3108jplatte merged 1 commit intotokio-rs:masterfrom
dead_code lint work on #[instrument]ed functions#3108jplatte merged 1 commit intotokio-rs:masterfrom
Conversation
b1af999 to
0928c37
Compare
dead_code lint work on #[instrumented functionsdead_code lint work on #[instrument]ed functions
5c58b47 to
cb4d357
Compare
jplatte
approved these changes
May 28, 2025
Contributor
jplatte
left a comment
There was a problem hiding this comment.
I love it! Could you rebase?
examples/examples/tower-load.rs
Outdated
| let svc = Server::bind(&addr).serve(svc); | ||
| let admin = Server::bind(&admin_addr).serve(admin); | ||
|
|
||
| #[allow(clippy::incompatible_msrv)] |
Contributor
There was a problem hiding this comment.
Maybe this won't be needed anymore after rebase?
Contributor
Author
There was a problem hiding this comment.
Looks OK to remove on my machine, let's see about CI...
9999years
commented
May 29, 2025
| "" | ||
| } | ||
|
|
||
| // FIXME: this span is still pretty poor |
Contributor
Author
There was a problem hiding this comment.
Sorry, removing this comment moved all the error locations...
9999years
commented
May 29, 2025
| | |_^ expected `i32`, found `()` | ||
| --> tests/ui/async_instrument.rs:40:1 | ||
| | | ||
| 40 | #[tracing::instrument] |
Contributor
Author
There was a problem hiding this comment.
This span is a little worse now, unfortunately. Not sure what's up with that.
Contributor
Author
|
@jplatte Rebased, PTAL! |
Closes (partially?) tokio-rs#1366
25 tasks
hds
pushed a commit
that referenced
this pull request
Jun 2, 2025
hds
pushed a commit
that referenced
this pull request
Jun 3, 2025
hds
added a commit
that referenced
this pull request
Jun 6, 2025
hds
added a commit
that referenced
this pull request
Jun 6, 2025
hds
added a commit
that referenced
this pull request
Jun 6, 2025
hds
added a commit
that referenced
this pull request
Jun 6, 2025
|
Looks like this closed #3207 too |
Contributor
|
Great! Now we just need to fix the regression caused by this 😅 (see #3306) |
This comment was marked as resolved.
This comment was marked as resolved.
Contributor
|
Yes, please! I suspect that one is probably a lot harder to fix, I have a PR up for the first regression now. |
hds
pushed a commit
that referenced
this pull request
Jun 13, 2025
The change to allow the `dead_code` lint to work on the `#[instrument]` attribute (#3108) introduced a shadowing problem which caused compilation failure in certain cases, as reported in #3306. The body of the original function was not given its own scope and `use` statements made there could leak out into the code inserted by the `#[instrument]`. This change fixes this problem by explicitly re-introducing the parenthesis to give the original function body its own scope. Closes #3306
pruthvikar
pushed a commit
to getcarv/tracing
that referenced
this pull request
Mar 7, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
#[instrument]ed functions never trigger adead_codelint.Closes (partially?) #1366
Solution
Include all of the input tokens in the output. In particular, the brace tokens surrounding the function body, the parenthesis surrounding the function parameters, and the angle brackets surrounding the generics must be included.
Prior art: andrewhickman/fn-error-context@cfa749a