Skip to content

Commit bb67558

Browse files
committed
Add reproduction tests
1 parent 8de4b13 commit bb67558

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
// known-bug: #91009
3+
4+
#![feature(const_mut_refs)]
5+
#![feature(const_trait_impl)]
6+
struct Panic;
7+
impl const Drop for Panic { fn drop(&mut self) { panic!(); } }
8+
pub const fn id<T>(x: T) -> T { x }
9+
pub const C: () = {
10+
let _: &'static _ = &id(&Panic);
11+
};
12+
13+
fn main() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
// known-bug: #91009
3+
4+
#![feature(const_precise_live_drops)]
5+
pub const fn id<T>(x: T) -> T { x }
6+
pub const C: () = {
7+
let _: &'static _ = &id(&String::new());
8+
};
9+
10+
fn main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub const fn id<T>(x: T) -> T { x }
2+
pub const C: () = {
3+
let _: &'static _ = &String::new();
4+
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
5+
//~| ERROR: temporary value dropped while borrowed
6+
7+
let _: &'static _ = &id(&String::new());
8+
//~^ ERROR: destructor of `String` cannot be evaluated at compile-time
9+
10+
let _: &'static _ = &std::mem::ManuallyDrop::new(String::new());
11+
// Promoted. bug!
12+
};
13+
14+
fn main() {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
error[E0493]: destructor of `String` cannot be evaluated at compile-time
2+
--> $DIR/promoted_const_call3.rs:7:30
3+
|
4+
LL | let _: &'static _ = &id(&String::new());
5+
| ^^^^^^^^^^^^^ - value is dropped here
6+
| |
7+
| the destructor for this type cannot be evaluated in constants
8+
9+
error[E0493]: destructor of `String` cannot be evaluated at compile-time
10+
--> $DIR/promoted_const_call3.rs:3:26
11+
|
12+
LL | let _: &'static _ = &String::new();
13+
| ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
14+
...
15+
LL | };
16+
| - value is dropped here
17+
18+
error[E0716]: temporary value dropped while borrowed
19+
--> $DIR/promoted_const_call3.rs:3:26
20+
|
21+
LL | let _: &'static _ = &String::new();
22+
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
23+
| |
24+
| type annotation requires that borrow lasts for `'static`
25+
...
26+
LL | };
27+
| - temporary value is freed at the end of this statement
28+
29+
error: aborting due to 3 previous errors
30+
31+
Some errors have detailed explanations: E0493, E0716.
32+
For more information about an error, try `rustc --explain E0493`.

0 commit comments

Comments
 (0)