blob: 1b25294c7e16186d1bd506d972316818ef23c676 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// This tests verifies that unary structs and enum variants
// are treated as rvalues and their lifetime is not bounded to
// the static scope.
fn id<T>(x: T) -> T { x }
struct Test;
enum MyEnum {
Variant1
}
fn structLifetime<'a>() -> &'a Test {
let testValue = &id(Test);
testValue
//~^ ERROR cannot return value referencing temporary value
}
fn variantLifetime<'a>() -> &'a MyEnum {
let testValue = &id(MyEnum::Variant1);
testValue
//~^ ERROR cannot return value referencing temporary value
}
fn main() {}
|