Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 894ce92

Browse files
committed
better test
1 parent 48a3ba9 commit 894ce92

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
1+
// run-pass
12
#![feature(const_trait_impl)]
23
#![feature(const_fn_trait_bound)]
34
#![feature(const_mut_refs)]
45
#![feature(const_panic)]
56

6-
struct S;
7+
struct S<'a>(&'a mut u8);
78

8-
impl const Drop for S {
9+
impl<'a> const Drop for S<'a> {
910
fn drop(&mut self) {
10-
// NB: There is no way to tell that a const destructor is ran,
11-
// because even if we can operate on mutable variables, it will
12-
// not be reflected because everything is `const`. So we panic
13-
// here, attempting to make the CTFE engine error.
14-
panic!("much const drop")
15-
//~^ ERROR evaluation of constant value failed
11+
*self.0 += 1;
1612
}
1713
}
1814

1915
const fn a<T: ~const Drop>(_: T) {}
2016

21-
const _: () = a(S);
17+
const fn b() -> u8 {
18+
let mut c = 0;
19+
let _ = S(&mut c);
20+
a(S(&mut c));
21+
c
22+
}
23+
24+
const C: u8 = b();
2225

23-
fn main() {}
26+
fn main() {
27+
assert_eq!(C, 2);
28+
}

src/test/ui/rfc-2632-const-trait-impl/const-drop.stderr

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)