]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/promoted_const_call.rs
Auto merge of #106121 - RalfJung:miri, r=RalfJung
[rust.git] / src / test / ui / consts / promoted_const_call.rs
1 #![feature(const_mut_refs)]
2 #![feature(const_trait_impl)]
3 struct Panic;
4 impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
5 pub const fn id<T>(x: T) -> T { x }
6 pub const C: () = {
7     let _: &'static _ = &id(&Panic);
8     //~^ ERROR: temporary value dropped while borrowed
9     //~| ERROR: temporary value dropped while borrowed
10 };
11
12 fn main() {
13     let _: &'static _ = &id(&Panic);
14     //~^ ERROR: temporary value dropped while borrowed
15     //~| ERROR: temporary value dropped while borrowed
16     let _: &'static _ = &&(Panic, 0).1;
17     //~^ ERROR: temporary value dropped while borrowed
18     //~| ERROR: temporary value dropped while borrowed
19 }