update dangling-alloc-id-ice test

This commit is contained in:
Vishnunarayan K I 2020-11-05 13:24:21 +05:30
parent bd7229daf0
commit a15ee4d7c8
2 changed files with 2 additions and 15 deletions

View File

@ -6,7 +6,7 @@ union Foo<'a> {
long_live_the_unit: &'static (),
}
const FOO: &() = { //~ ERROR it is undefined behavior to use this value
const FOO: &() = {
//~^ ERROR encountered dangling pointer in final constant
let y = ();
unsafe { Foo { y: &y }.long_live_the_unit }

View File

@ -8,18 +8,5 @@ LL | | unsafe { Foo { y: &y }.long_live_the_unit }
LL | | };
| |__^
error[E0080]: it is undefined behavior to use this value
--> $DIR/dangling-alloc-id-ice.rs:9:1
|
LL | / const FOO: &() = {
LL | |
LL | | let y = ();
LL | | unsafe { Foo { y: &y }.long_live_the_unit }
LL | | };
| |__^ type validation failed: encountered a dangling reference (use-after-free)
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
error: aborting due to previous error
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`.