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

Expand on lints with macro spans. #544

Open
ehuss opened this issue Mar 16, 2019 · 1 comment
Open

Expand on lints with macro spans. #544

ehuss opened this issue Mar 16, 2019 · 1 comment
Labels
A-attributes Area: Attributes

Comments

@ehuss
Copy link
Contributor

ehuss commented Mar 16, 2019

Lints behave a little strange with macros, particularly from external crates. This should probably be captured somewhere, probably the diagnostics page for allow/warn/deny/forbid.

For example, lints generated on items created by an extern macro do not fire. Calling the following will not trigger a (deny by default) lint:

#[macro_export]
macro_rules! thing {
    () => {
        #[no_mangle]
        pub const FOO: i32 = 5;
    }
}

See also rust-lang/rust#58502 where the ident comes from the local crate, but does not pick up the global lint level of the extern crate.

So I imagine there are a variety of things to consider (the location of a span, the lint level of the local and extern crates, etc.). I don't know where to begin distilling how things work. Perhaps it is not as complex as it appears. I also get the impression that it depends on exactly which lint it is, since some are done at different phases.

@ehuss ehuss added the A-attributes Area: Attributes label Mar 16, 2019
@petrochenkov
Copy link
Contributor

The intent is to report a lint if it can be addressed by the person encountering it, and not report it if the code comes from third party and cannot be fixed.
So, the characteristic span needs to be chosen accordingly (cc rust-lang/rust#50122 which is a related issue).

but does not pick up the global lint level of the extern crate.

Lint level of the external crate is never picked, we don't have this kind of hygiene.
allow/warn/deny/forbid attributes only work as a tree applied to expanded local crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes
Projects
None yet
Development

No branches or pull requests

2 participants