Merge pull request #18229 from geoffw0/self

Rust: Fix unwanted 'self' results from rust/unused-variable
This commit is contained in:
Geoffrey White
2024-12-09 08:50:03 +00:00
committed by GitHub
4 changed files with 34 additions and 27 deletions

View File

@@ -23,4 +23,7 @@ predicate isUnused(Variable v) {
predicate isAllowableUnused(Variable v) {
// in a macro expansion
v.getPat().isInMacroExpansion()
or
// a 'self' variable
v.getName() = "self"
}

View File

@@ -8,13 +8,13 @@
| main.rs:65:5:65:5 | f | Variable $@ is assigned a value that is never used. | main.rs:34:13:34:13 | f | f |
| main.rs:67:5:67:5 | f | Variable $@ is assigned a value that is never used. | main.rs:34:13:34:13 | f | f |
| main.rs:69:5:69:5 | g | Variable $@ is assigned a value that is never used. | main.rs:35:9:35:9 | g | g |
| main.rs:91:9:91:9 | a | Variable $@ is assigned a value that is never used. | main.rs:91:9:91:9 | a | a |
| main.rs:112:9:112:10 | is | Variable $@ is assigned a value that is never used. | main.rs:112:9:112:10 | is | is |
| main.rs:135:13:135:17 | total | Variable $@ is assigned a value that is never used. | main.rs:135:13:135:17 | total | total |
| main.rs:280:13:280:17 | total | Variable $@ is assigned a value that is never used. | main.rs:248:13:248:17 | total | total |
| main.rs:373:9:373:9 | x | Variable $@ is assigned a value that is never used. | main.rs:373:9:373:9 | x | x |
| main.rs:381:17:381:17 | x | Variable $@ is assigned a value that is never used. | main.rs:381:17:381:17 | x | x |
| main.rs:482:9:482:9 | c | Variable $@ is assigned a value that is never used. | main.rs:482:9:482:9 | c | c |
| main.rs:95:9:95:9 | a | Variable $@ is assigned a value that is never used. | main.rs:95:9:95:9 | a | a |
| main.rs:116:9:116:10 | is | Variable $@ is assigned a value that is never used. | main.rs:116:9:116:10 | is | is |
| main.rs:139:13:139:17 | total | Variable $@ is assigned a value that is never used. | main.rs:139:13:139:17 | total | total |
| main.rs:284:13:284:17 | total | Variable $@ is assigned a value that is never used. | main.rs:252:13:252:17 | total | total |
| main.rs:377:9:377:9 | x | Variable $@ is assigned a value that is never used. | main.rs:377:9:377:9 | x | x |
| main.rs:385:17:385:17 | x | Variable $@ is assigned a value that is never used. | main.rs:385:17:385:17 | x | x |
| main.rs:486:9:486:9 | c | Variable $@ is assigned a value that is never used. | main.rs:486:9:486:9 | c | c |
| 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

@@ -1,22 +1,22 @@
| main.rs:29:9:29:9 | a | Variable 'a' is not used. |
| main.rs:94:13:94:13 | d | Variable 'd' is not used. |
| main.rs:143:5:143:5 | y | Variable 'y' is not used. |
| main.rs:170:9:170:9 | x | Variable 'x' is not used. |
| main.rs:250:17:250:17 | a | Variable 'a' is not used. |
| main.rs:258:20:258:22 | val | Variable 'val' is not used. |
| main.rs:272:14:272:16 | val | Variable 'val' is not used. |
| main.rs:287:22:287:24 | val | Variable 'val' is not used. |
| main.rs:294:24:294:26 | val | Variable 'val' is not used. |
| main.rs:302:13:302:15 | num | Variable 'num' is not used. |
| main.rs:317:12:317:12 | j | Variable 'j' is not used. |
| main.rs:337:25:337:25 | y | Variable 'y' is not used. |
| main.rs:340:28:340:28 | a | Variable 'a' is not used. |
| main.rs:343:9:343:9 | p | Variable 'p' is not used. |
| main.rs:361:9:361:13 | right | Variable 'right' is not used. |
| main.rs:367:9:367:14 | right2 | Variable 'right2' is not used. |
| main.rs:374:13:374:13 | y | Variable 'y' is not used. |
| main.rs:382:21:382:21 | y | Variable 'y' is not used. |
| main.rs:427:26:427:28 | val | Variable 'val' is not used. |
| main.rs:430:21:430:23 | acc | Variable 'acc' is not used. |
| main.rs:451:9:451:14 | unused | Variable 'unused' is not used. |
| main.rs:98:13:98:13 | d | Variable 'd' is not used. |
| main.rs:147:5:147:5 | y | Variable 'y' is not used. |
| main.rs:174:9:174:9 | x | Variable 'x' is not used. |
| main.rs:254:17:254:17 | a | Variable 'a' is not used. |
| main.rs:262:20:262:22 | val | Variable 'val' is not used. |
| main.rs:276:14:276:16 | val | Variable 'val' is not used. |
| main.rs:291:22:291:24 | val | Variable 'val' is not used. |
| main.rs:298:24:298:26 | val | Variable 'val' is not used. |
| main.rs:306:13:306:15 | num | Variable 'num' is not used. |
| main.rs:321:12:321:12 | j | Variable 'j' is not used. |
| main.rs:341:25:341:25 | y | Variable 'y' is not used. |
| main.rs:344:28:344:28 | a | Variable 'a' is not used. |
| main.rs:347:9:347:9 | p | Variable 'p' is not used. |
| main.rs:365:9:365:13 | right | Variable 'right' is not used. |
| main.rs:371:9:371:14 | right2 | Variable 'right2' is not used. |
| main.rs:378:13:378:13 | y | Variable 'y' is not used. |
| main.rs:386:21:386:21 | y | Variable 'y' is not used. |
| main.rs:431:26:431:28 | val | Variable 'val' is not used. |
| main.rs:434:21:434:23 | acc | Variable 'acc' is not used. |
| main.rs:455:9:455:14 | unused | Variable 'unused' is not used. |
| more.rs:24:9:24:11 | val | Variable 'val' is not used. |

View File

@@ -85,6 +85,10 @@ impl MyStruct {
fn my_get(&mut self) -> i64 {
return self.val;
}
fn get_flags(&self) -> i64 {
return 0;
}
}
fn structs() {