-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17773 from geoffw0/unusedval2
Rust: Implement UnusedValue.ql (2)
- Loading branch information
Showing
8 changed files
with
246 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import rust | ||
|
||
/** A deliberately unused variable. */ | ||
class DiscardVariable extends Variable { | ||
DiscardVariable() { this.getName().charAt(0) = "_" } | ||
} | ||
|
||
/** Holds if variable `v` is unused. */ | ||
predicate isUnused(Variable v) { | ||
not exists(v.getAnAccess()) and | ||
not exists(v.getInitializer()) and | ||
not v instanceof DiscardVariable and | ||
exists(File f | f.getBaseName() = "main.rs" | v.getLocation().getFile() = f) // temporarily severely limit results | ||
} |
26 changes: 16 additions & 10 deletions
26
rust/ql/test/query-tests/unusedentities/CONSISTENCY/CfgConsistency.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
multipleSuccessors | ||
| main.rs:428:17:428:17 | 0 | successor | main.rs:428:9:428:10 | a2 | | ||
| main.rs:428:17:428:17 | 0 | successor | main.rs:428:20:428:62 | ClosureExpr | | ||
| main.rs:431:17:431:17 | 0 | successor | main.rs:431:9:431:10 | a3 | | ||
| main.rs:431:17:431:17 | 0 | successor | main.rs:431:20:431:41 | ClosureExpr | | ||
| main.rs:434:17:434:17 | 0 | successor | main.rs:434:9:434:10 | a4 | | ||
| main.rs:434:17:434:17 | 0 | successor | main.rs:434:20:434:35 | ClosureExpr | | ||
| main.rs:437:17:437:17 | 0 | successor | main.rs:437:9:437:10 | a5 | | ||
| main.rs:437:17:437:17 | 0 | successor | main.rs:437:20:437:35 | ClosureExpr | | ||
| main.rs:441:17:441:17 | 0 | successor | main.rs:441:9:441:10 | a6 | | ||
| main.rs:441:17:441:17 | 0 | successor | main.rs:441:20:441:46 | ClosureExpr | | ||
| main.rs:421:17:421:17 | 0 | successor | main.rs:421:9:421:10 | a2 | | ||
| main.rs:421:17:421:17 | 0 | successor | main.rs:421:20:421:62 | ClosureExpr | | ||
| main.rs:424:17:424:17 | 0 | successor | main.rs:424:9:424:10 | a3 | | ||
| main.rs:424:17:424:17 | 0 | successor | main.rs:424:20:424:41 | ClosureExpr | | ||
| main.rs:427:17:427:17 | 0 | successor | main.rs:427:9:427:10 | a4 | | ||
| main.rs:427:17:427:17 | 0 | successor | main.rs:427:20:427:35 | ClosureExpr | | ||
| main.rs:430:17:430:17 | 0 | successor | main.rs:430:9:430:10 | a5 | | ||
| main.rs:430:17:430:17 | 0 | successor | main.rs:430:20:430:35 | ClosureExpr | | ||
| main.rs:434:17:434:17 | 0 | successor | main.rs:434:9:434:10 | a6 | | ||
| main.rs:434:17:434:17 | 0 | successor | main.rs:434:20:434:46 | ClosureExpr | | ||
| more.rs:32:17:32:17 | a | successor | more.rs:32:5:32:5 | i | | ||
| more.rs:32:17:32:17 | a | successor | more.rs:32:20:32:20 | b | | ||
deadEnd | ||
| more.rs:9:9:9:19 | Param | | ||
| more.rs:38:23:38:28 | Param | | ||
| more.rs:42:19:42:24 | Param | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
| main.rs:6:9:6:9 | a | Variable is assigned a value that is never used. | | ||
| main.rs:9:9:9:9 | d | Variable is assigned a value that is never used. | | ||
| main.rs:35:5:35:5 | b | Variable is assigned a value that is never used. | | ||
| main.rs:37:5:37:5 | c | Variable is assigned a value that is never used. | | ||
| main.rs:40:5:40:5 | c | Variable is assigned a value that is never used. | | ||
| main.rs:44:9:44:9 | d | Variable is assigned a value that is never used. | | ||
| main.rs:50:5:50:5 | e | Variable is assigned a value that is never used. | | ||
| main.rs:61:5:61:5 | f | Variable is assigned a value that is never used. | | ||
| main.rs:63:5:63:5 | f | Variable is assigned a value that is never used. | | ||
| main.rs:65:5:65:5 | g | Variable is assigned a value that is never used. | | ||
| main.rs:87:9:87:9 | a | Variable is assigned a value that is never used. | | ||
| main.rs:108:9:108:10 | is | Variable is assigned a value that is never used. | | ||
| main.rs:133:13:133:17 | total | Variable is assigned a value that is never used. | | ||
| main.rs:203:13:203:31 | res | Variable is assigned a value that is never used. | | ||
| main.rs:218:9:218:24 | kind | Variable is assigned a value that is never used. | | ||
| main.rs:223:9:223:32 | kind | Variable is assigned a value that is never used. | | ||
| main.rs:280:13:280:17 | total | Variable is assigned a value that is never used. | | ||
| main.rs:348:5:348:39 | kind | Variable is assigned a value that is never used. | | ||
| main.rs:370:9:370:9 | x | Variable is assigned a value that is never used. | | ||
| main.rs:378:17:378:17 | x | Variable is assigned a value that is never used. | | ||
| main.rs:432:9:432:10 | i6 | Variable is assigned a value that is never used. | | ||
| more.rs:8:9:8:13 | times | Variable is assigned a value that is never used. | | ||
| more.rs:9:9:9:14 | unused | Variable is assigned a value that is never used. | | ||
| more.rs:21:9:21:14 | unused | Variable is assigned a value that is never used. | | ||
| more.rs:38:23:38:25 | val | Variable is assigned a value that is never used. | | ||
| more.rs:42:19:42:21 | val | Variable is assigned a value that is never used. | | ||
| more.rs:58:9:58:11 | val | Variable is assigned a value that is never used. | | ||
| more.rs:80:9:80:14 | a_ptr4 | Variable is assigned a value that is never used. | | ||
| more.rs:95:9:95:13 | d_ptr | Variable is assigned a value that is never used. | | ||
| more.rs:101:9:101:17 | f_ptr | Variable is assigned a value that is never used. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.