Skip to content

Commit 923ca85

Browse files
committed
Add test
1 parent 1b8ab72 commit 923ca85

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@[new] compile-flags: -Znext-solver
2+
//@ revisions: old new
3+
//@ check-pass
4+
5+
use std::mem::ManuallyDrop;
6+
7+
struct Moose;
8+
9+
impl Drop for Moose {
10+
fn drop(&mut self) {}
11+
}
12+
13+
struct ConstDropper<T>(ManuallyDrop<T>);
14+
15+
const fn foo(_var: ConstDropper<Moose>) {}
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0493]: destructor of `ConstDropper<Moose>` cannot be evaluated at compile-time
2+
--> $DIR/drop-manually-drop.rs:21:14
3+
|
4+
LL | const fn foo(_var: ConstDropper<Moose>) {}
5+
| ^^^^ - value is dropped here
6+
| |
7+
| the destructor for this type cannot be evaluated in constant functions
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0493`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0493]: destructor of `ConstDropper<Moose>` cannot be evaluated at compile-time
2+
--> $DIR/drop-manually-drop.rs:21:14
3+
|
4+
LL | const fn foo(_var: ConstDropper<Moose>) {}
5+
| ^^^^ - value is dropped here
6+
| |
7+
| the destructor for this type cannot be evaluated in constant functions
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0493`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@[new] compile-flags: -Znext-solver
2+
//@ revisions: old new
3+
4+
#![feature(const_destruct)]
5+
#![feature(const_trait_impl)]
6+
7+
use std::mem::ManuallyDrop;
8+
9+
struct Moose;
10+
11+
impl Drop for Moose {
12+
fn drop(&mut self) {}
13+
}
14+
15+
struct ConstDropper<T>(ManuallyDrop<T>);
16+
17+
impl<T> const Drop for ConstDropper<T> {
18+
fn drop(&mut self) {}
19+
}
20+
21+
const fn foo(_var: ConstDropper<Moose>) {}
22+
//~^ ERROR destructor of `ConstDropper<Moose>` cannot be evaluated at compile-time
23+
24+
fn main() {}

0 commit comments

Comments
 (0)