File tree Expand file tree Collapse file tree 2 files changed +73
-9
lines changed Expand file tree Collapse file tree 2 files changed +73
-9
lines changed Original file line number Diff line number Diff line change 1+ fn main () {}
2+
3+ @must_use
4+ fn use_me (x : i32 ) -> i32 {
5+ return 10 + x ;
6+ }
7+
8+ fn constant_short_circuited_expression () -> bool {
9+ return false && 0 != use_me (0 );
10+ }
11+
12+ fn constant_skipped_block () -> i32 {
13+ if (false ) {
14+ return use_me (- 1 );
15+ }
16+ return - 1 ;
17+ }
18+
19+ fn assignment_only () -> i32 {
20+ let unused = use_me (- 1 );
21+ return - 1 ;
22+ }
23+
24+ fn assignment_and_constant_skipped_block () -> i32 {
25+ let unused = use_me (- 1 );
26+ if (false ) {
27+ return unused ;
28+ }
29+ return - 1 ;
30+ }
31+
32+ fn assignment_and_maybe_skipped_block (skip : bool ) -> i32 {
33+ let unused = use_me (- 1 );
34+ if (skip ) {
35+ return unused ;
36+ }
37+ return - 1 ;
38+ }
39+
40+ fn assign_and_use_before_constant_return () -> i32 {
41+ let called_a = use_me_10 ();
42+ let used_a = 1 + called_a ;
43+ return 2 ;
44+ }
Original file line number Diff line number Diff line change 1- @compute @workgroup_size (1 )
21fn main () {}
32
43@must_use
5- fn use_me (x : i32 ) -> i32 {
6- return 10 + x ;
4+ fn use_me_10 () -> i32 { return 10 ; }
5+
6+ @must_use
7+ fn use_me_false () -> bool { return false ; }
8+
9+ fn use_return () -> i32 {
10+ return use_me_10 ();
11+ }
12+
13+ fn use_expression () -> bool {
14+ return use_me_10 () == 10 ;
15+ }
16+
17+
18+ fn assign_and_return () -> i32 {
19+ let called_a = use_me_10 ();
20+ return called_a ;
21+ }
22+
23+ fn assign_and_use_before_return () -> i32 {
24+ let called_a = use_me_10 ();
25+ let used_a = 1 + called_a ;
26+ return used_a ;
727}
828
9- fn useful (
10- m : i32 ,
11- ) -> i32 {
12- var q = use_me ( m );
13- q += m ;
14- return q ;
29+ fn use_in_condition_expression () -> i32 {
30+ if ( use_me_false ()) {
31+ return 1 ;
32+ } else {
33+ return 2 ;
34+ }
1535}
You can’t perform that action at this time.
0 commit comments