File tree 3 files changed +27
-4
lines changed
src/test/ui/consts/const-eval
3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ error[E0716]: temporary value dropped while borrowed
14
14
|
15
15
LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
16
16
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
+ ...
18
18
LL | }
19
19
| - temporary value is freed at the end of this statement
20
20
|
@@ -25,11 +25,22 @@ error[E0716]: temporary value dropped while borrowed
25
25
|
26
26
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
27
27
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
28
39
LL | }
29
40
| - temporary value is freed at the end of this statement
30
41
|
31
42
= note: borrowed value must be valid for the static lifetime...
32
43
33
- error: aborting due to 3 previous errors
44
+ error: aborting due to 4 previous errors
34
45
35
46
For more information about this error, try `rustc --explain E0716`.
Original file line number Diff line number Diff line change @@ -15,4 +15,5 @@ fn main() {
15
15
//~^ ERROR does not live long enough
16
16
let y: & ' static usize = & ( & 1 as * const i32 as usize + 1 ) ; //~ ERROR does not live long enough
17
17
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
18
19
}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ error[E0597]: borrowed value does not live long enough
14
14
|
15
15
LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
16
16
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
+ ...
18
18
LL | }
19
19
| - temporary value only lives until here
20
20
|
@@ -25,11 +25,22 @@ error[E0597]: borrowed value does not live long enough
25
25
|
26
26
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
27
27
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
28
39
LL | }
29
40
| - temporary value only lives until here
30
41
|
31
42
= note: borrowed value must be valid for the static lifetime...
32
43
33
- error: aborting due to 3 previous errors
44
+ error: aborting due to 4 previous errors
34
45
35
46
For more information about this error, try `rustc --explain E0597`.
You can’t perform that action at this time.
0 commit comments