File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed
src/queries/unusedentities
test/query-tests/unusedentities Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1111import rust
1212import UnusedVariable
1313
14+ /**
15+ * A callable for which we have incomplete information, for example because an unexpanded
16+ * macro call is present. These callables are prone to false positive results from unused
17+ * entities queries, unless they are excluded from results.
18+ */
19+ class IncompleteCallable extends Callable {
20+ IncompleteCallable ( ) {
21+ exists ( MacroExpr me |
22+ me .getEnclosingCallable ( ) = this and
23+ not me .getMacroCall ( ) .hasExpanded ( )
24+ )
25+ }
26+ }
27+
1428from Variable v
1529where
1630 isUnused ( v ) and
1731 not isAllowableUnused ( v ) and
18- not v instanceof DiscardVariable
32+ not v instanceof DiscardVariable and
33+ not v .getEnclosingCfgScope ( ) instanceof IncompleteCallable
1934select v , "Variable '" + v + "' is not used."
Original file line number Diff line number Diff line change 1919| main.rs:431:26:431:28 | val | Variable 'val' is not used. |
2020| main.rs:434:21:434:23 | acc | Variable 'acc' is not used. |
2121| main.rs:455:9:455:14 | unused | Variable 'unused' is not used. |
22- | main.rs:521:12:521:12 | n | Variable 'n' is not used. |
2322| more.rs:24:9:24:11 | val | Variable 'val' is not used. |
Original file line number Diff line number Diff line change @@ -518,7 +518,7 @@ fn macros4() {
518518
519519fn macros5 ( ) {
520520 match std:: env:: args ( ) . nth ( 1 ) . unwrap ( ) . parse :: < u16 > ( ) {
521- Ok ( n) => { // $ SPURIOUS: Alert[rust/unused-variable]
521+ Ok ( n) => {
522522 undefined_macro_call ! ( n) ;
523523 }
524524 _ => { }
You can’t perform that action at this time.
0 commit comments