Rust: Fix some false positives for rust/unused-variable and rust/unused-value
Fix some common false positive results for the rust/unused-variable and rust/unused-value queries. Typically these results look something like this:
match foo {
MY_CONSTANT => { ... }
...
}
Due to incorrect code, incorrect extraction, and/or extraction with the wrong settings MY_CONSTANT is misrecognized as a variable and the query observes that it is not used. I've been unable to produce a test case but its common in the wild and I expect DCA to produce many fixed examples of this.
Unfortunately it turns out this change does exclude some correct results (see the test). I'm not sure how I can improve that, short of looking at the case of the variable name (i.e. heuristic). Lets wait for the DCA results and see what we've got.
DCA showed 1076 results removed. I've reviewed a large number of these and nearly all resemble the typical example in the PR comment above. We do lose a tiny number of results where the target really was a (used or unused) variable - I've since narrowed the change slightly to address that (by checking capitalization as well).