File tree Expand file tree Collapse file tree 4 files changed +70
-5
lines changed
rust/ql/test/query-tests/unusedentities Expand file tree Collapse file tree 4 files changed +70
-5
lines changed Original file line number Diff line number Diff line change 14
14
| main.rs:284:13:284:17 | total | Variable $@ is assigned a value that is never used. | main.rs:252:13:252:17 | total | total |
15
15
| main.rs:377:9:377:9 | x | Variable $@ is assigned a value that is never used. | main.rs:377:9:377:9 | x | x |
16
16
| 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: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 |
17
+ | main.rs:510:9:510:9 | d | Variable $@ is assigned a value that is never used. | main.rs:510:9:510:9 | d | d |
18
+ | main.rs:550:9:550:20 | var_in_macro | Variable $@ is assigned a value that is never used. | main.rs:550:9:550:20 | var_in_macro | var_in_macro |
19
+ | main.rs:559:9:559:9 | c | Variable $@ is assigned a value that is never used. | main.rs:559:9:559:9 | c | c |
19
20
| 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 |
20
21
| 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 |
21
22
| 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 |
Original file line number Diff line number Diff line change 19
19
| main.rs:431:26:431:28 | val | Variable 'val' is not used. |
20
20
| main.rs:434:21:434:23 | acc | Variable 'acc' is not used. |
21
21
| main.rs:455:9:455:14 | unused | Variable 'unused' is not used. |
22
+ | main.rs:521:12:521:12 | n | Variable 'n' is not used. |
22
23
| more.rs:24:9:24:11 | val | Variable 'val' is not used. |
Original file line number Diff line number Diff line change @@ -468,15 +468,72 @@ fn traits() {
468
468
469
469
// --- macros ---
470
470
471
- fn macros ( ) {
471
+ macro_rules! set_value {
472
+ ( $x: expr, $y: expr) => {
473
+ $x = $y
474
+ } ;
475
+ }
476
+
477
+ macro_rules! use_value {
478
+ ( $x: expr) => {
479
+ println!( "{}" , $x)
480
+ } ;
481
+ }
482
+
483
+ fn macros1 ( ) {
484
+ let a: u16 ;
485
+ let b: u16 = 2 ;
486
+ set_value ! ( a, 1 ) ;
487
+ use_value ! ( b) ;
488
+
489
+ match std:: env:: args ( ) . nth ( 1 ) . unwrap ( ) . parse :: < u16 > ( ) {
490
+ Ok ( n) => {
491
+ use_value ! ( n) ;
492
+ }
493
+ _ => { }
494
+ }
495
+ }
496
+
497
+ fn macros2 ( ) {
498
+ let a: u16 = 3 ;
499
+ println ! ( "{}" , a) ;
500
+
501
+ match std:: env:: args ( ) . nth ( 1 ) . unwrap ( ) . parse :: < u16 > ( ) {
502
+ Ok ( n) => {
503
+ println ! ( "{}" , n) ;
504
+ }
505
+ _ => { }
506
+ }
507
+ }
508
+
509
+ fn macros3 ( ) {
510
+ let d: u16 = 4 ; // $ SPURIOUS: Alert[rust/unused-value]
511
+
512
+ undefined_macro_call ! ( d) ;
513
+ }
514
+
515
+ fn macros4 ( ) {
516
+ undefined_macro_call ! ( 5 ) ;
517
+ }
518
+
519
+ fn macros5 ( ) {
520
+ match std:: env:: args ( ) . nth ( 1 ) . unwrap ( ) . parse :: < u16 > ( ) {
521
+ Ok ( n) => { // $ SPURIOUS: Alert[rust/unused-variable]
522
+ undefined_macro_call ! ( n) ;
523
+ }
524
+ _ => { }
525
+ }
526
+ }
527
+
528
+ fn macros6 ( ) {
472
529
let x;
473
530
println ! (
474
531
"The value of x is {}" ,
475
532
( {
476
533
x = 10 ; // $ MISSING: Alert[rust/unused-value]
477
534
10
478
535
} )
479
- )
536
+ ) ;
480
537
}
481
538
482
539
macro_rules! let_in_macro {
@@ -535,7 +592,12 @@ fn main() {
535
592
shadowing ( ) ;
536
593
func_ptrs ( ) ;
537
594
folds_and_closures ( ) ;
538
- macros ( ) ;
595
+ macros1 ( ) ;
596
+ macros2 ( ) ;
597
+ macros3 ( ) ;
598
+ macros4 ( ) ;
599
+ macros5 ( ) ;
600
+ macros6 ( ) ;
539
601
hygiene_mismatch ( ) ;
540
602
references ( ) ;
541
603
Original file line number Diff line number Diff line change
1
+ qltest_cargo_check : false
You can’t perform that action at this time.
0 commit comments