Skip to content

false positive double_negations warning with macro invocation #143980

@anatawa12

Description

@anatawa12

I tried this code:

macro_rules! neg {
    ($value: expr) => { -$value }
}

fn test() {
    let value = 1;
    let _ = neg!(-value);
}

https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=0e6ac86ed0b4b3573551f8537f083c7a

I expected to see this happen: No double_negations warnings

Instead, this happened: double_negations warning

Meta

rustc --version --verbose:

1.90.0-nightly
(2025-07-14 a001497644bc229f1abc)

(Playgournd)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.L-double_negationsLint: double_negationsL-false-positiveLint: False positive (should not have fired).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