-
Notifications
You must be signed in to change notification settings - Fork 802
Let dead_code
lint work on #[instrument]
ed functions
#3108
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
Conversation
b1af999
to
0928c37
Compare
dead_code
lint work on #[instrument
ed functionsdead_code
lint work on #[instrument]
ed functions
5c58b47
to
cb4d357
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love it! Could you rebase?
examples/examples/tower-load.rs
Outdated
@@ -72,6 +72,7 @@ async fn main() -> Result<(), Err> { | |||
let svc = Server::bind(&addr).serve(svc); | |||
let admin = Server::bind(&admin_addr).serve(admin); | |||
|
|||
#[allow(clippy::incompatible_msrv)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this won't be needed anymore after rebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to remove on my machine, let's see about CI...
@@ -10,7 +10,6 @@ async fn simple_mismatch() -> String { | |||
"" | |||
} | |||
|
|||
// FIXME: this span is still pretty poor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, removing this comment moved all the error locations...
| |_^ expected `i32`, found `()` | ||
--> tests/ui/async_instrument.rs:40:1 | ||
| | ||
40 | #[tracing::instrument] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This span is a little worse now, unfortunately. Not sure what's up with that.
@jplatte Rebased, PTAL! |
Closes (partially?) tokio-rs#1366
Looks like this closed #3207 too |
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.
Yes, please! I suspect that one is probably a lot harder to fix, I have a PR up for the first regression now. |
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
Motivation
#[instrument]
ed functions never trigger adead_code
lint.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