Add reproduction tests
This commit is contained in:
parent
8de4b13845
commit
bb6755859c
4 changed files with 69 additions and 0 deletions
13
src/test/ui/consts/promoted_const_call.rs
Normal file
13
src/test/ui/consts/promoted_const_call.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// check-pass
|
||||
// known-bug: #91009
|
||||
|
||||
#![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);
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
10
src/test/ui/consts/promoted_const_call2.rs
Normal file
10
src/test/ui/consts/promoted_const_call2.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// check-pass
|
||||
// known-bug: #91009
|
||||
|
||||
#![feature(const_precise_live_drops)]
|
||||
pub const fn id<T>(x: T) -> T { x }
|
||||
pub const C: () = {
|
||||
let _: &'static _ = &id(&String::new());
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
14
src/test/ui/consts/promoted_const_call3.rs
Normal file
14
src/test/ui/consts/promoted_const_call3.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
pub const fn id<T>(x: T) -> T { x }
|
||||
pub const C: () = {
|
||||
let _: &'static _ = &String::new();
|
||||
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
|
||||
//~| ERROR: temporary value dropped while borrowed
|
||||
|
||||
let _: &'static _ = &id(&String::new());
|
||||
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
|
||||
|
||||
let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
|
||||
// Promoted. bug!
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
32
src/test/ui/consts/promoted_const_call3.stderr
Normal file
32
src/test/ui/consts/promoted_const_call3.stderr
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
error[E0493]: destructor of `String` cannot be evaluated at compile-time
|
||||
--> $DIR/promoted_const_call3.rs:7:30
|
||||
|
|
||||
LL | let _: &'static _ = &id(&String::new());
|
||||
| ^^^^^^^^^^^^^ - value is dropped here
|
||||
| |
|
||||
| the destructor for this type cannot be evaluated in constants
|
||||
|
||||
error[E0493]: destructor of `String` cannot be evaluated at compile-time
|
||||
--> $DIR/promoted_const_call3.rs:3:26
|
||||
|
|
||||
LL | let _: &'static _ = &String::new();
|
||||
| ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
|
||||
...
|
||||
LL | };
|
||||
| - value is dropped here
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_call3.rs:3:26
|
||||
|
|
||||
LL | let _: &'static _ = &String::new();
|
||||
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
|
||||
| |
|
||||
| type annotation requires that borrow lasts for `'static`
|
||||
...
|
||||
LL | };
|
||||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0493, E0716.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue