Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random false-positive Variable is never used when the variable used only in a macro #9468

Closed
vlad20012 opened this issue Oct 5, 2022 · 0 comments · Fixed by #9469
Closed
Assignees
Labels
bug subsystem::macros Issues related to macros

Comments

@vlad20012
Copy link
Member

vlad20012 commented Oct 5, 2022

Environment

  • IntelliJ Rust plugin version: 0.4.181.SNAPSHOT-222-dev
  • Rust toolchain version: 1.64.0 (a55dd71d5 2022-09-19) x86_64-unknown-linux-gnu
  • IDE name and version: IntelliJ IDEA 2022.2.2 Ultimate Edition (IU-222.4167.29)
  • Operating system: Linux 5.15.0-48-generic
  • Macro expansion: enabled
  • Additional experimental features: org.rust.cargo.emulate.terminal, org.rust.cargo.evaluate.build.scripts

Problem description

The most obvious manifestation of the bug is randomly appearing Variable is never used false-positive:

image

image

Other symptoms:

  • Go To Declaration does not work for a
  • Find usages for let a does not show the usage in the macro call
  • But Show recursive macro expansion works for the macro call:
    image

Steps to reproduce

It reproduces very randomly, in this sense the bug is similar to #9432. I think it's possible to reproduce it this way:

  1. Type this code somewhere in the codebase:
macro_rules! as_is { ($($ t:tt)*) => { $($ t)* } }

// Foo111
fn main() {
    let a = 0;
    as_is! {
        a;
    }
}
  1. Leave the tab with this code always open.
  2. Then don't type. Use navigation to jump over other source files (e.g. stdlib), use navigation, find usages and so on, i.e., navigation actions, without performing code modifications.
  3. Return to the sample code periodically and type something in the comment // Foo111. Then hope you will see the false-positive there.

Alternatively, you can leave the IDE inactive for several hours, then open it with a hope to with the false-positive there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug subsystem::macros Issues related to macros
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant