Skip to content
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

With #[context], a function never gets marked unused #3

Closed
jplatte opened this issue Apr 21, 2021 · 3 comments
Closed

With #[context], a function never gets marked unused #3

jplatte opened this issue Apr 21, 2021 · 3 comments

Comments

@jplatte
Copy link

jplatte commented Apr 21, 2021

Title should be self-explanatory. This should result in an unused function warning:

#[context("foo")]
fn never_used() -> anyhow::Result<()> {
    Ok(())
}
@andrewhickman
Copy link
Owner

Unfortunately this looks like a limitation of rust macros. All lints originating from inside an external macro are suppressed (rust-lang/rust#52467)

@andrewhickman
Copy link
Owner

After some experimentation, it turns out we were losing the spans on the { } tokens in the macro output. If we pass them them through directly, rustc seems to decide they're part of the original crate for the purposes of linting

Thanks for the issue!

andrewhickman added a commit that referenced this issue Apr 21, 2021
andrewhickman added a commit that referenced this issue Apr 21, 2021
@andrewhickman
Copy link
Owner

I've published 0.1.2 with the fix for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants