Skip to content

Commit a674e1c

Browse files
committed
remove unused mut, restructure the test
1 parent 5f4af54 commit a674e1c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/libcore/tests/mem.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,18 @@ fn test_discriminant_send_sync() {
132132

133133
#[test]
134134
fn test_const_forget() {
135-
const fn test_const_forget<T>(x: T) {
136-
forget(x);
137-
}
135+
const _: () = forget(0i32);
136+
const _: () = forget(Vec::<Vec<Box<i32>>>::new());
138137

139138
// Writing this function signature without const-forget
140139
// triggers compiler errors:
141140
// 1) That we use a non-const fn inside a const fn
142141
// 2) without the forget, it complains about the destructor of Box
143-
const fn const_forget_box<T>(mut x: Box<T>) {
142+
const fn const_forget_box<T>(x: Box<T>) {
144143
forget(x);
145144
}
146145

147-
const _: () = test_const_forget(0i32);
148-
const _: () = test_const_forget(Vec::<Vec<Box<i32>>>::new());
146+
// Call the forget_box at runtime,
147+
// as we can't const-construct a box yet.
148+
const_forget_box(Box::new(0i32));
149149
}

0 commit comments

Comments
 (0)