Skip to content

Commit

Permalink
also compile-fail test fn ptr comparison promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 30, 2018
1 parent 1397836 commit 4cbfc93
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E0716]: temporary value dropped while borrowed
|
LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
...
LL | }
| - temporary value is freed at the end of this statement
|
Expand All @@ -25,11 +25,22 @@ error[E0716]: temporary value dropped while borrowed
|
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
LL | }
| - temporary value is freed at the end of this statement
|
= note: borrowed value must be valid for the static lifetime...

error[E0716]: temporary value dropped while borrowed
--> $DIR/promoted_raw_ptr_ops.rs:18:29
|
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
LL | }
| - temporary value is freed at the end of this statement
|
= note: borrowed value must be valid for the static lifetime...

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0716`.
1 change: 1 addition & 0 deletions src/test/ui/consts/const-eval/promoted_raw_ptr_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ fn main() {
//~^ ERROR does not live long enough
let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
}
15 changes: 13 additions & 2 deletions src/test/ui/consts/const-eval/promoted_raw_ptr_ops.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ error[E0597]: borrowed value does not live long enough
|
LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
...
LL | }
| - temporary value only lives until here
|
Expand All @@ -25,11 +25,22 @@ error[E0597]: borrowed value does not live long enough
|
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
LL | }
| - temporary value only lives until here
|
= note: borrowed value must be valid for the static lifetime...

error[E0597]: borrowed value does not live long enough
--> $DIR/promoted_raw_ptr_ops.rs:18:29
|
LL | let a: &'static bool = &(main as fn() == main as fn()); //~ ERROR does not live long enough
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
LL | }
| - temporary value only lives until here
|
= note: borrowed value must be valid for the static lifetime...

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

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

0 comments on commit 4cbfc93

Please sign in to comment.