Rollup merge of #45880 - arielb1:never-coerce, r=nikomatsakis
make coercions to `!` in unreachable code a hard error This was added to cover up a lazy extra semicolon in #35849, but does not actually make sense. This is removed as a part of the stabilization of `never_type`.
This commit is contained in:
commit
95f465d535
9 changed files with 64 additions and 13 deletions
|
|
@ -12,11 +12,14 @@
|
|||
#![allow(unused_assignments)]
|
||||
#![allow(dead_code)]
|
||||
#![deny(unreachable_code)]
|
||||
#![deny(coerce_never)]
|
||||
#![feature(never_type)]
|
||||
|
||||
fn foo() {
|
||||
let x: ! = ! { return; 22 }; //~ ERROR unreachable
|
||||
//~^ ERROR cannot apply unary operator `!` to type `!`
|
||||
//~^ ERROR cannot coerce
|
||||
//~| hard error
|
||||
//~| ERROR cannot apply unary operator `!` to type `!`
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: unreachable expression
|
||||
--> $DIR/expr_unary.rs:18:28
|
||||
--> $DIR/expr_unary.rs:19:28
|
||||
|
|
||||
18 | let x: ! = ! { return; 22 }; //~ ERROR unreachable
|
||||
19 | let x: ! = ! { return; 22 }; //~ ERROR unreachable
|
||||
| ^^
|
||||
|
|
||||
note: lint level defined here
|
||||
|
|
@ -10,11 +10,25 @@ note: lint level defined here
|
|||
14 | #![deny(unreachable_code)]
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0600]: cannot apply unary operator `!` to type `!`
|
||||
--> $DIR/expr_unary.rs:18:16
|
||||
error: cannot coerce `{integer}` to !
|
||||
--> $DIR/expr_unary.rs:19:28
|
||||
|
|
||||
18 | let x: ! = ! { return; 22 }; //~ ERROR unreachable
|
||||
19 | let x: ! = ! { return; 22 }; //~ ERROR unreachable
|
||||
| ^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/expr_unary.rs:15:9
|
||||
|
|
||||
15 | #![deny(coerce_never)]
|
||||
| ^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #46325 <https://github.com/rust-lang/rust/issues/46325>
|
||||
|
||||
error[E0600]: cannot apply unary operator `!` to type `!`
|
||||
--> $DIR/expr_unary.rs:19:16
|
||||
|
|
||||
19 | let x: ! = ! { return; 22 }; //~ ERROR unreachable
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue