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
4
2
#![ deny( unreachable_code) ]
5
- #![ feature( never_type, type_ascription) ]
6
3
7
4
fn a ( ) {
8
- // the cast is unreachable:
9
- let x = { return } as !; //~ ERROR unreachable
10
- //~| ERROR non-primitive cast
5
+ _ = { return } as u32 ; //~ error: unreachable
11
6
}
12
7
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 1
1
error: unreachable expression
2
- --> $DIR/expr_cast.rs:9:13
2
+ --> $DIR/expr_cast.rs:5:9
3
3
|
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
9
9
|
10
10
note: the lint level is defined here
11
- --> $DIR/expr_cast.rs:4 :9
11
+ --> $DIR/expr_cast.rs:2 :9
12
12
|
13
13
LL | #![deny(unreachable_code)]
14
14
| ^^^^^^^^^^^^^^^^
15
15
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
18
18
|
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
21
24
22
25
error: aborting due to 2 previous errors
23
26
24
- For more information about this error, try `rustc --explain E0605`.
You can’t perform that action at this time.
0 commit comments