Skip to content

Commit

Permalink
Auto merge of rust-lang#88316 - est31:remove_box_tests, r=Mark-Simula…
Browse files Browse the repository at this point in the history
…crum

Remove most box syntax uses from the testsuite except for src/test/ui/issues

Removes most box syntax uses from the testsuite outside of the src/test/ui/issues directory. The goal was to only change tests where box syntax is an implementation detail instead of the actual feature being tested. So some tests were left out, like the regression test for rust-lang#87935, or tests where the obtained error message changed significantly.

Mostly this replaces box syntax with `Box::new`, but there are some minor drive by improvements, like formatting improvements or `assert_eq` instead of `assert!( == )`.

Prior PR that removed box syntax from the compiler and tools: rust-lang#87781
  • Loading branch information
bors committed Sep 26, 2021
2 parents ac8dd1b + 6550021 commit c09d637
Show file tree
Hide file tree
Showing 330 changed files with 999 additions and 1,193 deletions.
3 changes: 1 addition & 2 deletions src/test/debuginfo/borrowed-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
// lldbr-check:(f64) *unique_val_interior_ref_2 = 26.5

#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand All @@ -79,7 +78,7 @@ fn main() {
let stack_val_interior_ref_2: &f64 = &stack_val.y;
let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 };

let unique_val: Box<_> = box SomeStruct { x: 13, y: 26.5 };
let unique_val: Box<_> = Box::new(SomeStruct { x: 13, y: 26.5 });
let unique_val_ref: &SomeStruct = &*unique_val;
let unique_val_interior_ref_1: &isize = &unique_val.x;
let unique_val_interior_ref_2: &f64 = &unique_val.y;
Expand Down
3 changes: 1 addition & 2 deletions src/test/debuginfo/borrowed-tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@


#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand All @@ -46,7 +45,7 @@ fn main() {
let stack_val_ref: &(i16, f32) = &stack_val;
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);

let unique_val: Box<(i16, f32)> = box (-17, -22f32);
let unique_val: Box<(i16, f32)> = Box::new((-17, -22f32));
let unique_val_ref: &(i16, f32) = &*unique_val;

zzz(); // #break
Expand Down
29 changes: 14 additions & 15 deletions src/test/debuginfo/borrowed-unique-basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,51 +116,50 @@
// lldbr-check:(f64) *f64_ref = 3.5

#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

fn main() {
let bool_box: Box<bool> = box true;
let bool_box: Box<bool> = Box::new(true);
let bool_ref: &bool = &*bool_box;

let int_box: Box<isize> = box -1;
let int_box: Box<isize> = Box::new(-1);
let int_ref: &isize = &*int_box;

let char_box: Box<char> = box 'a';
let char_box: Box<char> = Box::new('a');
let char_ref: &char = &*char_box;

let i8_box: Box<i8> = box 68;
let i8_box: Box<i8> = Box::new(68);
let i8_ref: &i8 = &*i8_box;

let i16_box: Box<i16> = box -16;
let i16_box: Box<i16> = Box::new(-16);
let i16_ref: &i16 = &*i16_box;

let i32_box: Box<i32> = box -32;
let i32_box: Box<i32> = Box::new(-32);
let i32_ref: &i32 = &*i32_box;

let i64_box: Box<i64> = box -64;
let i64_box: Box<i64> = Box::new(-64);
let i64_ref: &i64 = &*i64_box;

let uint_box: Box<usize> = box 1;
let uint_box: Box<usize> = Box::new(1);
let uint_ref: &usize = &*uint_box;

let u8_box: Box<u8> = box 100;
let u8_box: Box<u8> = Box::new(100);
let u8_ref: &u8 = &*u8_box;

let u16_box: Box<u16> = box 16;
let u16_box: Box<u16> = Box::new(16);
let u16_ref: &u16 = &*u16_box;

let u32_box: Box<u32> = box 32;
let u32_box: Box<u32> = Box::new(32);
let u32_ref: &u32 = &*u32_box;

let u64_box: Box<u64> = box 64;
let u64_box: Box<u64> = Box::new(64);
let u64_ref: &u64 = &*u64_box;

let f32_box: Box<f32> = box 2.5;
let f32_box: Box<f32> = Box::new(2.5);
let f32_ref: &f32 = &*f32_box;

let f64_box: Box<f64> = box 3.5;
let f64_box: Box<f64> = Box::new(3.5);
let f64_ref: &f64 = &*f64_box;

zzz(); // #break
Expand Down
5 changes: 2 additions & 3 deletions src/test/debuginfo/box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
// lldbr-check:((i32, f64)) *b = { 0 = 2 1 = 3.5 }

#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

fn main() {
let a = box 1;
let b = box (2, 3.5f64);
let a = Box::new(1);
let b = Box::new((2, 3.5f64));

zzz(); // #break
}
Expand Down
17 changes: 13 additions & 4 deletions src/test/debuginfo/boxed-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
// lldbr-check:(boxed_struct::StructWithDestructor) *boxed_with_dtor = { x = 77 y = 777 z = 7777 w = 77777 }

#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand All @@ -52,9 +51,19 @@ impl Drop for StructWithDestructor {

fn main() {

let boxed_with_padding: Box<_> = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 };

let boxed_with_dtor: Box<_> = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 };
let boxed_with_padding: Box<_> = Box::new(StructWithSomePadding {
x: 99,
y: 999,
z: 9999,
w: 99999,
});

let boxed_with_dtor: Box<_> = Box::new(StructWithDestructor {
x: 77,
y: 777,
z: 7777,
w: 77777,
});
zzz(); // #break
}

Expand Down
1 change: 0 additions & 1 deletion src/test/debuginfo/closure-in-generic-function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
// lldbr-check:(i32) *y = 110
// lldb-command:continue

#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down
3 changes: 1 addition & 2 deletions src/test/debuginfo/destructured-fn-argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@

#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -480,7 +479,7 @@ fn main() {
managed_box(&(34, 35));
borrowed_pointer(&(36, 37));
contained_borrowed_pointer((&38, 39));
unique_pointer(box (40, 41, 42));
unique_pointer(Box::new((40, 41, 42)));
ref_binding((43, 44, 45));
ref_binding_in_tuple((46, (47, 48)));
ref_binding_in_struct(Struct { a: 49, b: 50 });
Expand Down
3 changes: 1 addition & 2 deletions src/test/debuginfo/destructured-for-loop-variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@

#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -214,7 +213,7 @@ fn main() {
y: -300001.5,
z: true
},
box 854237.5);
Box::new(854237.5));

for &(v1,
&Struct { x: x1, y: ref y1, z: z1 },
Expand Down
3 changes: 1 addition & 2 deletions src/test/debuginfo/destructured-local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@

#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -345,7 +344,7 @@ fn main() {
let (&cc, _) = (&38, 39);

// unique pointer
let box dd = box (40, 41, 42);
let box dd = Box::new((40, 41, 42));

// ref binding
let ref ee = (43, 44, 45);
Expand Down
3 changes: 1 addition & 2 deletions src/test/debuginfo/generic-method-on-generic-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
// lldbr-check:(f32) arg2 = -10.5
// lldb-command:continue

#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -155,7 +154,7 @@ fn main() {
let _ = stack.self_by_ref(-1, 2_u16);
let _ = stack.self_by_val(-3, -4_i16);

let owned: Box<_> = box Struct { x: 1234.5f64 };
let owned: Box<_> = Box::new(Struct { x: 1234.5f64 });
let _ = owned.self_by_ref(-5, -6_i32);
let _ = owned.self_by_val(-7, -8_i64);
let _ = owned.self_owned(-9, -10.5_f32);
Expand Down
3 changes: 1 addition & 2 deletions src/test/debuginfo/method-on-enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
// lldb-check:[...]$14 = -10
// lldb-command:continue

#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -140,7 +139,7 @@ fn main() {
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);

let owned: Box<_> = box Enum::Variant1{ x: 1799, y: 1799 };
let owned: Box<_> = Box::new(Enum::Variant1{ x: 1799, y: 1799 });
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
Expand Down
4 changes: 1 addition & 3 deletions src/test/debuginfo/method-on-generic-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@
// lldbr-check:(isize) arg2 = -10
// lldb-command:continue


#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -156,7 +154,7 @@ fn main() {
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);

let owned: Box<_> = box Struct { x: 1234.5f64 };
let owned: Box<_> = Box::new(Struct { x: 1234.5f64 });
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
Expand Down
4 changes: 1 addition & 3 deletions src/test/debuginfo/method-on-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@
// lldbr-check:(isize) arg2 = -10
// lldb-command:continue


#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -154,7 +152,7 @@ fn main() {
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);

let owned: Box<_> = box Struct { x: 200 };
let owned: Box<_> = Box::new(Struct { x: 200 });
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
Expand Down
4 changes: 1 addition & 3 deletions src/test/debuginfo/method-on-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@
// lldbr-check:(isize) arg2 = -10
// lldb-command:continue


#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -160,7 +158,7 @@ fn main() {
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);

let owned: Box<_> = box Struct { x: 200 };
let owned: Box<_> = Box::new(Struct { x: 200 });
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
Expand Down
4 changes: 1 addition & 3 deletions src/test/debuginfo/method-on-tuple-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@
// lldbr-check:(isize) arg2 = -10
// lldb-command:continue


#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

Expand Down Expand Up @@ -152,7 +150,7 @@ fn main() {
let _ = stack.self_by_ref(-1, -2);
let _ = stack.self_by_val(-3, -4);

let owned: Box<_> = box TupleStruct(200, -200.5);
let owned: Box<_> = Box::new(TupleStruct(200, -200.5));
let _ = owned.self_by_ref(-5, -6);
let _ = owned.self_by_val(-7, -8);
let _ = owned.self_owned(-9, -10);
Expand Down
Loading

0 comments on commit c09d637

Please sign in to comment.