-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust: Exclude results inside macro expansions from unused entity queries #17865
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fec31a6
Rust: Include variable name in `Unused{Variable,Value}.ql`
hvitved 2b340b1
Rust: Exclude results inside macro expansions from unused entity queries
hvitved 55a6ed7
Rust: Include link to variable in unused value query
hvitved d0f9a0b
Rust: Add another unused-value test
hvitved c4adec3
Address review comment
hvitved File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
28 changes: 14 additions & 14 deletions
28
rust/ql/test/query-tests/unusedentities/UnreachableCode.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,16 +1,16 @@ | ||
| unreachable.rs:11:9:11:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:19:9:19:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:31:9:31:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:38:9:38:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:59:5:59:19 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:106:13:106:20 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:115:13:115:20 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:141:5:141:19 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:148:9:148:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:157:13:157:27 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:163:9:163:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:169:13:169:27 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:27:9:27:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:39:9:39:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:46:9:46:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:67:5:67:19 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:114:13:114:20 | MacroExpr | This code is never reached. | | ||
| unreachable.rs:123:13:123:20 | MacroExpr | This code is never reached. | | ||
| unreachable.rs:149:5:149:19 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:156:9:156:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:165:13:165:27 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:171:9:171:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:177:13:177:27 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:180:5:180:19 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:204:9:204:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:220:9:220:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:185:13:185:27 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:188:5:188:19 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:212:9:212:23 | ExprStmt | This code is never reached. | | ||
| unreachable.rs:228:9:228:23 | ExprStmt | This code is never reached. | |
44 changes: 20 additions & 24 deletions
44
rust/ql/test/query-tests/unusedentities/UnusedValue.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,24 +1,20 @@ | ||
| 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:8:9:8:9 | a | Variable $@ is assigned a value that is never used. | main.rs:8:9:8:9 | a | a | | ||
| main.rs:11:9:11:9 | d | Variable $@ is assigned a value that is never used. | main.rs:11:9:11:9 | d | d | | ||
| main.rs:37:5:37:5 | b | Variable $@ is assigned a value that is never used. | main.rs:28:9:28:9 | b | b | | ||
| main.rs:39:5:39:5 | c | Variable $@ is assigned a value that is never used. | main.rs:29:13:29:13 | c | c | | ||
| main.rs:42:5:42:5 | c | Variable $@ is assigned a value that is never used. | main.rs:29:13:29:13 | c | c | | ||
| main.rs:46:9:46:9 | d | Variable $@ is assigned a value that is never used. | main.rs:30:13:30:13 | d | d | | ||
| main.rs:52:5:52:5 | e | Variable $@ is assigned a value that is never used. | main.rs:31:13:31:13 | e | e | | ||
| main.rs:63:5:63:5 | f | Variable $@ is assigned a value that is never used. | main.rs:32:13:32:13 | f | f | | ||
| main.rs:65:5:65:5 | f | Variable $@ is assigned a value that is never used. | main.rs:32:13:32:13 | f | f | | ||
| main.rs:67:5:67:5 | g | Variable $@ is assigned a value that is never used. | main.rs:33:9:33:9 | g | g | | ||
| main.rs:89:9:89:9 | a | Variable $@ is assigned a value that is never used. | main.rs:89:9:89:9 | a | a | | ||
| main.rs:110:9:110:10 | is | Variable $@ is assigned a value that is never used. | main.rs:110:9:110:10 | is | is | | ||
| main.rs:133:13:133:17 | total | Variable $@ is assigned a value that is never used. | main.rs:133:13:133:17 | total | total | | ||
| 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 | |
42 changes: 21 additions & 21 deletions
42
rust/ql/test/query-tests/unusedentities/UnusedVariable.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,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:27:9:27:9 | a | Variable 'a' is not used. | | ||
| main.rs:92:13:92:13 | d | Variable 'd' is not used. | | ||
| main.rs:141:5:141:5 | y | Variable 'y' is not used. | | ||
| main.rs:168:9:168:9 | x | Variable 'x' is not used. | | ||
| main.rs:240:17:240:17 | a | Variable 'a' is not used. | | ||
| main.rs:248:20:248:22 | val | Variable 'val' is not used. | | ||
| main.rs:262:14:262:16 | val | Variable 'val' is not used. | | ||
| main.rs:277:22:277:24 | val | Variable 'val' is not used. | | ||
| main.rs:284:24:284:26 | val | Variable 'val' is not used. | | ||
| main.rs:292:13:292:15 | num | Variable 'num' is not used. | | ||
| main.rs:307:12:307:12 | j | Variable 'j' is not used. | | ||
| main.rs:327:25:327:25 | y | Variable 'y' is not used. | | ||
| main.rs:330:28:330:28 | a | Variable 'a' is not used. | | ||
| main.rs:333:9:333:9 | p | Variable 'p' is not used. | | ||
| main.rs:351:9:351:13 | right | Variable 'right' is not used. | | ||
| main.rs:357:9:357:14 | right2 | Variable 'right2' is not used. | | ||
| main.rs:364:13:364:13 | y | Variable 'y' is not used. | | ||
| main.rs:372:21:372:21 | y | Variable 'y' is not used. | | ||
| 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. | |
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 was deleted.
Oops, something went wrong.
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer
getParent
. I think all immediate parents are actually AstNodes, and if not, we should probably change the schema.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't be named
getParent
because it will then conflict with the auto-generatedComment.getParent
predicate :-(