-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #55262 - oli-obk:dangling_alloc_id_ice, r=RalfJung
Change the ICE from #55223 to a hard error cc @SimonSapin r? @RalfJung fixes #55287
- Loading branch information
Showing
5 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// https://github.com/rust-lang/rust/issues/55223 | ||
|
||
#![feature(const_let)] | ||
|
||
union Foo<'a> { | ||
y: &'a (), | ||
long_live_the_unit: &'static (), | ||
} | ||
|
||
const FOO: &() = { //~ ERROR any use of this value will cause an error | ||
let y = (); | ||
unsafe { Foo { y: &y }.long_live_the_unit } | ||
}; | ||
|
||
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,13 @@ | ||
error: any use of this value will cause an error | ||
--> $DIR/dangling-alloc-id-ice.rs:10:1 | ||
| | ||
LL | / const FOO: &() = { //~ ERROR any use of this value will cause an error | ||
LL | | let y = (); | ||
LL | | unsafe { Foo { y: &y }.long_live_the_unit } | ||
LL | | }; | ||
| |__^ type validation failed: encountered dangling pointer in final constant | ||
| | ||
= note: #[deny(const_err)] on by default | ||
|
||
error: aborting due to previous error | ||
|
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,10 @@ | ||
#![feature(const_let)] | ||
|
||
const FOO: *const u32 = { //~ ERROR any use of this value will cause an error | ||
let x = 42; | ||
&x | ||
}; | ||
|
||
fn main() { | ||
let x = FOO; | ||
} |
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 @@ | ||
error: any use of this value will cause an error | ||
--> $DIR/dangling_raw_ptr.rs:3:1 | ||
| | ||
LL | / const FOO: *const u32 = { //~ ERROR any use of this value will cause an error | ||
LL | | let x = 42; | ||
LL | | &x | ||
LL | | }; | ||
| |__^ type validation failed: encountered dangling pointer in final constant | ||
| | ||
= note: #[deny(const_err)] on by default | ||
|
||
error: aborting due to previous error | ||
|