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 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: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 |
1920| 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 |
2021| 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 |
2122| 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 1919| main.rs:431:26:431:28 | val | Variable 'val' is not used. |
2020| main.rs:434:21:434:23 | acc | Variable 'acc' is not used. |
2121| 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. |
2223| 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() {
468468
469469// --- macros ---
470470
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 ( ) {
472529 let x;
473530 println ! (
474531 "The value of x is {}" ,
475532 ( {
476533 x = 10 ; // $ MISSING: Alert[rust/unused-value]
477534 10
478535 } )
479- )
536+ ) ;
480537}
481538
482539macro_rules! let_in_macro {
@@ -535,7 +592,12 @@ fn main() {
535592 shadowing ( ) ;
536593 func_ptrs ( ) ;
537594 folds_and_closures ( ) ;
538- macros ( ) ;
595+ macros1 ( ) ;
596+ macros2 ( ) ;
597+ macros3 ( ) ;
598+ macros4 ( ) ;
599+ macros5 ( ) ;
600+ macros6 ( ) ;
539601 hygiene_mismatch ( ) ;
540602 references ( ) ;
541603
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