Expand on lints with macro spans.

Open
#544 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
documentation

Research direction

Start with the diagnostics page covering allow, warn, deny, and forbid, then compare its treatment of macro-generated items with the external-macro example in this issue. Read the related issue 58502 for the local-identifier case. Done would require a clearly scoped explanation of lint behavior for macro spans, including the cases and lint phases that are in scope.

Written by the indexing model from the issue text.

Description

A-attributes A-diagnostics

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 https://github.com/rust-lang/rust/issues/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.

Dominant language
Rust
Stars
1.6k
Forks
607
Avg merge
1d 1h
Merged PRs (30d)
12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/reference

All issues in rust-lang/reference

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.