Skip to content

Commit 4cbfc93

Browse files
committed
also compile-fail test fn ptr comparison promotion
1 parent 1397836 commit 4cbfc93

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr

+13-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0716]: temporary value dropped while borrowed
1414
|
1515
LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
17-
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
17+
...
1818
LL | }
1919
| - temporary value is freed at the end of this statement
2020
|
@@ -25,11 +25,22 @@ error[E0716]: temporary value dropped while borrowed
2525
|
2626
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
2727
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
28+
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
29+
LL | }
30+
| - temporary value is freed at the end of this statement
31+
|
32+
= note: borrowed value must be valid for the static lifetime...
33+
34+
error[E0716]: temporary value dropped while borrowed
35+
--> $DIR/promoted_raw_ptr_ops.rs:18:29
36+
|
37+
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
2839
LL | }
2940
| - temporary value is freed at the end of this statement
3041
|
3142
= note: borrowed value must be valid for the static lifetime...
3243

33-
error: aborting due to 3 previous errors
44+
error: aborting due to 4 previous errors
3445

3546
For more information about this error, try `rustc --explain E0716`.

src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ fn main() {
1515
//~^ ERROR does not live long enough
1616
let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
1717
let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
18+
let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
1819
}

src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr

+13-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ error[E0597]: borrowed value does not live long enough
1414
|
1515
LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
17-
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
17+
...
1818
LL | }
1919
| - temporary value only lives until here
2020
|
@@ -25,11 +25,22 @@ error[E0597]: borrowed value does not live long enough
2525
|
2626
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
2727
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
28+
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
29+
LL | }
30+
| - temporary value only lives until here
31+
|
32+
= note: borrowed value must be valid for the static lifetime...
33+
34+
error[E0597]: borrowed value does not live long enough
35+
--> $DIR/promoted_raw_ptr_ops.rs:18:29
36+
|
37+
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
38+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
2839
LL | }
2940
| - temporary value only lives until here
3041
|
3142
= note: borrowed value must be valid for the static lifetime...
3243

33-
error: aborting due to 3 previous errors
44+
error: aborting due to 4 previous errors
3445

3546
For more information about this error, try `rustc --explain E0597`.

0 commit comments

Comments
 (0)