Merge pull request #17757 from geoffw0/unusedvar7

Rust: Remove the workaround in rust/unused-variable.
This commit is contained in:
Geoffrey White
2024-11-05 15:06:48 +00:00
committed by GitHub
4 changed files with 3 additions and 4 deletions

View File

@@ -10,6 +10,5 @@ predicate isUnused(Variable v) {
not exists(v.getAnAccess()) and
not exists(v.getInitializer()) and
not v instanceof DiscardVariable and
not v.getPat().isInMacroExpansion() and
exists(File f | f.getBaseName() = "main.rs" | v.getLocation().getFile() = f) // temporarily severely limit results
not v.getPat().isInMacroExpansion()
}

View File

@@ -14,7 +14,6 @@
| main.rs:270:13:270:17 | total | Variable $@ is assigned a value that is never used. | main.rs:238:13:238:17 | total | total |
| main.rs:363:9:363:9 | x | Variable $@ is assigned a value that is never used. | main.rs:363:9:363:9 | x | x |
| main.rs:371:17:371:17 | x | Variable $@ is assigned a value that is never used. | main.rs:371:17:371:17 | x | x |
| more.rs:24:9:24:11 | val | Variable $@ is assigned a value that is never used. | more.rs:24:9:24:11 | val | val |
| 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 |
| 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 |
| 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 |

View File

@@ -19,3 +19,4 @@
| main.rs:417:26:417:28 | val | Variable 'val' is not used. |
| main.rs:420:21:420:23 | acc | Variable 'acc' is not used. |
| main.rs:441:9:441:14 | unused | Variable 'unused' is not used. |
| more.rs:24:9:24:11 | val | Variable 'val' is not used. |

View File

@@ -21,7 +21,7 @@ impl<T> MySettable<T> for MyContainer<T> {
impl<T> MyGettable<T> for MyContainer<T> {
fn get(
&self,
val: T, // $ SPURIOUS: Alert[rust/unused-value] $ MISSING: Alert[rust/unused-variable]
val: T, // $ Alert[rust/unused-variable]
) -> &T {
return &(self.val);
}