rust-lang / rust-lang/rust

`cfg_select` is not marking selected branches as expansion

Open
#162,481 5 comments 0 reactions 1 assignee View on GitHub

@saberoueslati is already working on this.

Since Sep 8, 2026.

A-cfg_select C-bug T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Playground link

I tried this code:

fn main() {
    cfg_select! {
        true => {
            let a = 1 + 1;
        }
        false => {
            let b = 1 + 1;
        }
    }
}

I expected to see this happen: The selected branch should be marked as an expansion, so Span::from_expansion should return true.

Instead, this happened: The selected branch is pasted directly, without being marked as a macro expansion (or any expansion of any kind). This produces a bug in Clippy.

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (c54751567 2026-08-22)
binary: rustc
commit-hash: c54751567b19c4ceb08b0412d83529c2568cba8b
commit-date: 2026-08-22
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

cc https://github.com/rust-lang/rust-clippy/issues/17498 and https://github.com/rust-lang/rust-clippy/pull/17508
cc @folkertdev since you were to one to implement it, maybe you can shine some insights!! (ฅ`・ω・´)っ=

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.