Skip to content

Commit bb5ee52

Browse files
authored
Merge pull request github#17757 from geoffw0/unusedvar7
Rust: Remove the workaround in rust/unused-variable.
2 parents 3cdf94e + 088dd50 commit bb5ee52

File tree

4 files changed

+3
-4
lines changed

4 files changed

+3
-4
lines changed

rust/ql/src/queries/unusedentities/UnusedVariable.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ predicate isUnused(Variable v) {
1010
not exists(v.getAnAccess()) and
1111
not exists(v.getInitializer()) and
1212
not v instanceof DiscardVariable and
13-
not v.getPat().isInMacroExpansion() and
14-
exists(File f | f.getBaseName() = "main.rs" | v.getLocation().getFile() = f) // temporarily severely limit results
13+
not v.getPat().isInMacroExpansion()
1514
}

rust/ql/test/query-tests/unusedentities/UnusedValue.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
| main.rs:270:13:270:17 | total | Variable $@ is assigned a value that is never used. | main.rs:238:13:238:17 | total | total |
1515
| main.rs:363:9:363:9 | x | Variable $@ is assigned a value that is never used. | main.rs:363:9:363:9 | x | x |
1616
| main.rs:371:17:371:17 | x | Variable $@ is assigned a value that is never used. | main.rs:371:17:371:17 | x | x |
17-
| more.rs:24:9:24:11 | val | Variable $@ is assigned a value that is never used. | more.rs:24:9:24:11 | val | val |
1817
| more.rs:44:9:44:14 | a_ptr4 | Variable $@ is assigned a value that is never used. | more.rs:44:9:44:14 | a_ptr4 | a_ptr4 |
1918
| more.rs:59:9:59:13 | d_ptr | Variable $@ is assigned a value that is never used. | more.rs:59:9:59:13 | d_ptr | d_ptr |
2019
| more.rs:65:9:65:17 | f_ptr | Variable $@ is assigned a value that is never used. | more.rs:65:13:65:17 | f_ptr | f_ptr |

rust/ql/test/query-tests/unusedentities/UnusedVariable.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
| main.rs:417:26:417:28 | val | Variable 'val' is not used. |
2020
| main.rs:420:21:420:23 | acc | Variable 'acc' is not used. |
2121
| main.rs:441:9:441:14 | unused | Variable 'unused' is not used. |
22+
| more.rs:24:9:24:11 | val | Variable 'val' is not used. |

rust/ql/test/query-tests/unusedentities/more.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<T> MySettable<T> for MyContainer<T> {
2121
impl<T> MyGettable<T> for MyContainer<T> {
2222
fn get(
2323
&self,
24-
val: T, // $ SPURIOUS: Alert[rust/unused-value] $ MISSING: Alert[rust/unused-variable]
24+
val: T, // $ Alert[rust/unused-variable]
2525
) -> &T {
2626
return &(self.val);
2727
}

0 commit comments

Comments
 (0)