Skip to content

Commit 45b10f6

Browse files
authored
Rollup merge of #70038 - DutchGhost:const-forget-tests, r=RalfJung
Remove the call that makes miri fail Fixes the concern raised in https://github.com/rust-lang/rust/pull/69645/files#r392884274 cc @RalfJung
2 parents 801a25a + d6f3a43 commit 45b10f6

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

src/libcore/tests/mem.rs

-18
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,3 @@ fn test_discriminant_send_sync() {
129129
is_send_sync::<Discriminant<Regular>>();
130130
is_send_sync::<Discriminant<NotSendSync>>();
131131
}
132-
133-
#[test]
134-
fn test_const_forget() {
135-
const _: () = forget(0i32);
136-
const _: () = forget(Vec::<Vec<Box<i32>>>::new());
137-
138-
// Writing this function signature without const-forget
139-
// triggers compiler errors:
140-
// 1) That we use a non-const fn inside a const fn
141-
// 2) without the forget, it complains about the destructor of Box
142-
const fn const_forget_box<T>(x: Box<T>) {
143-
forget(x);
144-
}
145-
146-
// Call the forget_box at runtime,
147-
// as we can't const-construct a box yet.
148-
const_forget_box(Box::new(0i32));
149-
}

src/test/ui/consts/const_forget.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// check-pass
2+
3+
#![feature(const_forget)]
4+
5+
use std::mem::forget;
6+
7+
const _: () = forget(0i32);
8+
const _: () = forget(Vec::<Vec<Box<i32>>>::new());
9+
10+
// Writing this function signature without const-forget
11+
// triggers compiler errors:
12+
// 1) That we use a non-const fn inside a const fn
13+
// 2) without the forget, it complains about the destructor of Box
14+
//
15+
// FIXME: this method cannot be called in const-eval yet, as Box isn't
16+
// const constructable
17+
#[allow(unused)]
18+
const fn const_forget_box<T: ?Sized>(b: Box<T>) {
19+
forget(b);
20+
}
21+
22+
fn main() {}

0 commit comments

Comments
 (0)