mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
27 lines
531 B
Rust
27 lines
531 B
Rust
// 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() {}
|