forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#55262 - oli-obk:dangling_alloc_id_ice, r=Ra…
…lfJung Change the ICE from rust-lang#55223 to a hard error cc @SimonSapin r? @RalfJung
- Loading branch information
Showing
6 changed files
with
84 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,30 @@ | ||
warning[E0716]: temporary value dropped while borrowed | ||
--> $DIR/dangling-alloc-id-ice-2.rs:5:28 | ||
| | ||
LL | static MAP: Slice = Slice(&[ | ||
| ___________________________-^ | ||
| |___________________________| | ||
| || | ||
LL | || b"CloseEvent" as &'static [u8], | ||
LL | || ]); | ||
| || -- temporary value is freed at the end of this statement | ||
| ||_| | ||
| |__creates a temporary which is freed while still in use | ||
| cast requires that borrow lasts for `'static` | ||
| | ||
= warning: This error has been downgraded to a warning for backwards compatibility with previous releases. | ||
It represents potential unsoundness in your code. | ||
This warning will become a hard error in the future. | ||
|
||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/dangling-alloc-id-ice-2.rs:5:1 | ||
| | ||
LL | / static MAP: Slice = Slice(&[ | ||
LL | | b"CloseEvent" as &'static [u8], | ||
LL | | ]); | ||
| |___^ type validation failed: encountered dangling pointer in final constant | ||
|
||
error: aborting due to previous error | ||
|
||
Some errors occurred: E0080, E0716. | ||
For more information about an error, try `rustc --explain E0080`. |
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 @@ | ||
// FIXME(#55223) this is just a reproduction test showing the wrong behavior | ||
|
||
struct Slice(&'static [&'static [u8]]); | ||
|
||
static MAP: Slice = Slice(&[ | ||
b"CloseEvent" as &'static [u8], | ||
]); | ||
|
||
|
||
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,11 @@ | ||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/dangling-alloc-id-ice-2.rs:5:1 | ||
| | ||
LL | / static MAP: Slice = Slice(&[ | ||
LL | | b"CloseEvent" as &'static [u8], | ||
LL | | ]); | ||
| |___^ type validation failed: encountered dangling pointer in final constant | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
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 this constant cannot be used | ||
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: this constant cannot be used | ||
--> $DIR/dangling-alloc-id-ice.rs:10:1 | ||
| | ||
LL | / const FOO: &() = { //~ ERROR this constant cannot be used | ||
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 | ||
|