forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not consider match/let/raw-ref of deref that evalautes to ! to div…
…erge
- Loading branch information
1 parent
6d8fbc9
commit cefd384
Showing
6 changed files
with
99 additions
and
2 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,13 @@ | ||
#![feature(never_type)] | ||
|
||
fn make_up_a_value<T>() -> T { | ||
unsafe { | ||
//~^ ERROR mismatched types | ||
let x: *const ! = 0 as _; | ||
let _: ! = *x; | ||
// Since `*x` "diverges" in HIR, but doesn't count as a read in MIR, this | ||
// is unsound since we act as if it diverges but it doesn't. | ||
} | ||
} | ||
|
||
fn main() {} |
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,20 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/diverging-place-match.rs:4:5 | ||
| | ||
LL | fn make_up_a_value<T>() -> T { | ||
| - expected this type parameter | ||
LL | / unsafe { | ||
LL | | | ||
LL | | let x: *const ! = 0 as _; | ||
LL | | let _: ! = *x; | ||
LL | | // Since `*x` "diverges" in HIR, but doesn't count as a read in MIR, this | ||
LL | | // is unsound since we act as if it diverges but it doesn't. | ||
LL | | } | ||
| |_____^ expected type parameter `T`, found `()` | ||
| | ||
= note: expected type parameter `T` | ||
found unit type `()` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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,13 @@ | ||
#![feature(never_type)] | ||
|
||
fn make_up_a_value<T>() -> T { | ||
unsafe { | ||
//~^ ERROR mismatched types | ||
let x: *const ! = 0 as _; | ||
&raw const *x; | ||
// Since `*x` is `!`, HIR typeck used to think that it diverges | ||
// and allowed the block to coerce to any value, leading to UB. | ||
} | ||
} | ||
|
||
fn main() {} |
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,20 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/never-place-isnt-diverging.rs:4:5 | ||
| | ||
LL | fn make_up_a_value<T>() -> T { | ||
| - expected this type parameter | ||
LL | / unsafe { | ||
LL | | | ||
LL | | let x: *const ! = 0 as _; | ||
LL | | &raw const *x; | ||
LL | | // Since `*x` is `!`, HIR typeck used to think that it diverges | ||
LL | | // and allowed the block to coerce to any value, leading to UB. | ||
LL | | } | ||
| |_____^ expected type parameter `T`, found `()` | ||
| | ||
= note: expected type parameter `T` | ||
found unit type `()` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |