Skip to content

cfg_select is not marking selected branches as expansion #162481

Description

@blyxyas

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 rust-lang/rust-clippy#17498 and rust-lang/rust-clippy#17508
cc @folkertdev since you were to one to implement it, maybe you can shine some insights!! (ฅ`・ω・´)っ=

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-cfg_selectArea: `cfg_select!`C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions