Skip to content

Commit abe14ba

Browse files
committed
Rust: Clean up the existing macro cases for the unusedentities test.
1 parent 82b7a19 commit abe14ba

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

rust/ql/test/query-tests/unusedentities/UnusedValue.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
| main.rs:284:13:284:17 | total | Variable $@ is assigned a value that is never used. | main.rs:252:13:252:17 | total | total |
1515
| main.rs:377:9:377:9 | x | Variable $@ is assigned a value that is never used. | main.rs:377:9:377:9 | x | x |
1616
| main.rs:385:17:385:17 | x | Variable $@ is assigned a value that is never used. | main.rs:385:17:385:17 | x | x |
17-
| main.rs:486:9:486:9 | c | Variable $@ is assigned a value that is never used. | main.rs:486:9:486:9 | c | c |
18-
| main.rs:519:9:519:20 | var_in_macro | Variable $@ is assigned a value that is never used. | main.rs:519:9:519:20 | var_in_macro | var_in_macro |
17+
| main.rs:493:9:493:20 | var_in_macro | Variable $@ is assigned a value that is never used. | main.rs:493:9:493:20 | var_in_macro | var_in_macro |
18+
| main.rs:502:9:502:9 | c | Variable $@ is assigned a value that is never used. | main.rs:502:9:502:9 | c | c |
1919
| 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 |
2020
| 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 |
2121
| more.rs:65:13:65:17 | f_ptr | Variable $@ is assigned a value that is never used. | more.rs:65:13:65:17 | f_ptr | f_ptr |

rust/ql/test/query-tests/unusedentities/main.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,22 @@ fn macros() {
478478
})
479479
)
480480
}
481+
482+
macro_rules! let_in_macro {
483+
($e:expr) => {{
484+
let var_in_macro = 0;
485+
$e
486+
}};
487+
}
488+
489+
// Our analysis does not currently respect the hygiene rules of Rust macros
490+
// (https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene.html), because
491+
// all we have access to is the expanded AST
492+
fn hygiene_mismatch() {
493+
let var_in_macro = 0; // $ SPURIOUS: Alert[rust/unused-value]
494+
let_in_macro!(var_in_macro);
495+
}
496+
481497
// --- references ---
482498

483499
fn references() {
@@ -505,21 +521,6 @@ trait MyTrait {
505521
fn my_func2(&self, x: i32) -> i32;
506522
}
507523

508-
macro_rules! let_in_macro {
509-
($e:expr) => {{
510-
let var_in_macro = 0;
511-
$e
512-
}};
513-
}
514-
515-
// Our analysis does not currently respect the hygiene rules of Rust macros
516-
// (https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene.html), because
517-
// all we have access to is the expanded AST
518-
fn hygiene_mismatch() {
519-
let var_in_macro = 0; // $ SPURIOUS: Alert[rust/unused-value]
520-
let_in_macro!(var_in_macro);
521-
}
522-
523524
// --- main ---
524525

525526
fn main() {
@@ -535,6 +536,7 @@ fn main() {
535536
func_ptrs();
536537
folds_and_closures();
537538
macros();
539+
hygiene_mismatch();
538540
references();
539541

540542
generics();

0 commit comments

Comments
 (0)