diff options
Diffstat (limited to 'tests/ui/consts/promoted_const_call2.rs')
-rw-r--r-- | tests/ui/consts/promoted_const_call2.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/consts/promoted_const_call2.rs b/tests/ui/consts/promoted_const_call2.rs new file mode 100644 index 000000000..f332cd18c --- /dev/null +++ b/tests/ui/consts/promoted_const_call2.rs @@ -0,0 +1,14 @@ +#![feature(const_precise_live_drops)] +pub const fn id<T>(x: T) -> T { x } +pub const C: () = { + let _: &'static _ = &id(&String::new()); + //~^ ERROR: temporary value dropped while borrowed + //~| ERROR: temporary value dropped while borrowed + //~| ERROR: destructor of `String` cannot be evaluated at compile-time +}; + +fn main() { + let _: &'static _ = &id(&String::new()); + //~^ ERROR: temporary value dropped while borrowed + //~| ERROR: temporary value dropped while borrowed +} |