1
Fork 0

Auto merge of #88316 - est31:remove_box_tests, r=Mark-Simulacrum

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 #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: #87781
This commit is contained in:
bors 2021-09-26 15:48:10 +00:00
commit c09d637432
330 changed files with 1015 additions and 1209 deletions

View file

@ -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]
@ -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;

View file

@ -37,7 +37,6 @@
#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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]
@ -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_padding: Box<_> = Box::new(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_dtor: Box<_> = Box::new(StructWithDestructor {
x: 77,
y: 777,
z: 7777,
w: 77777,
});
zzz(); // #break
}

View file

@ -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]

View file

@ -358,7 +358,6 @@
#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -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 });

View file

@ -173,7 +173,6 @@
#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -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 },

View file

@ -285,7 +285,6 @@
#![allow(unused_variables)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -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);

View file

@ -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]
@ -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);

View file

@ -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]
@ -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);

View file

@ -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]
@ -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);

View file

@ -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]
@ -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);

View file

@ -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]
@ -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);

View file

@ -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]
@ -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);

View file

@ -52,20 +52,20 @@
// gdb-command:print long_cycle4.value
// gdb-check:$18 = 29.5
// gdbr-command:print long_cycle_w_anonymous_types.value
// gdbr-command:print long_cycle_w_anon_types.value
// gdb-check:$19 = 30
// gdbr-command:print long_cycle_w_anonymous_types.next.val.value
// gdbr-command:print long_cycle_w_anon_types.next.val.value
// gdb-check:$20 = 31
// gdb-command:continue
#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
use self::Opt::{Empty, Val};
use std::boxed::Box as B;
enum Opt<T> {
Empty,
@ -120,75 +120,75 @@ struct LongCycleWithAnonymousTypes {
fn main() {
let stack_unique: UniqueNode<u16> = UniqueNode {
next: Val {
val: box UniqueNode {
val: Box::new(UniqueNode {
next: Empty,
value: 1,
}
})
},
value: 0,
};
let unique_unique: Box<UniqueNode<u32>> = box UniqueNode {
let unique_unique: Box<UniqueNode<u32>> = Box::new(UniqueNode {
next: Val {
val: box UniqueNode {
val: Box::new(UniqueNode {
next: Empty,
value: 3,
}
})
},
value: 2,
};
});
let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
next: Val {
val: box UniqueNode {
val: Box::new(UniqueNode {
next: Empty,
value: 7.5,
}
})
},
value: 6.5,
}];
let borrowed_unique: &UniqueNode<f64> = &UniqueNode {
next: Val {
val: box UniqueNode {
val: Box::new(UniqueNode {
next: Empty,
value: 9.5,
}
})
},
value: 8.5,
};
// LONG CYCLE
let long_cycle1: LongCycle1<u16> = LongCycle1 {
next: box LongCycle2 {
next: box LongCycle3 {
next: box LongCycle4 {
next: Box::new(LongCycle2 {
next: Box::new(LongCycle3 {
next: Box::new(LongCycle4 {
next: None,
value: 23,
},
}),
value: 22,
},
}),
value: 21
},
}),
value: 20
};
let long_cycle2: LongCycle2<u32> = LongCycle2 {
next: box LongCycle3 {
next: box LongCycle4 {
next: Box::new(LongCycle3 {
next: Box::new(LongCycle4 {
next: None,
value: 26,
},
}),
value: 25,
},
}),
value: 24
};
let long_cycle3: LongCycle3<u64> = LongCycle3 {
next: box LongCycle4 {
next: Box::new(LongCycle4 {
next: None,
value: 28,
},
}),
value: 27,
};
@ -199,15 +199,15 @@ fn main() {
// It's important that LongCycleWithAnonymousTypes is encountered only at the end of the
// `box` chain.
let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes {
let long_cycle_w_anon_types = B::new(B::new(B::new(B::new(B::new(LongCycleWithAnonymousTypes {
next: Val {
val: box box box box box LongCycleWithAnonymousTypes {
val: Box::new(Box::new(Box::new(Box::new(Box::new(LongCycleWithAnonymousTypes {
next: Empty,
value: 31,
}
})))))
},
value: 30
};
})))));
zzz(); // #break
}

View file

@ -121,7 +121,6 @@
// lldbr-check:(isize) arg2 = -10
// lldb-command:continue
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -154,7 +153,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);

View file

@ -121,7 +121,6 @@
// lldbr-check:(f32) arg2 = -10.5
// lldb-command:continue
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -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: 879 };
let owned: Box<_> = Box::new(Struct { x: 879 });
let _ = owned.self_by_ref(-5, -6_i32);
let _ = owned.self_by_val(-7, -8_i64);
let _ = owned.self_owned(-9, -10.5_f32);

View file

@ -5,7 +5,6 @@
// lldb-command:run
#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -24,5 +23,5 @@ impl Trait for Struct {}
fn main() {
let stack_struct = Struct { a:0, b: 1.0 };
let reference: &Trait = &stack_struct as &Trait;
let unique: Box<Trait> = box Struct { a:2, b: 3.0 } as Box<Trait>;
let unique: Box<Trait> = Box::new(Struct { a:2, b: 3.0 }) as Box<Trait>;
}

View file

@ -262,7 +262,6 @@
// cdb-check:struct ForeignType2 * foreign2 = [...]
// cdb-check:struct ForeignType1 * foreign1 = [...]
#![feature(box_syntax)]
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -373,8 +372,8 @@ fn main() {
let tuple2 = ((Struct1, mod1::mod2::Struct3), mod1::Variant1, 'x');
// Box
let box1 = (box 1f32, 0i32);
let box2 = (box mod1::mod2::Variant2(1f32), 0i32);
let box1 = (Box::new(1f32), 0i32);
let box2 = (Box::new(mod1::mod2::Variant2(1f32)), 0i32);
// References
let ref1 = (&Struct1, 0i32);
@ -404,14 +403,14 @@ fn main() {
let slice2 = &*vec2;
// Trait Objects
let box_trait = (box 0_isize) as Box<dyn Trait1>;
let box_trait = Box::new(0_isize) as Box<dyn Trait1>;
let ref_trait = &0_isize as &dyn Trait1;
let mut mut_int1 = 0_isize;
let mut_ref_trait = (&mut mut_int1) as &mut dyn Trait1;
let no_principal_trait = (box 0_isize) as Box<(dyn Send + Sync)>;
let no_principal_trait = Box::new(0_isize) as Box<(dyn Send + Sync)>;
let has_associated_type_trait = &0_isize as &(dyn Trait3<u32, AssocType = isize> + Send);
let generic_box_trait = (box 0_isize) as Box<dyn Trait2<i32, mod1::Struct2>>;
let generic_box_trait = Box::new(0_isize) as Box<dyn Trait2<i32, mod1::Struct2>>;
let generic_ref_trait = (&0_isize) as &dyn Trait2<Struct1, Struct1>;
let mut generic_mut_ref_trait_impl = 0_isize;

View file

@ -32,7 +32,6 @@
// lldbr-check:(unique_enum::Univariant) *univariant = { TheOnlyCase = { = 123234 } }
#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -59,15 +58,15 @@ fn main() {
// 0b01111100011111000111110001111100 = 2088533116
// 0b0111110001111100 = 31868
// 0b01111100 = 124
let the_a: Box<_> = box ABC::TheA { x: 0, y: 8970181431921507452 };
let the_a: Box<_> = Box::new(ABC::TheA { x: 0, y: 8970181431921507452 });
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
// 0b00010001000100010001000100010001 = 286331153
// 0b0001000100010001 = 4369
// 0b00010001 = 17
let the_b: Box<_> = box ABC::TheB (0, 286331153, 286331153);
let the_b: Box<_> = Box::new(ABC::TheB (0, 286331153, 286331153));
let univariant: Box<_> = box Univariant::TheOnlyCase(123234);
let univariant: Box<_> = Box::new(Univariant::TheOnlyCase(123234));
zzz(); // #break
}

View file

@ -133,7 +133,6 @@
// cdb-check:closure_local : 8 [Type: [...]]
#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -154,7 +153,7 @@ fn main() {
};
let struct_ref = &a_struct;
let owned: Box<_> = box 6;
let owned: Box<_> = Box::new(6);
let mut closure = || {
let closure_local = 8;

View file

@ -34,7 +34,6 @@
// lldbr-check:(isize) *owned = 5
#![allow(unused_variables)]
#![feature(box_syntax)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -53,7 +52,7 @@ fn main() {
c: 4
};
let owned: Box<_> = box 5;
let owned: Box<_> = Box::new(5);
let closure = move || {
zzz(); // #break

View file

@ -115,7 +115,6 @@
// cdb-command: dx owned
// cdb-check:owned : 0x[...] : 6 [Type: [...] *]
#![feature(box_syntax)]
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
@ -137,7 +136,7 @@ fn main() {
};
let struct_ref = &a_struct;
let owned: Box<_> = box 6;
let owned: Box<_> = Box::new(6);
{
let mut first_closure = || {

View file

@ -1,4 +1,4 @@
#![feature(box_syntax, plugin, rustc_private)]
#![feature(plugin, rustc_private)]
#![crate_type = "dylib"]
extern crate rustc_ast_pretty;
@ -21,7 +21,7 @@ use rustc_span::source_map;
#[no_mangle]
fn __rustc_plugin_registrar(reg: &mut Registry) {
reg.lint_store.register_lints(&[&MISSING_ALLOWED_ATTR]);
reg.lint_store.register_late_pass(|| box MissingAllowedAttrPass);
reg.lint_store.register_late_pass(|| Box::new(MissingAllowedAttrPass));
}
declare_lint! {

View file

@ -1,7 +1,6 @@
// force-host
#![feature(rustc_private)]
#![feature(box_syntax)]
extern crate rustc_driver;
extern crate rustc_hir;
@ -73,7 +72,7 @@ fn __rustc_plugin_registrar(reg: &mut Registry) {
&CRATE_NOT_GREY,
&CRATE_NOT_GREEN,
]);
reg.lint_store.register_late_pass(|| box PassOkay);
reg.lint_store.register_late_pass(|| box PassRedBlue);
reg.lint_store.register_late_pass(|| box PassGreyGreen);
reg.lint_store.register_late_pass(|| Box::new(PassOkay));
reg.lint_store.register_late_pass(|| Box::new(PassRedBlue));
reg.lint_store.register_late_pass(|| Box::new(PassGreyGreen));
}

View file

@ -1,7 +1,6 @@
// force-host
#![feature(rustc_private)]
#![feature(box_syntax)]
extern crate rustc_driver;
extern crate rustc_hir;
@ -41,5 +40,5 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
#[no_mangle]
fn __rustc_plugin_registrar(reg: &mut Registry) {
reg.lint_store.register_lints(&[&CRATE_NOT_OKAY]);
reg.lint_store.register_late_pass(|| box Pass);
reg.lint_store.register_late_pass(|| Box::new(Pass));
}

View file

@ -1,6 +1,6 @@
// force-host
#![feature(box_syntax, rustc_private)]
#![feature(rustc_private)]
// Load rustc as a plugin to get macros.
extern crate rustc_driver;
@ -36,7 +36,7 @@ impl<'tcx> LateLintPass<'tcx> for Pass {
#[no_mangle]
fn __rustc_plugin_registrar(reg: &mut Registry) {
reg.lint_store.register_lints(&[&TEST_LINT, &PLEASE_LINT]);
reg.lint_store.register_late_pass(|| box Pass);
reg.lint_store.register_late_pass(|| Box::new(Pass));
reg.lint_store.register_group(
true,
"lint_me",

View file

@ -1,6 +1,6 @@
// force-host
#![feature(box_syntax, rustc_private)]
#![feature(rustc_private)]
extern crate rustc_ast;
@ -31,5 +31,5 @@ impl EarlyLintPass for Pass {
#[no_mangle]
fn __rustc_plugin_registrar(reg: &mut Registry) {
reg.lint_store.register_lints(&[&TEST_LINT]);
reg.lint_store.register_early_pass(|| box Pass);
reg.lint_store.register_early_pass(|| Box::new(Pass));
}

View file

@ -1,4 +1,4 @@
#![feature(box_syntax, rustc_private)]
#![feature(rustc_private)]
extern crate rustc_ast;
@ -46,7 +46,7 @@ impl EarlyLintPass for Pass {
#[no_mangle]
fn __rustc_plugin_registrar(reg: &mut Registry) {
reg.lint_store.register_lints(&[&TEST_RUSTC_TOOL_LINT, &TEST_LINT, &TEST_GROUP]);
reg.lint_store.register_early_pass(|| box Pass);
reg.lint_store.register_early_pass(|| Box::new(Pass));
reg.lint_store.register_group(
true,
"clippy::group",

View file

@ -1,6 +1,6 @@
// force-host
#![feature(box_syntax, rustc_private)]
#![feature(rustc_private)]
extern crate rustc_middle;
extern crate rustc_driver;
@ -20,5 +20,5 @@ impl Drop for Foo {
#[no_mangle]
fn __rustc_plugin_registrar(_: &mut Registry) {
thread_local!(static FOO: RefCell<Option<Box<Any+Send>>> = RefCell::new(None));
FOO.with(|s| *s.borrow_mut() = Some(box Foo { foo: 10 } as Box<Any+Send>));
FOO.with(|s| *s.borrow_mut() = Some(Box::new(Foo { foo: 10 }) as Box<Any+Send>));
}

View file

@ -1,7 +1,6 @@
// run-pass
#![allow(unused_imports)]
#![feature(box_syntax)]
#![feature(rustc_private)]
extern crate rustc_macros;

View file

@ -3,8 +3,6 @@
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![feature(box_syntax)]
struct pair<A,B> {
a: A, b: B
}
@ -25,10 +23,10 @@ impl<A:Clone> Invokable<A> for Invoker<A> {
}
fn f<A:Clone + 'static>(a: A, b: u16) -> Box<dyn Invokable<A>+'static> {
box Invoker {
Box::new(Invoker {
a: a,
b: b,
} as Box<dyn Invokable<A>+'static>
}) as Box<dyn Invokable<A>+'static>
}
pub fn main() {

View file

@ -1,11 +1,9 @@
// run-pass
#![feature(box_syntax)]
pub fn main() {
// Tests for indexing into box/& [T; n]
// Tests for indexing into Box<[T; n]>/& [T; n]
let x: [isize; 3] = [1, 2, 3];
let mut x: Box<[isize; 3]> = box x;
let mut x: Box<[isize; 3]> = x.into();
assert_eq!(x[0], 1);
assert_eq!(x[1], 2);
assert_eq!(x[2], 3);

View file

@ -2,6 +2,6 @@
// pretty-expanded FIXME #23616
#![feature(box_syntax)]
pub fn main() { let _quux: Box<Vec<usize>> = box Vec::new(); }
pub fn main() {
let _quux: Box<Vec<usize>> = Box::new(Vec::new());
}

View file

@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]
fn pairwise_sub(mut t: Box<dyn DoubleEndedIterator<Item=isize>>) -> isize {
let mut result = 0;

View file

@ -1,23 +1,23 @@
#![feature(box_syntax)]
struct Clam {
x: Box<isize>,
y: Box<isize>,
}
struct Fish {
a: Box<isize>,
}
fn main() {
let a: Clam = Clam{x: box 1, y: box 2};
let b: Clam = Clam{x: box 10, y: box 20};
let a: Clam = Clam{ x: Box::new(1), y: Box::new(2) };
let b: Clam = Clam{ x: Box::new(10), y: Box::new(20) };
let z: isize = a.x + b.y;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", z);
assert_eq!(z, 21);
let forty: Fish = Fish{a: box 40};
let two: Fish = Fish{a: box 2};
let forty: Fish = Fish{ a: Box::new(40) };
let two: Fish = Fish{ a: Box::new(2) };
let answer: isize = forty.a + two.a;
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
println!("{}", answer);

View file

@ -1,6 +1,5 @@
// run-pass
#![allow(non_camel_case_types)]
#![feature(box_syntax)]
trait double {
fn double(self: Box<Self>) -> usize;
@ -11,6 +10,6 @@ impl double for usize {
}
pub fn main() {
let x: Box<_> = box (box 3usize as Box<dyn double>);
let x: Box<_> = Box::new(Box::new(3usize) as Box<dyn double>);
assert_eq!(x.double(), 6);
}

View file

@ -1,6 +1,5 @@
// run-pass
#![allow(non_camel_case_types)]
#![feature(box_syntax)]
trait double {
fn double(self) -> usize;
@ -15,6 +14,6 @@ impl double for Box<usize> {
}
pub fn main() {
let x: Box<_> = box 3;
let x: Box<_> = Box::new(3);
assert_eq!(x.double(), 6);
}

View file

@ -1,6 +1,5 @@
// run-pass
#![allow(non_camel_case_types)]
#![feature(box_syntax)]
trait double {
fn double(self: Box<Self>) -> usize;
@ -11,6 +10,6 @@ impl double for Box<usize> {
}
pub fn main() {
let x: Box<Box<Box<Box<Box<_>>>>> = box box box box box 3;
let x: Box<Box<Box<Box<Box<_>>>>> = Box::new(Box::new(Box::new(Box::new(Box::new(3)))));
assert_eq!(x.double(), 6);
}

View file

@ -1,6 +1,5 @@
// run-pass
#![allow(non_camel_case_types)]
#![feature(box_syntax)]
trait double {
fn double(self: Box<Self>) -> usize;
@ -11,6 +10,6 @@ impl double for usize {
}
pub fn main() {
let x: Box<Box<_>> = box box 3;
let x: Box<Box<_>> = Box::new(Box::new(3));
assert_eq!(x.double(), 6);
}

View file

@ -1,6 +1,5 @@
// run-pass
#![allow(non_camel_case_types)]
#![feature(box_syntax)]
trait double {
fn double(self: Box<Self>) -> usize;
@ -11,6 +10,6 @@ impl double for usize {
}
pub fn main() {
let x: Box<_> = box 3;
let x: Box<_> = Box::new(3);
assert_eq!(x.double(), 6);
}

View file

@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]
trait Foo {
fn foo(&self) -> String;
@ -18,6 +17,6 @@ impl Foo for usize {
}
pub fn main() {
let x: Box<_> = box 3;
let x: Box<_> = Box::new(3);
assert_eq!(x.foo(), "box 3".to_string());
}

View file

@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]
fn test_generic<T: Clone, F>(expected: Box<T>, eq: F) where F: FnOnce(Box<T>, Box<T>) -> bool {
let actual: Box<T> = match true {
@ -13,7 +12,7 @@ fn test_box() {
fn compare_box(b1: Box<bool>, b2: Box<bool>) -> bool {
return *b1 == *b2;
}
test_generic::<bool, _>(box true, compare_box);
test_generic::<bool, _>(Box::new(true), compare_box);
}
pub fn main() { test_box(); }

View file

@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]
fn test_generic<T: Clone, F>(expected: T, eq: F) where F: FnOnce(T, T) -> bool {
let actual: T = match true {
@ -11,7 +10,7 @@ fn test_generic<T: Clone, F>(expected: T, eq: F) where F: FnOnce(T, T) -> bool {
fn test_vec() {
fn compare_box(v1: Box<isize>, v2: Box<isize>) -> bool { return v1 == v2; }
test_generic::<Box<isize>, _>(box 1, compare_box);
test_generic::<Box<isize>, _>(Box::new(1), compare_box);
}
pub fn main() { test_vec(); }

View file

@ -1,9 +1,8 @@
// run-pass
#![feature(box_syntax)]
// Tests for match as expressions resulting in boxed types
fn test_box() {
let res: Box<_> = match true { true => { box 100 }, _ => panic!() };
let res: Box<_> = match true { true => { Box::new(100) }, _ => panic!() };
assert_eq!(*res, 100);
}

View file

@ -3,8 +3,6 @@
// Test that we do not leak when the arg pattern must drop part of the
// argument (in this case, the `y` field).
#![feature(box_syntax)]
struct Foo {
x: Box<usize>,
y: Box<usize>,
@ -16,9 +14,9 @@ fn foo(Foo {x, ..}: Foo) -> *const usize {
}
pub fn main() {
let obj: Box<_> = box 1;
let obj: Box<_> = Box::new(1);
let objptr: *const usize = &*obj;
let f = Foo {x: obj, y: box 2};
let f = Foo { x: obj, y: Box::new(2) };
let xptr = foo(f);
assert_eq!(objptr, xptr);
}

View file

@ -5,7 +5,6 @@
// pattern.
#![feature(box_patterns)]
#![feature(box_syntax)]
fn getaddr(box ref x: Box<usize>) -> *const usize {
let addr: *const usize = &*x;
@ -17,11 +16,11 @@ fn checkval(box ref x: Box<usize>) -> usize {
}
pub fn main() {
let obj: Box<_> = box 1;
let obj: Box<_> = Box::new(1);
let objptr: *const usize = &*obj;
let xptr = getaddr(obj);
assert_eq!(objptr, xptr);
let obj = box 22;
let obj = Box::new(22);
assert_eq!(checkval(obj), 22);
}

View file

@ -1,8 +1,7 @@
// run-pass
#![feature(box_syntax)]
fn f() {
let a: Box<_> = box 1;
let a: Box<_> = Box::new(1);
let b: &isize = &*a;
println!("{}", b);
}

View file

@ -1,16 +1,15 @@
// run-pass
#![allow(non_shorthand_field_patterns)]
#![feature(box_syntax)]
struct Pair { a: Box<isize>, b: Box<isize> }
pub fn main() {
let mut x: Box<_> = box Pair {a: box 10, b: box 20};
let mut x: Box<_> = Box::new(Pair { a: Box::new(10), b: Box::new(20) });
let x_internal = &mut *x;
match *x_internal {
Pair {a: ref mut a, b: ref mut _b} => {
assert_eq!(**a, 10);
*a = box 30;
*a = Box::new(30);
assert_eq!(**a, 30);
}
}

View file

@ -1,9 +1,8 @@
// run-pass
#![feature(box_patterns)]
#![feature(box_syntax)]
pub fn main() {
match box 100 {
match Box::new(100) {
box x => {
println!("{}", x);
assert_eq!(x, 100);

View file

@ -1,8 +1,6 @@
// run-pass
// pretty-expanded FIXME #23616
#![feature(box_syntax)]
fn foo(x: Option<Box<isize>>, b: bool) -> isize {
match x {
None => { 1 }
@ -12,8 +10,8 @@ fn foo(x: Option<Box<isize>>, b: bool) -> isize {
}
pub fn main() {
foo(Some(box 22), true);
foo(Some(box 22), false);
foo(Some(Box::new(22)), true);
foo(Some(Box::new(22)), false);
foo(None, true);
foo(None, false);
}

View file

@ -1,13 +1,13 @@
#![feature(box_syntax)]
struct Foo(Box<isize>, isize);
struct Bar(isize, isize);
fn main() {
let x: (Box<_>, _) = (box 1, 2);
let x: (Box<_>, _) = (Box::new(1), 2);
let r = &x.0;
let y = x; //~ ERROR cannot move out of `x` because it is borrowed
@ -23,7 +23,7 @@ fn main() {
let b = &mut x.0; //~ ERROR cannot borrow `x.0` as mutable more than once at a time
a.use_ref();
let x = Foo(box 1, 2);
let x = Foo(Box::new(1), 2);
let r = &x.0;
let y = x; //~ ERROR cannot move out of `x` because it is borrowed
r.use_ref();

View file

@ -1,10 +1,10 @@
// Test that we detect nested calls that could free pointers evaluated
// for earlier arguments.
#![feature(box_syntax)]
fn rewrite(v: &mut Box<usize>) -> usize {
*v = box 22;
*v = Box::new(22);
**v
}
@ -13,7 +13,7 @@ fn add(v: &usize, w: usize) -> usize {
}
fn implicit() {
let mut a: Box<_> = box 1;
let mut a: Box<_> = Box::new(1);
// Note the danger here:
//
@ -26,7 +26,7 @@ fn implicit() {
}
fn explicit() {
let mut a: Box<_> = box 1;
let mut a: Box<_> = Box::new(1);
add(
&*a,
rewrite(&mut a)); //~ ERROR cannot borrow

View file

@ -1,10 +1,10 @@
// Test that we detect nested calls that could free pointers evaluated
// for earlier arguments.
#![feature(box_syntax)]
fn rewrite(v: &mut Box<usize>) -> usize {
*v = box 22;
*v = Box::new(22);
**v
}
@ -13,7 +13,7 @@ fn add(v: &usize, w: Box<usize>) -> usize {
}
fn implicit() {
let mut a: Box<_> = box 1;
let mut a: Box<_> = Box::new(1);
// Note the danger here:
//
@ -26,7 +26,7 @@ fn implicit() {
}
fn explicit() {
let mut a: Box<_> = box 1;
let mut a: Box<_> = Box::new(1);
add(
&*a,
a); //~ ERROR cannot move

View file

@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]
fn borrow<F>(x: &isize, f: F) where F: FnOnce(&isize) {
f(x)
@ -14,5 +13,5 @@ fn test1(x: &Box<isize>) {
}
pub fn main() {
test1(&box 22);
test1(&Box::new(22));
}

View file

@ -1,5 +1,3 @@
#![feature(box_syntax)]
struct A;
impl A {
@ -7,8 +5,10 @@ impl A {
}
}
pub fn main() {
let a: Box<_> = box A;
let a: Box<_> = Box::new(A);
a.foo();
//~^ ERROR cannot borrow `*a` as mutable, as `a` is not declared as mutable [E0596]
}

View file

@ -1,7 +1,7 @@
error[E0596]: cannot borrow `*a` as mutable, as `a` is not declared as mutable
--> $DIR/borrowck-borrow-immut-deref-of-box-as-mut.rs:12:5
|
LL | let a: Box<_> = box A;
LL | let a: Box<_> = Box::new(A);
| - help: consider changing this to be mutable: `mut a`
LL | a.foo();
| ^ cannot borrow as mutable

View file

@ -1,15 +1,15 @@
//buggy.rs
#![feature(box_syntax)]
use std::collections::HashMap;
fn main() {
let tmp: Box<_>;
let mut buggy_map: HashMap<usize, &usize> = HashMap::new();
buggy_map.insert(42, &*Box::new(1)); //~ ERROR temporary value dropped while borrowed
// but it is ok if we use a temporary
tmp = box 2;
tmp = Box::new(2);
buggy_map.insert(43, &*tmp);
}

View file

@ -3,8 +3,6 @@
// run-pass
#![feature(box_syntax)]
struct A {
x: Box<isize>,
y: isize,
@ -26,97 +24,97 @@ struct D {
}
fn copy_after_move() {
let a: Box<_> = box A { x: box 0, y: 1 };
let a: Box<_> = Box::new(A { x: Box::new(0), y: 1 });
let _x = a.x;
let _y = a.y;
}
fn move_after_move() {
let a: Box<_> = box B { x: box 0, y: box 1 };
let a: Box<_> = Box::new(B { x: Box::new(0), y: Box::new(1) });
let _x = a.x;
let _y = a.y;
}
fn borrow_after_move() {
let a: Box<_> = box A { x: box 0, y: 1 };
let a: Box<_> = Box::new(A { x: Box::new(0), y: 1 });
let _x = a.x;
let _y = &a.y;
}
fn move_after_borrow() {
let a: Box<_> = box B { x: box 0, y: box 1 };
let a: Box<_> = Box::new(B { x: Box::new(0), y: Box::new(1) });
let _x = &a.x;
let _y = a.y;
use_imm(_x);
}
fn copy_after_mut_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let mut a: Box<_> = Box::new(A { x: Box::new(0), y: 1 });
let _x = &mut a.x;
let _y = a.y;
use_mut(_x);
}
fn move_after_mut_borrow() {
let mut a: Box<_> = box B { x: box 0, y: box 1 };
let mut a: Box<_> = Box::new(B { x: Box::new(0), y: Box::new(1) });
let _x = &mut a.x;
let _y = a.y;
use_mut(_x);
}
fn borrow_after_mut_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let mut a: Box<_> = Box::new(A { x: Box::new(0), y: 1 });
let _x = &mut a.x;
let _y = &a.y;
use_mut(_x);
}
fn mut_borrow_after_borrow() {
let mut a: Box<_> = box A { x: box 0, y: 1 };
let mut a: Box<_> = Box::new(A { x: Box::new(0), y: 1 });
let _x = &a.x;
let _y = &mut a.y;
use_imm(_x);
}
fn copy_after_move_nested() {
let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let a: Box<_> = Box::new(C { x: Box::new(A { x: Box::new(0), y: 1 }), y: 2 });
let _x = a.x.x;
let _y = a.y;
}
fn move_after_move_nested() {
let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let a: Box<_> = Box::new(D { x: Box::new(A { x: Box::new(0), y: 1 }), y: Box::new(2) });
let _x = a.x.x;
let _y = a.y;
}
fn borrow_after_move_nested() {
let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let a: Box<_> = Box::new(C { x: Box::new(A { x: Box::new(0), y: 1 }), y: 2 });
let _x = a.x.x;
let _y = &a.y;
}
fn move_after_borrow_nested() {
let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let a: Box<_> = Box::new(D { x: Box::new(A { x: Box::new(0), y: 1 }), y: Box::new(2) });
let _x = &a.x.x;
let _y = a.y;
use_imm(_x);
}
fn copy_after_mut_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let mut a: Box<_> = Box::new(C { x: Box::new(A { x: Box::new(0), y: 1 }), y: 2 });
let _x = &mut a.x.x;
let _y = a.y;
use_mut(_x);
}
fn move_after_mut_borrow_nested() {
let mut a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 };
let mut a: Box<_> = Box::new(D { x: Box::new(A { x: Box::new(0), y: 1 }), y: Box::new(2) });
let _x = &mut a.x.x;
let _y = a.y;
use_mut(_x);
}
fn borrow_after_mut_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let mut a: Box<_> = Box::new(C { x: Box::new(A { x: Box::new(0), y: 1 }), y: 2 });
let _x = &mut a.x.x;
let _y = &a.y;
use_mut(_x);
}
fn mut_borrow_after_borrow_nested() {
let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 };
let mut a: Box<_> = Box::new(C { x: Box::new(A { x: Box::new(0), y: 1 }), y: 2 });
let _x = &a.x.x;
let _y = &mut a.y;
use_imm(_x);

View file

@ -1,8 +1,6 @@
// Tests that two closures cannot simultaneously have mutable
// and immutable access to the variable. Issue #6801.
#![feature(box_syntax)]
fn get(x: &isize) -> isize {
*x
}
@ -11,6 +9,8 @@ fn set(x: &mut isize) {
*x = 4;
}
fn a() {
let mut x = 3;
let c1 = || x = 4;
@ -52,7 +52,7 @@ fn e() {
}
fn f() {
let mut x: Box<_> = box 3;
let mut x: Box<_> = Box::new(3);
let c1 = || get(&*x);
*x = 5;
//~^ ERROR cannot assign to `*x` because it is borrowed
@ -64,7 +64,7 @@ fn g() {
f: Box<isize>
}
let mut x: Box<_> = box Foo { f: box 3 };
let mut x: Box<_> = Box::new(Foo { f: Box::new(3) });
let c1 = || get(&*x.f);
*x.f = 5;
//~^ ERROR cannot assign to `*x.f` because it is borrowed
@ -76,7 +76,7 @@ fn h() {
f: Box<isize>
}
let mut x: Box<_> = box Foo { f: box 3 };
let mut x: Box<_> = Box::new(Foo { f: Box::new(3) });
let c1 = || get(&*x.f);
let c2 = || *x.f = 5;
//~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable

View file

@ -2,7 +2,7 @@
// access to the variable, whether that mutable access be used
// for direct assignment or for taking mutable ref. Issue #6801.
#![feature(box_syntax)]
@ -48,7 +48,7 @@ fn g() {
f: Box<isize>
}
let mut x: Box<_> = box Foo { f: box 3 };
let mut x: Box<_> = Box::new(Foo { f: Box::new(3) });
let c1 = to_fn_mut(|| set(&mut *x.f));
let c2 = to_fn_mut(|| set(&mut *x.f));
//~^ ERROR cannot borrow `x` as mutable more than once

View file

@ -2,7 +2,7 @@
// access to the variable, whether that mutable access be used
// for direct assignment or for taking mutable ref. Issue #6801.
#![feature(box_syntax)]
fn to_fn_mut<F: FnMut()>(f: F) -> F { f }
@ -44,7 +44,7 @@ fn g() {
f: Box<isize>
}
let mut x: Box<_> = box Foo { f: box 3 };
let mut x: Box<_> = Box::new(Foo { f: Box::new(3) });
let c1 = to_fn_mut(|| set(&mut *x.f));
let c2 = to_fn_mut(|| set(&mut *x.f));
//~^ ERROR cannot borrow `x` as mutable more than once

View file

@ -2,8 +2,6 @@
// cannot also be supplied a borrowed version of that
// variable's contents. Issue #11192.
#![feature(box_syntax)]
struct Foo {
x: isize
}
@ -14,10 +12,12 @@ impl Drop for Foo {
}
}
fn main() {
let mut ptr: Box<_> = box Foo { x: 0 };
let mut ptr: Box<_> = Box::new(Foo { x: 0 });
let mut test = |foo: &Foo| {
ptr = box Foo { x: ptr.x + 1 };
ptr = Box::new(Foo { x: ptr.x + 1 });
};
test(&*ptr); //~ ERROR cannot borrow `*ptr`
}

View file

@ -3,7 +3,7 @@ error[E0502]: cannot borrow `*ptr` as immutable because it is also borrowed as m
|
LL | let mut test = |foo: &Foo| {
| ----------- mutable borrow occurs here
LL | ptr = box Foo { x: ptr.x + 1 };
LL | ptr = Box::new(Foo { x: ptr.x + 1 });
| --- first borrow occurs due to use of `ptr` in closure
LL | };
LL | test(&*ptr);

View file

@ -3,89 +3,87 @@
#![allow(unused_variables)]
// pretty-expanded FIXME #23616
#![feature(box_syntax)]
struct A { a: isize, b: Box<isize> }
struct B { a: Box<isize>, b: Box<isize> }
fn move_after_copy() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.a);
drop(x.b);
}
fn move_after_fu_copy() {
let x = A { a: 1, b: box 2 };
let _y = A { b: box 3, .. x };
let x = A { a: 1, b: Box::new(2) };
let _y = A { b: Box::new(3), .. x };
drop(x.b);
}
fn fu_move_after_copy() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.a);
let _y = A { a: 3, .. x };
}
fn fu_move_after_fu_copy() {
let x = A { a: 1, b: box 2 };
let _y = A { b: box 3, .. x };
let x = A { a: 1, b: Box::new(2) };
let _y = A { b: Box::new(3), .. x };
let _z = A { a: 4, .. x };
}
fn copy_after_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.b);
drop(x.a);
}
fn copy_after_fu_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let y = A { a: 3, .. x };
drop(x.a);
}
fn fu_copy_after_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.b);
let _y = A { b: box 3, .. x };
let _y = A { b: Box::new(3), .. x };
}
fn fu_copy_after_fu_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
let _z = A { b: box 3, .. x };
let _z = A { b: Box::new(3), .. x };
}
fn borrow_after_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.b);
let p = &x.a;
drop(*p);
}
fn borrow_after_fu_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
let p = &x.a;
drop(*p);
}
fn move_after_borrow() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let p = &x.a;
drop(x.b);
drop(*p);
}
fn fu_move_after_borrow() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let p = &x.a;
let _y = A { a: 3, .. x };
drop(*p);
}
fn mut_borrow_after_mut_borrow() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let p = &mut x.a;
let q = &mut x.b;
drop(*p);
@ -93,134 +91,134 @@ fn mut_borrow_after_mut_borrow() {
}
fn move_after_move() {
let x = B { a: box 1, b: box 2 };
let x = B { a: Box::new(1), b: Box::new(2) };
drop(x.a);
drop(x.b);
}
fn move_after_fu_move() {
let x = B { a: box 1, b: box 2 };
let y = B { a: box 3, .. x };
let x = B { a: Box::new(1), b: Box::new(2) };
let y = B { a: Box::new(3), .. x };
drop(x.a);
}
fn fu_move_after_move() {
let x = B { a: box 1, b: box 2 };
let x = B { a: Box::new(1), b: Box::new(2) };
drop(x.a);
let z = B { a: box 3, .. x };
let z = B { a: Box::new(3), .. x };
drop(z.b);
}
fn fu_move_after_fu_move() {
let x = B { a: box 1, b: box 2 };
let _y = B { b: box 3, .. x };
let _z = B { a: box 4, .. x };
let x = B { a: Box::new(1), b: Box::new(2) };
let _y = B { b: Box::new(3), .. x };
let _z = B { a: Box::new(4), .. x };
}
fn copy_after_assign_after_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
drop(x.b);
x = A { a: 3, b: box 4 };
x = A { a: 3, b: Box::new(4) };
drop(*x.b);
}
fn copy_after_assign_after_fu_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
x = A { a: 3, b: box 4 };
x = A { a: 3, b: Box::new(4) };
drop(*x.b);
}
fn copy_after_field_assign_after_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
drop(x.b);
x.b = box 3;
x.b = Box::new(3);
drop(*x.b);
}
fn copy_after_field_assign_after_fu_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
x.b = box 3;
x.b = Box::new(3);
drop(*x.b);
}
fn borrow_after_assign_after_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
drop(x.b);
x = A { a: 3, b: box 4 };
x = A { a: 3, b: Box::new(4) };
let p = &x.b;
drop(**p);
}
fn borrow_after_assign_after_fu_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
x = A { a: 3, b: box 4 };
x = A { a: 3, b: Box::new(4) };
let p = &x.b;
drop(**p);
}
fn borrow_after_field_assign_after_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
drop(x.b);
x.b = box 3;
x.b = Box::new(3);
let p = &x.b;
drop(**p);
}
fn borrow_after_field_assign_after_fu_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
x.b = box 3;
x.b = Box::new(3);
let p = &x.b;
drop(**p);
}
fn move_after_assign_after_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let _y = x.b;
x = A { a: 3, b: box 4 };
x = A { a: 3, b: Box::new(4) };
drop(x.b);
}
fn move_after_assign_after_fu_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
x = A { a: 3, b: box 4 };
x = A { a: 3, b: Box::new(4) };
drop(x.b);
}
fn move_after_field_assign_after_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
drop(x.b);
x.b = box 3;
x.b = Box::new(3);
drop(x.b);
}
fn move_after_field_assign_after_fu_move() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
x.b = box 3;
x.b = Box::new(3);
drop(x.b);
}
fn copy_after_assign_after_uninit() {
let mut x: A;
x = A { a: 1, b: box 2 };
x = A { a: 1, b: Box::new(2) };
drop(x.a);
}
fn borrow_after_assign_after_uninit() {
let mut x: A;
x = A { a: 1, b: box 2 };
x = A { a: 1, b: Box::new(2) };
let p = &x.a;
drop(*p);
}
fn move_after_assign_after_uninit() {
let mut x: A;
x = A { a: 1, b: box 2 };
x = A { a: 1, b: Box::new(2) };
drop(x.b);
}

View file

@ -1,49 +1,49 @@
#![feature(box_syntax)]
struct A { a: isize, b: Box<isize> }
fn deref_after_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.b);
drop(*x.b); //~ ERROR use of moved value: `x.b`
}
fn deref_after_fu_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let y = A { a: 3, .. x };
drop(*x.b); //~ ERROR use of moved value: `x.b`
}
fn borrow_after_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.b);
let p = &x.b; //~ ERROR borrow of moved value: `x.b`
drop(**p);
}
fn borrow_after_fu_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
let p = &x.b; //~ ERROR borrow of moved value: `x.b`
drop(**p);
}
fn move_after_borrow() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let p = &x.b;
drop(x.b); //~ ERROR cannot move out of `x.b` because it is borrowed
drop(**p);
}
fn fu_move_after_borrow() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let p = &x.b;
let _y = A { a: 3, .. x }; //~ ERROR cannot move out of `x.b` because it is borrowed
drop(**p);
}
fn mut_borrow_after_mut_borrow() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let p = &mut x.a;
let q = &mut x.a; //~ ERROR cannot borrow `x.a` as mutable more than once at a time
drop(*p);
@ -51,25 +51,25 @@ fn mut_borrow_after_mut_borrow() {
}
fn move_after_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.b);
drop(x.b); //~ ERROR use of moved value: `x.b`
}
fn move_after_fu_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
drop(x.b); //~ ERROR use of moved value: `x.b`
}
fn fu_move_after_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
drop(x.b);
let _z = A { a: 3, .. x }; //~ ERROR use of moved value: `x.b`
}
fn fu_move_after_fu_move() {
let x = A { a: 1, b: box 2 };
let x = A { a: 1, b: Box::new(2) };
let _y = A { a: 3, .. x };
let _z = A { a: 4, .. x }; //~ ERROR use of moved value: `x.b`
}
@ -91,7 +91,7 @@ fn borrow_after_field_assign_after_uninit() {
fn move_after_field_assign_after_uninit() {
let mut x: A;
x.b = box 1; //~ ERROR assign to part of possibly-uninitialized variable: `x`
x.b = Box::new(1); //~ ERROR assign to part of possibly-uninitialized variable: `x`
drop(x.b);
}

View file

@ -123,7 +123,7 @@ LL | x.a = 1;
error[E0381]: assign to part of possibly-uninitialized variable: `x`
--> $DIR/borrowck-field-sensitivity.rs:94:5
|
LL | x.b = box 1;
LL | x.b = Box::new(1);
| ^^^ use of possibly-uninitialized `x`
error: aborting due to 14 previous errors

View file

@ -1,6 +1,6 @@
// Issue #16205.
#![feature(box_syntax)]
struct Foo {
a: [Box<isize>; 3],
@ -13,12 +13,12 @@ fn main() {
}
let f = Foo {
a: [box 3, box 4, box 5],
a: [Box::new(3), Box::new(4), Box::new(5)],
};
for &a in &f.a { //~ ERROR cannot move out
}
let x: Option<Box<_>> = Some(box 1);
let x: Option<Box<_>> = Some(Box::new(1));
for &a in x.iter() { //~ ERROR cannot move out
}
}

View file

@ -4,14 +4,14 @@
// Also includes tests of the errors reported when the Box in question
// is immutable (#14270).
#![feature(box_syntax)]
struct A { a: isize }
struct B<'a> { a: Box<&'a mut isize> }
fn indirect_write_to_imm_box() {
let mut x: isize = 1;
let y: Box<_> = box &mut x;
let y: Box<_> = Box::new(&mut x);
let p = &y;
***p = 2; //~ ERROR cannot assign to `***p`
drop(p);
@ -19,7 +19,7 @@ fn indirect_write_to_imm_box() {
fn borrow_in_var_from_var() {
let mut x: isize = 1;
let mut y: Box<_> = box &mut x;
let mut y: Box<_> = Box::new(&mut x);
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
@ -29,7 +29,7 @@ fn borrow_in_var_from_var() {
fn borrow_in_var_from_var_via_imm_box() {
let mut x: isize = 1;
let y: Box<_> = box &mut x;
let y: Box<_> = Box::new(&mut x);
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
@ -39,7 +39,7 @@ fn borrow_in_var_from_var_via_imm_box() {
fn borrow_in_var_from_field() {
let mut x = A { a: 1 };
let mut y: Box<_> = box &mut x.a;
let mut y: Box<_> = Box::new(&mut x.a);
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
@ -49,7 +49,7 @@ fn borrow_in_var_from_field() {
fn borrow_in_var_from_field_via_imm_box() {
let mut x = A { a: 1 };
let y: Box<_> = box &mut x.a;
let y: Box<_> = Box::new(&mut x.a);
let p = &y;
let q = &***p;
**y = 2; //~ ERROR cannot assign to `**y` because it is borrowed
@ -59,7 +59,7 @@ fn borrow_in_var_from_field_via_imm_box() {
fn borrow_in_field_from_var() {
let mut x: isize = 1;
let mut y = B { a: box &mut x };
let mut y = B { a: Box::new(&mut x) };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
@ -69,7 +69,7 @@ fn borrow_in_field_from_var() {
fn borrow_in_field_from_var_via_imm_box() {
let mut x: isize = 1;
let y = B { a: box &mut x };
let y = B { a: Box::new(&mut x) };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
@ -79,7 +79,7 @@ fn borrow_in_field_from_var_via_imm_box() {
fn borrow_in_field_from_field() {
let mut x = A { a: 1 };
let mut y = B { a: box &mut x.a };
let mut y = B { a: Box::new(&mut x.a) };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed
@ -89,7 +89,7 @@ fn borrow_in_field_from_field() {
fn borrow_in_field_from_field_via_imm_box() {
let mut x = A { a: 1 };
let y = B { a: box &mut x.a };
let y = B { a: Box::new(&mut x.a) };
let p = &y.a;
let q = &***p;
**y.a = 2; //~ ERROR cannot assign to `**y.a` because it is borrowed

View file

@ -1,9 +1,9 @@
#![feature(box_syntax)]
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }
fn main() {
let x: Option<Box<_>> = Some(box 1);
let x: Option<Box<_>> = Some(Box::new(1));
match x {
Some(ref _y) => {
let _a = x; //~ ERROR cannot move
@ -12,6 +12,3 @@ fn main() {
_ => {}
}
}
trait Fake { fn use_mut(&mut self) { } fn use_ref(&self) { } }
impl<T> Fake for T { }

View file

@ -1,7 +1,7 @@
#![feature(box_syntax)]
fn main() {
let x: Option<Box<_>> = Some(box 1);
let x: Option<Box<_>> = Some(Box::new(1));
match x {
Some(ref y) => {
let _b = *y; //~ ERROR cannot move out

View file

@ -4,7 +4,7 @@
// either genuine or would require more advanced changes. The latter
// cases are noted.
#![feature(box_syntax)]
fn borrow(_v: &isize) {}
fn borrow_mut(_v: &mut isize) {}
@ -13,15 +13,15 @@ fn for_func<F>(_f: F) where F: FnOnce() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<isize>) {
*v = box (**v + 1);
*v = Box::new(**v + 1);
}
fn pre_freeze_cond() {
// In this instance, the freeze is conditional and starts before
// the mut borrow.
let u = box 0;
let mut v: Box<_> = box 3;
let u = Box::new(0);
let mut v: Box<_> = Box::new(3);
let mut _w = &u;
if cond() {
_w = &v;
@ -34,8 +34,8 @@ fn pre_freeze_else() {
// In this instance, the freeze and mut borrow are on separate sides
// of the if.
let u = box 0;
let mut v: Box<_> = box 3;
let u = Box::new(0);
let mut v: Box<_> = Box::new(3);
let mut _w = &u;
if cond() {
_w = &v;

View file

@ -1,18 +1,18 @@
#![feature(box_syntax)]
fn borrow(_v: &isize) {}
fn borrow_mut(_v: &mut isize) {}
fn cond() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<isize>) {
*v = box (**v + 1);
*v = Box::new(**v + 1);
}
fn loop_overarching_alias_mut() {
// In this instance, the borrow ends on the line before the loop
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
let mut x = &mut v;
**x += 1;
loop {
@ -23,18 +23,18 @@ fn loop_overarching_alias_mut() {
fn block_overarching_alias_mut() {
// In this instance, the borrow encompasses the entire closure call.
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
let mut x = &mut v;
for _ in 0..3 {
borrow(&*v); //~ ERROR cannot borrow
}
*x = box 5;
*x = Box::new(5);
}
fn loop_aliased_mut() {
// In this instance, the borrow ends right after each assignment to _x
let mut v: Box<_> = box 3;
let mut w: Box<_> = box 4;
let mut v: Box<_> = Box::new(3);
let mut w: Box<_> = Box::new(4);
let mut _x = &w;
loop {
borrow_mut(&mut *v); // OK
@ -45,8 +45,8 @@ fn loop_aliased_mut() {
fn while_aliased_mut() {
// In this instance, the borrow ends right after each assignment to _x
let mut v: Box<_> = box 3;
let mut w: Box<_> = box 4;
let mut v: Box<_> = Box::new(3);
let mut w: Box<_> = Box::new(4);
let mut _x = &w;
while cond() {
borrow_mut(&mut *v); // OK
@ -58,8 +58,8 @@ fn while_aliased_mut() {
fn loop_aliased_mut_break() {
// In this instance, the borrow ends right after each assignment to _x
let mut v: Box<_> = box 3;
let mut w: Box<_> = box 4;
let mut v: Box<_> = Box::new(3);
let mut w: Box<_> = Box::new(4);
let mut _x = &w;
loop {
borrow_mut(&mut *v);
@ -72,8 +72,8 @@ fn loop_aliased_mut_break() {
fn while_aliased_mut_break() {
// In this instance, the borrow ends right after each assignment to _x
let mut v: Box<_> = box 3;
let mut w: Box<_> = box 4;
let mut v: Box<_> = Box::new(3);
let mut w: Box<_> = Box::new(4);
let mut _x = &w;
while cond() {
borrow_mut(&mut *v);
@ -84,8 +84,8 @@ fn while_aliased_mut_break() {
}
fn while_aliased_mut_cond(cond: bool, cond2: bool) {
let mut v: Box<_> = box 3;
let mut w: Box<_> = box 4;
let mut v: Box<_> = Box::new(3);
let mut w: Box<_> = Box::new(4);
let mut x = &mut w;
while cond {
**x += 1;

View file

@ -7,7 +7,7 @@ LL | for _ in 0..3 {
LL | borrow(&*v);
| ^^^ immutable borrow occurs here
LL | }
LL | *x = box 5;
LL | *x = Box::new(5);
| -- mutable borrow later used here
error[E0502]: cannot borrow `*v` as immutable because it is also borrowed as mutable

View file

@ -4,7 +4,7 @@
// either genuine or would require more advanced changes. The latter
// cases are noted.
#![feature(box_syntax)]
fn borrow(_v: &isize) {}
fn borrow_mut(_v: &mut isize) {}
@ -13,13 +13,13 @@ fn for_func<F>(_f: F) where F: FnOnce() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<isize>) {
*v = box (**v + 1);
*v = Box::new(**v + 1);
}
fn pre_freeze() {
// In this instance, the freeze starts before the mut borrow.
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
let _w = &v;
borrow_mut(&mut *v); //~ ERROR cannot borrow
_w.use_ref();
@ -28,7 +28,7 @@ fn pre_freeze() {
fn post_freeze() {
// In this instance, the const alias starts after the borrow.
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
borrow_mut(&mut *v);
let _w = &v;
}

View file

@ -1,5 +1,3 @@
#![feature(box_syntax)]
use std::thread;
@ -8,8 +6,10 @@ fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
f(v);
}
fn box_imm() {
let v: Box<_> = box 3;
let v: Box<_> = Box::new(3);
let w = &v;
thread::spawn(move|| {
//~^ ERROR cannot move out of `v` because it is borrowed
@ -19,7 +19,7 @@ fn box_imm() {
}
fn box_imm_explicit() {
let v: Box<_> = box 3;
let v: Box<_> = Box::new(3);
let w = &v;
thread::spawn(move|| {
//~^ ERROR cannot move

View file

@ -1,12 +1,12 @@
#![feature(box_syntax)]
fn take(_v: Box<isize>) {
}
fn box_imm() {
let v = box 3;
let v = Box::new(3);
let w = &v;
take(v); //~ ERROR cannot move out of `v` because it is borrowed
w.use_ref();

View file

@ -1,14 +1,14 @@
#![feature(box_syntax)]
fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
f(v);
}
fn box_imm() {
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
borrow(&*v,
|w| { //~ ERROR cannot borrow `v` as mutable
v = box 4;
v = Box::new(4);
assert_eq!(*v, 3);
assert_eq!(*w, 4);
})

View file

@ -7,7 +7,7 @@ LL | borrow(&*v,
| immutable borrow later used by call
LL | |w| {
| ^^^ mutable borrow occurs here
LL | v = box 4;
LL | v = Box::new(4);
| - second borrow occurs due to use of `v` in closure
error: aborting due to previous error

View file

@ -1,5 +1,5 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
use std::ops::Add;
@ -12,12 +12,12 @@ impl Add for Foo {
fn add(self, f: Foo) -> Foo {
let Foo(box i) = self;
let Foo(box j) = f;
Foo(box (i + j))
Foo(Box::new(i + j))
}
}
fn main() {
let x = Foo(box 3);
let x = Foo(Box::new(3));
let _y = {x} + x.clone(); // the `{x}` forces a move to occur
//~^ ERROR borrow of moved value: `x`
}

View file

@ -1,7 +1,7 @@
error[E0382]: borrow of moved value: `x`
--> $DIR/borrowck-loan-in-overloaded-op.rs:21:20
|
LL | let x = Foo(box 3);
LL | let x = Foo(Box::new(3));
| - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait
LL | let _y = {x} + x.clone(); // the `{x}` forces a move to occur
| - ^ value borrowed here after move

View file

@ -6,9 +6,7 @@
// Check that we do not ICE when compiling this
// macro, which reuses the expression `$id`
#![feature(box_patterns)]
#![feature(box_syntax)]
struct Foo {
a: isize
@ -23,7 +21,7 @@ impl Foo {
macro_rules! declare {
($id:expr, $rest:expr) => ({
self.check_id($id);
box Bar::Bar2($id, $rest)
Box::new(Bar::Bar2($id, $rest))
})
}
match s {

View file

@ -1,8 +1,7 @@
// run-pass
#![feature(box_syntax)]
pub fn main() {
let bar: Box<_> = box 3;
let bar: Box<_> = Box::new(3);
let h = || -> isize { *bar };
assert_eq!(h(), 3);
}

View file

@ -1,10 +1,10 @@
#![feature(box_syntax,unboxed_closures)]
#![feature(unboxed_closures)]
fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f }
fn to_fn_once<A,F:FnOnce<A>>(f: F) -> F { f }
pub fn main() {
let bar: Box<_> = box 3;
let bar: Box<_> = Box::new(3);
let _g = to_fn_mut(|| {
let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of
});

View file

@ -1,7 +1,7 @@
error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure
--> $DIR/borrowck-move-by-capture.rs:9:29
|
LL | let bar: Box<_> = box 3;
LL | let bar: Box<_> = Box::new(3);
| --- captured outer variable
LL | let _g = to_fn_mut(|| {
| ________________________-

View file

@ -1,14 +1,14 @@
#![feature(box_syntax)]
enum Foo {
Foo1(Box<u32>, Box<u32>),
Foo2(Box<u32>),
Foo3,
}
fn blah() {
let f = &Foo::Foo1(box 1, box 2);
match *f { //~ ERROR cannot move out of
let f = &Foo::Foo1(Box::new(1), Box::new(2));
match *f { //~ ERROR cannot move out of
Foo::Foo1(num1,
num2) => (),
Foo::Foo2(num) => (),
@ -42,8 +42,8 @@ struct A {
fn free<T>(_: T) {}
fn blah2() {
let a = &A { a: box 1 };
match a.a { //~ ERROR cannot move out of
let a = &A { a: Box::new(1) };
match a.a { //~ ERROR cannot move out of
n => {
free(n)
}

View file

@ -3,10 +3,10 @@
#![feature(box_syntax)]
fn main() {
let a: Box<Box<_>> = box box 2;
let a: Box<Box<_>> = Box::new(Box::new(2));
let b = &a;
let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed

View file

@ -1,11 +1,11 @@
#![feature(box_syntax)]
fn call_f<F:FnOnce() -> isize>(f: F) -> isize {
f()
}
fn main() {
let t: Box<_> = box 3;
let t: Box<_> = Box::new(3);
call_f(move|| { *t + 1 });
call_f(move|| { *t + 1 }); //~ ERROR use of moved value

View file

@ -1,7 +1,7 @@
error[E0382]: use of moved value: `t`
--> $DIR/borrowck-move-moved-value-into-closure.rs:11:12
|
LL | let t: Box<_> = box 3;
LL | let t: Box<_> = Box::new(3);
| - move occurs because `t` has type `Box<isize>`, which does not implement the `Copy` trait
LL |
LL | call_f(move|| { *t + 1 });

View file

@ -1,7 +1,7 @@
// Tests that the borrow checker checks all components of a path when moving
// out.
#![feature(box_syntax)]
struct S {
x : Box<isize>
@ -10,7 +10,7 @@ struct S {
fn f<T>(_: T) {}
fn main() {
let a : S = S { x : box 1 };
let a : S = S { x : Box::new(1) };
let pb = &a;
let S { x: ax } = a; //~ ERROR cannot move out
f(pb);

View file

@ -1,13 +1,13 @@
#![feature(box_syntax)]
use std::thread;
fn borrow<T>(_: &T) { }
fn different_vars_after_borrows() {
let x1: Box<_> = box 1;
let x1: Box<_> = Box::new(1);
let p1 = &x1;
let x2: Box<_> = box 2;
let x2: Box<_> = Box::new(2);
let p2 = &x2;
thread::spawn(move|| {
//~^ ERROR cannot move out of `x1` because it is borrowed
@ -20,9 +20,9 @@ fn different_vars_after_borrows() {
}
fn different_vars_after_moves() {
let x1: Box<_> = box 1;
let x1: Box<_> = Box::new(1);
drop(x1);
let x2: Box<_> = box 2;
let x2: Box<_> = Box::new(2);
drop(x2);
thread::spawn(move|| {
//~^ ERROR use of moved value: `x1`
@ -33,7 +33,7 @@ fn different_vars_after_moves() {
}
fn same_var_after_borrow() {
let x: Box<_> = box 1;
let x: Box<_> = Box::new(1);
let p = &x;
thread::spawn(move|| {
//~^ ERROR cannot move out of `x` because it is borrowed
@ -44,7 +44,7 @@ fn same_var_after_borrow() {
}
fn same_var_after_move() {
let x: Box<_> = box 1;
let x: Box<_> = Box::new(1);
drop(x);
thread::spawn(move|| {
//~^ ERROR use of moved value: `x`

View file

@ -30,7 +30,7 @@ LL | borrow(&*p2);
error[E0382]: use of moved value: `x1`
--> $DIR/borrowck-multiple-captures.rs:27:19
|
LL | let x1: Box<_> = box 1;
LL | let x1: Box<_> = Box::new(1);
| -- move occurs because `x1` has type `Box<i32>`, which does not implement the `Copy` trait
LL | drop(x1);
| -- value moved here
@ -44,7 +44,7 @@ LL | drop(x1);
error[E0382]: use of moved value: `x2`
--> $DIR/borrowck-multiple-captures.rs:27:19
|
LL | let x2: Box<_> = box 2;
LL | let x2: Box<_> = Box::new(2);
| -- move occurs because `x2` has type `Box<i32>`, which does not implement the `Copy` trait
LL | drop(x2);
| -- value moved here
@ -91,7 +91,7 @@ LL | drop(x);
error[E0382]: use of moved value: `x`
--> $DIR/borrowck-multiple-captures.rs:49:19
|
LL | let x: Box<_> = box 1;
LL | let x: Box<_> = Box::new(1);
| - move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
LL | drop(x);
| - value moved here

View file

@ -1,5 +1,4 @@
// run-pass
#![feature(box_syntax)]
use std::mem::swap;
@ -20,7 +19,7 @@ fn iter_ints<F>(x: &Ints, mut f: F) -> bool where F: FnMut(&isize) -> bool {
}
pub fn main() {
let mut ints: Box<_> = box Ints {sum: box 0, values: Vec::new()};
let mut ints: Box<_> = Box::new(Ints {sum: Box::new(0), values: Vec::new()});
add_int(&mut *ints, 22);
add_int(&mut *ints, 44);

View file

@ -1,5 +1,3 @@
#![feature(box_syntax)]
struct Node_ {
a: Box<Cycle>
}
@ -8,8 +6,10 @@ enum Cycle {
Node(Node_),
Empty,
}
fn main() {
let mut x: Box<_> = box Cycle::Node(Node_ {a: box Cycle::Empty});
let mut x: Box<_> = Box::new(Cycle::Node(Node_ {a: Box::new(Cycle::Empty)}));
// Create a cycle!
match *x {
Cycle::Node(ref mut y) => {

View file

@ -1,5 +1,3 @@
#![feature(box_syntax)]
use std::ops::Index;
struct MyVec<T> {
@ -14,8 +12,10 @@ impl<T> Index<usize> for MyVec<T> {
}
}
fn main() {
let v = MyVec::<Box<_>> { data: vec![box 1, box 2, box 3] };
let v = MyVec::<Box<_>> { data: vec![Box::new(1), Box::new(2), Box::new(3)] };
let good = &v[0]; // Shouldn't fail here
let bad = v[0];
//~^ ERROR cannot move out of index of `MyVec<Box<i32>>`

View file

@ -1,17 +1,17 @@
#![feature(box_syntax)]
fn borrow(_v: &isize) {}
fn local() {
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
borrow(&*v);
}
fn local_rec() {
struct F { f: Box<isize> }
let mut v = F {f: box 3};
let mut v = F {f: Box::new(3)};
borrow(&*v.f);
}
@ -19,35 +19,35 @@ fn local_recs() {
struct F { f: G }
struct G { g: H }
struct H { h: Box<isize> }
let mut v = F {f: G {g: H {h: box 3}}};
let mut v = F {f: G {g: H {h: Box::new(3)}}};
borrow(&*v.f.g.h);
}
fn aliased_imm() {
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
let w = &v;
borrow(&*v);
w.use_ref();
}
fn aliased_mut() {
let mut v: Box<_> = box 3;
let mut v: Box<_> = Box::new(3);
let w = &mut v;
borrow(&*v); //~ ERROR cannot borrow `*v`
w.use_mut();
}
fn aliased_other() {
let mut v: Box<_> = box 3;
let mut w: Box<_> = box 4;
let mut v: Box<_> = Box::new(3);
let mut w: Box<_> = Box::new(4);
let x = &mut w;
borrow(&*v);
x.use_mut();
}
fn aliased_other_reassign() {
let mut v: Box<_> = box 3;
let mut w: Box<_> = box 4;
let mut v: Box<_> = Box::new(3);
let mut w: Box<_> = Box::new(4);
let mut x = &mut w;
x = &mut v;
borrow(&*v); //~ ERROR cannot borrow `*v`

View file

@ -1,41 +1,39 @@
// run-pass
// pretty-expanded FIXME #23616
#![feature(box_syntax)]
struct A { a: isize, b: Box<isize> }
fn field_copy_after_field_borrow() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let p = &mut x.b;
drop(x.a);
**p = 3;
}
fn fu_field_copy_after_field_borrow() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let p = &mut x.b;
let y = A { b: box 3, .. x };
let y = A { b: Box::new(3), .. x };
drop(y);
**p = 4;
}
fn field_deref_after_field_borrow() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let p = &mut x.a;
drop(*x.b);
*p = 3;
}
fn field_move_after_field_borrow() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let p = &mut x.a;
drop(x.b);
*p = 3;
}
fn fu_field_move_after_field_borrow() {
let mut x = A { a: 1, b: box 2 };
let mut x = A { a: 1, b: Box::new(2) };
let p = &mut x.a;
let y = A { a: 3, .. x };
drop(y);

View file

@ -1,10 +1,10 @@
#![feature(box_syntax)]
#[derive(Copy, Clone)]
struct A { a: isize, b: isize }
struct B { a: isize, b: Box<isize> }
fn var_copy_after_var_borrow() {
let mut x: isize = 1;
let p = &mut x;
@ -50,21 +50,21 @@ fn fu_field_copy_after_field_borrow() {
}
fn var_deref_after_var_borrow() {
let mut x: Box<isize> = box 1;
let mut x: Box<isize> = Box::new(1);
let p = &mut x;
drop(*x); //~ ERROR cannot use `*x` because it was mutably borrowed
**p = 2;
}
fn field_deref_after_var_borrow() {
let mut x = B { a: 1, b: box 2 };
let mut x = B { a: 1, b: Box::new(2) };
let p = &mut x;
drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed
p.a = 3;
}
fn field_deref_after_field_borrow() {
let mut x = B { a: 1, b: box 2 };
let mut x = B { a: 1, b: Box::new(2) };
let p = &mut x.b;
drop(*x.b); //~ ERROR cannot use `*x.b` because it was mutably borrowed
**p = 3;

View file

@ -1,12 +1,12 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
fn a() {
let mut vec = [box 1, box 2, box 3];
let mut vec = [Box::new(1), Box::new(2), Box::new(3)];
match vec {
[box ref _a, _, _] => {
//~^ NOTE borrow of `vec[_]` occurs here
vec[0] = box 4; //~ ERROR cannot assign
vec[0] = Box::new(4); //~ ERROR cannot assign
//~^ NOTE assignment to borrowed `vec[_]` occurs here
_a.use_ref();
//~^ NOTE borrow later used here
@ -15,12 +15,12 @@ fn a() {
}
fn b() {
let mut vec = vec![box 1, box 2, box 3];
let mut vec = vec![Box::new(1), Box::new(2), Box::new(3)];
let vec: &mut [Box<isize>] = &mut vec;
match vec {
&mut [ref _b @ ..] => {
//~^ borrow of `vec[_]` occurs here
vec[0] = box 4; //~ ERROR cannot assign
vec[0] = Box::new(4); //~ ERROR cannot assign
//~^ NOTE assignment to borrowed `vec[_]` occurs here
_b.use_ref();
//~^ NOTE borrow later used here
@ -29,7 +29,7 @@ fn b() {
}
fn c() {
let mut vec = vec![box 1, box 2, box 3];
let mut vec = vec![Box::new(1), Box::new(2), Box::new(3)];
let vec: &mut [Box<isize>] = &mut vec;
match vec {
//~^ ERROR cannot move out
@ -50,7 +50,7 @@ fn c() {
}
fn d() {
let mut vec = vec![box 1, box 2, box 3];
let mut vec = vec![Box::new(1), Box::new(2), Box::new(3)];
let vec: &mut [Box<isize>] = &mut vec;
match vec {
//~^ ERROR cannot move out
@ -69,7 +69,7 @@ fn d() {
}
fn e() {
let mut vec = vec![box 1, box 2, box 3];
let mut vec = vec![Box::new(1), Box::new(2), Box::new(3)];
let vec: &mut [Box<isize>] = &mut vec;
match vec {
//~^ ERROR cannot move out

Some files were not shown because too many files have changed in this diff Show more