rust/tests/ui/consts/promoted_const_call.rs

20 lines
653 B
Rust
Raw Normal View History

2022-11-30 06:29:01 -06:00
#![feature(const_mut_refs)]
#![feature(const_trait_impl)]
struct Panic;
impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
pub const fn id<T>(x: T) -> T { x }
pub const C: () = {
let _: &'static _ = &id(&Panic);
2022-11-30 08:35:23 -06:00
//~^ ERROR: temporary value dropped while borrowed
//~| ERROR: temporary value dropped while borrowed
2022-11-30 06:29:01 -06:00
};
fn main() {
let _: &'static _ = &id(&Panic);
//~^ ERROR: temporary value dropped while borrowed
//~| ERROR: temporary value dropped while borrowed
2022-12-01 07:41:59 -06:00
let _: &'static _ = &&(Panic, 0).1;
//~^ ERROR: temporary value dropped while borrowed
//~| ERROR: temporary value dropped while borrowed
}