mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 18:27:37 +00:00
refactor unreachable/expr_cast.rs
test
This commit is contained in:
parent
4b55fe199c
commit
a067c6a3c6
@ -1,13 +1,12 @@
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_assignments)]
|
||||
#![allow(dead_code)]
|
||||
//@ edition: 2024
|
||||
#![deny(unreachable_code)]
|
||||
#![feature(never_type, type_ascription)]
|
||||
|
||||
fn a() {
|
||||
// the cast is unreachable:
|
||||
let x = {return} as !; //~ ERROR unreachable
|
||||
//~| ERROR non-primitive cast
|
||||
_ = {return} as u32; //~ error: unreachable
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
fn b() {
|
||||
(return) as u32; //~ error: unreachable
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,24 +1,26 @@
|
||||
error: unreachable expression
|
||||
--> $DIR/expr_cast.rs:9:13
|
||||
--> $DIR/expr_cast.rs:5:9
|
||||
|
|
||||
LL | let x = {return} as !;
|
||||
| ^------^^^^^^
|
||||
| ||
|
||||
| |any code following this expression is unreachable
|
||||
| unreachable expression
|
||||
LL | _ = {return} as u32;
|
||||
| ^------^^^^^^^^
|
||||
| ||
|
||||
| |any code following this expression is unreachable
|
||||
| unreachable expression
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/expr_cast.rs:4:9
|
||||
--> $DIR/expr_cast.rs:2:9
|
||||
|
|
||||
LL | #![deny(unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0605]: non-primitive cast: `()` as `!`
|
||||
--> $DIR/expr_cast.rs:9:13
|
||||
error: unreachable expression
|
||||
--> $DIR/expr_cast.rs:9:5
|
||||
|
|
||||
LL | let x = {return} as !;
|
||||
| ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
||||
LL | (return) as u32;
|
||||
| --------^^^^^^^
|
||||
| |
|
||||
| unreachable expression
|
||||
| any code following this expression is unreachable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0605`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user