Skip to content

Commit

Permalink
Rust: Include variable name in Unused{Variable,Value}.ql
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Oct 29, 2024
1 parent dd520fe commit 40dcc0e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion rust/ql/src/queries/unusedentities/UnusedValue.ql
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ where
// avoid overlap with the unused variable query
not isUnused(v) and
not v instanceof DiscardVariable
select write, "Variable is assigned a value that is never used."
select write, "Variable '" + v + "' is assigned a value that is never used."
2 changes: 1 addition & 1 deletion rust/ql/src/queries/unusedentities/UnusedVariable.ql
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ import UnusedVariable

from Variable v
where isUnused(v)
select v, "Variable is not used."
select v, "Variable '" + v + "' is not used."
48 changes: 24 additions & 24 deletions rust/ql/test/query-tests/unusedentities/UnusedValue.expected
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
| 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:131:13:131:17 | total | Variable is assigned a value that is never used. |
| main.rs:194:13:194:31 | res | Variable is assigned a value that is never used. |
| main.rs:206:9:206:24 | kind | Variable is assigned a value that is never used. |
| main.rs:210:9:210:32 | kind | Variable is assigned a value that is never used. |
| main.rs:266:13:266:17 | total | Variable is assigned a value that is never used. |
| main.rs:334:5:334:39 | kind | Variable is assigned a value that is never used. |
| main.rs:359:9:359:9 | x | Variable is assigned a value that is never used. |
| main.rs:367:17:367:17 | x | Variable is assigned a value that is never used. |
| more.rs:24:9:24:11 | val | Variable is assigned a value that is never used. |
| more.rs:44:9:44:14 | a_ptr4 | Variable is assigned a value that is never used. |
| more.rs:59:9:59:13 | d_ptr | Variable is assigned a value that is never used. |
| more.rs:65:9:65:17 | f_ptr | Variable is assigned a value that is never used. |
| main.rs:6:9:6:9 | a | Variable 'a' is assigned a value that is never used. |
| main.rs:9:9:9:9 | d | Variable 'd' is assigned a value that is never used. |
| main.rs:35:5:35:5 | b | Variable 'b' is assigned a value that is never used. |
| main.rs:37:5:37:5 | c | Variable 'c' is assigned a value that is never used. |
| main.rs:40:5:40:5 | c | Variable 'c' is assigned a value that is never used. |
| main.rs:44:9:44:9 | d | Variable 'd' is assigned a value that is never used. |
| main.rs:50:5:50:5 | e | Variable 'e' is assigned a value that is never used. |
| main.rs:61:5:61:5 | f | Variable 'f' is assigned a value that is never used. |
| main.rs:63:5:63:5 | f | Variable 'f' is assigned a value that is never used. |
| main.rs:65:5:65:5 | g | Variable 'g' is assigned a value that is never used. |
| main.rs:87:9:87:9 | a | Variable 'a' is assigned a value that is never used. |
| main.rs:108:9:108:10 | is | Variable 'is' is assigned a value that is never used. |
| main.rs:131:13:131:17 | total | Variable 'total' is assigned a value that is never used. |
| main.rs:194:13:194:31 | res | Variable 'res' is assigned a value that is never used. |
| main.rs:206:9:206:24 | kind | Variable 'kind' is assigned a value that is never used. |
| main.rs:210:9:210:32 | kind | Variable 'kind' is assigned a value that is never used. |
| main.rs:266:13:266:17 | total | Variable 'total' is assigned a value that is never used. |
| main.rs:334:5:334:39 | kind | Variable 'kind' is assigned a value that is never used. |
| main.rs:359:9:359:9 | x | Variable 'x' is assigned a value that is never used. |
| main.rs:367:17:367:17 | x | Variable 'x' is assigned a value that is never used. |
| more.rs:24:9:24:11 | val | Variable 'val' is assigned a value that is never used. |
| more.rs:44:9:44:14 | a_ptr4 | Variable 'a_ptr4' is assigned a value that is never used. |
| more.rs:59:9:59:13 | d_ptr | Variable 'd_ptr' is assigned a value that is never used. |
| more.rs:65:9:65:17 | f_ptr | Variable 'f_ptr' is assigned a value that is never used. |
42 changes: 21 additions & 21 deletions rust/ql/test/query-tests/unusedentities/UnusedVariable.expected
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
| main.rs:25:9:25:9 | a | Variable is not used. |
| main.rs:90:13:90:13 | d | Variable is not used. |
| main.rs:139:5:139:5 | y | Variable is not used. |
| main.rs:166:9:166:9 | x | Variable is not used. |
| main.rs:236:17:236:17 | a | Variable is not used. |
| main.rs:244:20:244:22 | val | Variable is not used. |
| main.rs:258:14:258:16 | val | Variable is not used. |
| main.rs:273:22:273:24 | val | Variable is not used. |
| main.rs:280:24:280:26 | val | Variable is not used. |
| main.rs:288:13:288:15 | num | Variable is not used. |
| main.rs:303:12:303:12 | j | Variable is not used. |
| main.rs:323:25:323:25 | y | Variable is not used. |
| main.rs:326:28:326:28 | a | Variable is not used. |
| main.rs:329:9:329:9 | p | Variable is not used. |
| main.rs:347:9:347:13 | right | Variable is not used. |
| main.rs:353:9:353:14 | right2 | Variable is not used. |
| main.rs:360:13:360:13 | y | Variable is not used. |
| main.rs:368:21:368:21 | y | Variable is not used. |
| main.rs:413:26:413:28 | val | Variable is not used. |
| main.rs:416:21:416:23 | acc | Variable is not used. |
| main.rs:437:9:437:14 | unused | Variable is not used. |
| main.rs:25:9:25:9 | a | Variable 'a' is not used. |
| main.rs:90:13:90:13 | d | Variable 'd' is not used. |
| main.rs:139:5:139:5 | y | Variable 'y' is not used. |
| main.rs:166:9:166:9 | x | Variable 'x' is not used. |
| main.rs:236:17:236:17 | a | Variable 'a' is not used. |
| main.rs:244:20:244:22 | val | Variable 'val' is not used. |
| main.rs:258:14:258:16 | val | Variable 'val' is not used. |
| main.rs:273:22:273:24 | val | Variable 'val' is not used. |
| main.rs:280:24:280:26 | val | Variable 'val' is not used. |
| main.rs:288:13:288:15 | num | Variable 'num' is not used. |
| main.rs:303:12:303:12 | j | Variable 'j' is not used. |
| main.rs:323:25:323:25 | y | Variable 'y' is not used. |
| main.rs:326:28:326:28 | a | Variable 'a' is not used. |
| main.rs:329:9:329:9 | p | Variable 'p' is not used. |
| main.rs:347:9:347:13 | right | Variable 'right' is not used. |
| main.rs:353:9:353:14 | right2 | Variable 'right2' is not used. |
| main.rs:360:13:360:13 | y | Variable 'y' is not used. |
| main.rs:368:21:368:21 | y | Variable 'y' is not used. |
| main.rs:413:26:413:28 | val | Variable 'val' is not used. |
| main.rs:416:21:416:23 | acc | Variable 'acc' is not used. |
| main.rs:437:9:437:14 | unused | Variable 'unused' is not used. |

0 comments on commit 40dcc0e

Please sign in to comment.