Skip to content

Commit 5c45fef

Browse files
committed
Update and add new test (fixes rust-lang#55353)
1 parent 9d18968 commit 5c45fef

4 files changed

+26
-3
lines changed

src/test/ui/consts/dangling-alloc-id-ice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ union Foo<'a> {
77
long_live_the_unit: &'static (),
88
}
99

10-
const FOO: &() = { //~ ERROR this constant cannot be used
10+
const FOO: &() = { //~ ERROR any use of this value will cause an error
1111
let y = ();
1212
unsafe { Foo { y: &y }.long_live_the_unit }
1313
};

src/test/ui/consts/dangling-alloc-id-ice.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
error: this constant cannot be used
1+
error: any use of this value will cause an error
22
--> $DIR/dangling-alloc-id-ice.rs:10:1
33
|
4-
LL | / const FOO: &() = { //~ ERROR this constant cannot be used
4+
LL | / const FOO: &() = { //~ ERROR any use of this value will cause an error
55
LL | | let y = ();
66
LL | | unsafe { Foo { y: &y }.long_live_the_unit }
77
LL | | };
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(const_let)]
2+
3+
const FOO: *const u32 = { //~ ERROR any use of this value will cause an error
4+
let x = 42;
5+
&x
6+
};
7+
8+
fn main() {
9+
let x = FOO;
10+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: any use of this value will cause an error
2+
--> $DIR/dangling_raw_ptr.rs:3:1
3+
|
4+
LL | / const FOO: *const u32 = { //~ ERROR any use of this value will cause an error
5+
LL | | let x = 42;
6+
LL | | &x
7+
LL | | };
8+
| |__^ type validation failed: encountered dangling pointer in final constant
9+
|
10+
= note: #[deny(const_err)] on by default
11+
12+
error: aborting due to previous error
13+

0 commit comments

Comments
 (0)