Add reproduction tests

This commit is contained in:
Oli Scherer 2022-11-30 12:29:01 +00:00
parent 8de4b13845
commit bb6755859c
4 changed files with 69 additions and 0 deletions

View 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() {}

View 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() {}

View 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() {}

View 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`.