forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#61814 - varkor:uninhabited-const-61744, r=o…
…li-obk Fix an ICE with uninhabited consts Fixes rust-lang#61744. r? @oli-obk
- Loading branch information
Showing
4 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// compile-fail | ||
|
||
pub const unsafe fn fake_type<T>() -> T { | ||
hint_unreachable() | ||
} | ||
|
||
pub const unsafe fn hint_unreachable() -> ! { | ||
fake_type() //~ ERROR any use of this value will cause an error | ||
} | ||
|
||
trait Const { | ||
const CONSTANT: i32 = unsafe { fake_type() }; | ||
} | ||
|
||
impl <T> Const for T {} | ||
|
||
pub fn main() -> () { | ||
dbg!(i32::CONSTANT); //~ ERROR erroneous constant used | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error: any use of this value will cause an error | ||
--> $DIR/uninhabited-const-issue-61744.rs:8:5 | ||
| | ||
LL | fake_type() | ||
| ^^^^^^^^^^^ | ||
| | | ||
| tried to call a function with return type T passing return place of type ! | ||
| inside call to `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:4:5 | ||
| inside call to `fake_type::<i32>` at $DIR/uninhabited-const-issue-61744.rs:12:36 | ||
... | ||
LL | const CONSTANT: i32 = unsafe { fake_type() }; | ||
| --------------------------------------------- | ||
| | ||
= note: #[deny(const_err)] on by default | ||
|
||
error[E0080]: erroneous constant used | ||
--> $DIR/uninhabited-const-issue-61744.rs:18:10 | ||
| | ||
LL | dbg!(i32::CONSTANT); | ||
| ^^^^^^^^^^^^^ referenced constant has errors | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |