rust-lang / rust-lang/rust

Tracking Issue for future-incompatibility lint `out_of_scope_macro_calls`

Open
#144,406 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-decl-macros-1-2 A-lints A-macros C-future-incompatibility C-tracking-issue T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The out_of_scope_macro_calls lint detects macro_rules called when they are not in scope,
above their definition, which may happen in key-value attributes.

Example
#![doc = in_root!()]

macro_rules! in_root { () => { "" } }

fn main() {}
Explanation

The scope in which a macro_rules item is visible starts at that item and continues
below it. This is more similar to let than to other items, which are in scope both above
and below their definition.
Due to a bug macro_rules were accidentally in scope inside some key-value attributes
above their definition. The lint catches such cases.
To address the issue turn the macro_rules into a regularly scoped item by importing it
with use.

Implementation history

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.

Research direction

Review the lint behavior and implementation history through the linked pull requests, starting with the introduction of out_of_scope_macro_calls and its allow/warn/deny integration. The work is complete when the lint is turned into a hard error without reintroducing the documented false positives or the undesirable unused_imports warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.