Open bluenote10 opened 11 months ago
Ah, this one is a macro hygienic issue. Here is the expanded code:
let temp = (Node::new());
let temp = (Node::new());
temp.add_child((Node::new()));
temp.add_child(temp);
(Node::new()).add_child(temp)
In reality, those temp
s are different, but r-a treats them as equal, so it thinks the first temp
is an unused variable.
rust-analyzer version: 0.4.1676-standalone
rustc version: rustc 1.72.0 (5680fa18f 2023-08-23)
relevant settings: Not sure of any relevant settings. I typically use
"rust-analyzer.procMacro.enable": true
in the settings, but this doesn't seem to affect the issue.I'm getting false positive "unused variable" warnings from rust-analyzer in the following recursive macro:
I don't think there is an unused variable here,
cargo build
andcargo clippy
don't complain about anything.On first glance it looks like the issue has to do with the depth of the assembled tree, i.e., the depth of the macro recursion, because usages that only involve up to 3 level do not produce a warning, but usages that go 4 levels deep start to produce the warning.