File tree Expand file tree Collapse file tree 2 files changed +21
-20
lines changed Expand file tree Collapse file tree 2 files changed +21
-20
lines changed Original file line number Diff line number Diff line change 1- #![ allow( unused_variables) ]
2- #![ allow( unused_assignments) ]
3- #![ allow( dead_code) ]
1+ //@ edition: 2024
42#![ deny( unreachable_code) ]
5- #![ feature( never_type, type_ascription) ]
63
74fn a ( ) {
8- // the cast is unreachable:
9- let x = { return } as !; //~ ERROR unreachable
10- //~| ERROR non-primitive cast
5+ _ = { return } as u32 ; //~ error: unreachable
116}
127
13- fn main ( ) { }
8+ fn b ( ) {
9+ ( return ) as u32 ; //~ error: unreachable
10+ }
11+
12+ fn main ( ) { }
Original file line number Diff line number Diff line change 11error: unreachable expression
2- --> $DIR/expr_cast.rs:9:13
2+ --> $DIR/expr_cast.rs:5:9
33 |
4- LL | let x = {return} as ! ;
5- | ^------^^^^^^
6- | ||
7- | |any code following this expression is unreachable
8- | unreachable expression
4+ LL | _ = {return} as u32 ;
5+ | ^------^^ ^^^^^^
6+ | ||
7+ | |any code following this expression is unreachable
8+ | unreachable expression
99 |
1010note: the lint level is defined here
11- --> $DIR/expr_cast.rs:4 :9
11+ --> $DIR/expr_cast.rs:2 :9
1212 |
1313LL | #![deny(unreachable_code)]
1414 | ^^^^^^^^^^^^^^^^
1515
16- error[E0605]: non-primitive cast: `()` as `!`
17- --> $DIR/expr_cast.rs:9:13
16+ error: unreachable expression
17+ --> $DIR/expr_cast.rs:9:5
1818 |
19- LL | let x = {return} as !;
20- | ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
19+ LL | (return) as u32;
20+ | --------^^^^^^^
21+ | |
22+ | unreachable expression
23+ | any code following this expression is unreachable
2124
2225error: aborting due to 2 previous errors
2326
24- For more information about this error, try `rustc --explain E0605`.
You can’t perform that action at this time.
0 commit comments