Skip to content

Commit 0760803

Browse files
committed
rather than removing const_forget_box, stick an attribute on it and explain it cant be called in ctfe yet
1 parent dcc2321 commit 0760803

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libcore/tests/mem.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,16 @@ fn test_discriminant_send_sync() {
134134
fn test_const_forget() {
135135
const _: () = forget(0i32);
136136
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+
//
143+
// FIXME: this method cannot be called in const-eval yet, as Box isn't
144+
// const constructable
145+
#[allow(unused)]
146+
const fn const_forget_box<T: ?Sized>(x: Box<T>) {
147+
forget(x);
148+
}
137149
}

0 commit comments

Comments
 (0)