rust/tests/ui/transmutability/references/reject_lifetime_extension.s...

79 lines
3.3 KiB
Plaintext

error: lifetime may not live long enough
--> $DIR/reject_lifetime_extension.rs:20:18
|
LL | fn extend_bare<'a>(src: &'a u8) -> &'static u8 {
| -- lifetime `'a` defined here
LL | unsafe { transmute(src) }
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/reject_lifetime_extension.rs:28:18
|
LL | fn extend_nested<'a>(src: &'a &'a u8) -> &'a &'static u8 {
| -- lifetime `'a` defined here
LL | unsafe { transmute(src) }
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/reject_lifetime_extension.rs:36:18
|
LL | fn extend_unit<'a>(src: (&'a u8,)) -> (&'static u8,) {
| -- lifetime `'a` defined here
LL | unsafe { transmute(src) }
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/reject_lifetime_extension.rs:40:18
|
LL | fn extend_pair<'a>(src: (&'a u8, u8)) -> (&'static u8, u8) {
| -- lifetime `'a` defined here
LL | unsafe { transmute(src) }
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/reject_lifetime_extension.rs:50:18
|
LL | fn extend_struct<'a>(src: Struct<'a>) -> Struct<'static> {
| -- lifetime `'a` defined here
LL | unsafe { transmute(src) }
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/reject_lifetime_extension.rs:62:18
|
LL | fn extend_single<'a>(src: Single<'a>) -> Single<'static> {
| -- lifetime `'a` defined here
LL | unsafe { transmute(src) }
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error: lifetime may not live long enough
--> $DIR/reject_lifetime_extension.rs:72:18
|
LL | fn extend_multi<'a>(src: Multi<'a>) -> Multi<'static> {
| -- lifetime `'a` defined here
LL | unsafe { transmute(src) }
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
error[E0521]: borrowed data escapes outside of function
--> $DIR/reject_lifetime_extension.rs:80:18
|
LL | fn call_extend_hrtb<'a>(src: &'a u8) -> &'static u8 {
| -- --- `src` is a reference that is only valid in the function body
| |
| lifetime `'a` defined here
LL | unsafe { extend_hrtb(src) }
| ^^^^^^^^^^^^^^^^
| |
| `src` escapes the function body here
| argument requires that `'a` must outlive `'static`
|
note: due to current limitations in the borrow checker, this implies a `'static` lifetime
--> $DIR/reject_lifetime_extension.rs:85:25
|
LL | for<'b> &'b u8: TransmuteFrom<&'a u8>,
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0521`.