diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 75160476d71..630ca837daa 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -157,7 +157,7 @@ impl Default for Box { #[stable(feature = "rust1", since = "1.0.0")] impl Default for Box<[T]> { #[stable(feature = "rust1", since = "1.0.0")] - fn default() -> Box<[T]> { box [] } + fn default() -> Box<[T]> { Box::<[T; 0]>::new([]) } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcoretest/hash/mod.rs b/src/libcoretest/hash/mod.rs index 9b6af182f72..da96680d84b 100644 --- a/src/libcoretest/hash/mod.rs +++ b/src/libcoretest/hash/mod.rs @@ -64,7 +64,8 @@ fn test_writer_hasher() { //assert_eq!(hasher.hash(& s), 97 + 0xFF); let cs: &[u8] = &[1u8, 2u8, 3u8]; assert_eq!(hash(& cs), 9); - let cs: Box<[u8]> = box [1u8, 2u8, 3u8]; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let cs: Box<[u8]> = Box::new([1u8, 2u8, 3u8]); assert_eq!(hash(& cs), 9); // FIXME (#18248) Add tests for hashing Rc and Rc<[T]> diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index abf88583c03..b1b10b582e5 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -404,7 +404,8 @@ fn test_collect() { #[test] fn test_all() { - let v: Box<[int]> = box [1, 2, 3, 4, 5]; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let v: Box<[int]> = Box::new([1, 2, 3, 4, 5]); assert!(v.iter().all(|&x| x < 10)); assert!(!v.iter().all(|&x| x % 2 == 0)); assert!(!v.iter().all(|&x| x > 100)); @@ -413,7 +414,8 @@ fn test_all() { #[test] fn test_any() { - let v: Box<[int]> = box [1, 2, 3, 4, 5]; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let v: Box<[int]> = Box::new([1, 2, 3, 4, 5]); assert!(v.iter().any(|&x| x < 10)); assert!(v.iter().any(|&x| x % 2 == 0)); assert!(!v.iter().any(|&x| x > 100)); @@ -581,8 +583,9 @@ fn test_rposition() { #[test] #[should_fail] fn test_rposition_panic() { - let v = [(box 0, box 0), (box 0, box 0), - (box 0, box 0), (box 0, box 0)]; + let v: [(Box<_>, Box<_>); 4] = + [(box 0, box 0), (box 0, box 0), + (box 0, box 0), (box 0, box 0)]; let mut i = 0; v.iter().rposition(|_elt| { if i == 2 { diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 9291f175777..ae43738d471 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -79,7 +79,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt, None => {} } let expr_id = match csearch::maybe_get_item_ast(tcx, enum_def, - box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { + Box::new(|a, b, c, d| astencode::decode_inlined_item(a, b, c, d))) { csearch::FoundAst::Found(&ast::IIItem(ref item)) => match item.node { ast::ItemEnum(ast::EnumDef { ref variants }, _) => { // NOTE this doesn't do the right thing, it compares inlined @@ -119,7 +119,7 @@ pub fn lookup_const_by_id<'a>(tcx: &'a ty::ctxt, def_id: ast::DefId) None => {} } let expr_id = match csearch::maybe_get_item_ast(tcx, def_id, - box |a, b, c, d| astencode::decode_inlined_item(a, b, c, d)) { + Box::new(|a, b, c, d| astencode::decode_inlined_item(a, b, c, d))) { csearch::FoundAst::Found(&ast::IIItem(ref item)) => match item.node { ast::ItemConst(_, ref const_expr) => Some(const_expr.id), _ => None diff --git a/src/librustc/plugin/registry.rs b/src/librustc/plugin/registry.rs index 12634204f8b..6f98b79e782 100644 --- a/src/librustc/plugin/registry.rs +++ b/src/librustc/plugin/registry.rs @@ -99,7 +99,7 @@ impl<'a> Registry<'a> { /// It builds for you a `NormalTT` that calls `expander`, /// and also takes care of interning the macro's name. pub fn register_macro(&mut self, name: &str, expander: MacroExpanderFn) { - self.register_syntax_extension(token::intern(name), NormalTT(box expander, None)); + self.register_syntax_extension(token::intern(name), NormalTT(Box::new(expander), None)); } /// Register a compiler lint pass. diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 2c92f11c4e7..13f882bc363 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2969,7 +2969,7 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec { } let encode_inlined_item: encoder::EncodeInlinedItem = - box |ecx, rbml_w, ii| astencode::encode_inlined_item(ecx, rbml_w, ii); + Box::new(|ecx, rbml_w, ii| astencode::encode_inlined_item(ecx, rbml_w, ii)); let encode_parms = crate_ctxt_to_encode_parms(cx, encode_inlined_item); let metadata = encoder::encode_metadata(encode_parms, krate); diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index 56fda20e0e8..14f92334073 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -40,7 +40,7 @@ fn instantiate_inline(ccx: &CrateContext, fn_id: ast::DefId) let csearch_result = csearch::maybe_get_item_ast( ccx.tcx(), fn_id, - box |a,b,c,d| astencode::decode_inlined_item(a, b, c, d)); + Box::new(|a,b,c,d| astencode::decode_inlined_item(a, b, c, d))); let inline_def = match csearch_result { csearch::FoundAst::NotFound => { diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index f9495af79c5..f31dbf5138b 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -152,12 +152,12 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, &closure_ty.sig).0; fcx.record_deferred_call_resolution( def_id, - box CallResolution {call_expr: call_expr, - callee_expr: callee_expr, - adjusted_ty: adjusted_ty, - autoderefref: autoderefref, - fn_sig: fn_sig.clone(), - closure_def_id: def_id}); + Box::new(CallResolution {call_expr: call_expr, + callee_expr: callee_expr, + adjusted_ty: adjusted_ty, + autoderefref: autoderefref, + fn_sig: fn_sig.clone(), + closure_def_id: def_id})); return Some(CallStep::DeferredClosure(fn_sig)); } } diff --git a/src/libstd/old_io/stdio.rs b/src/libstd/old_io/stdio.rs index a5df21749e2..85bf4908f83 100644 --- a/src/libstd/old_io/stdio.rs +++ b/src/libstd/old_io/stdio.rs @@ -547,8 +547,9 @@ mod tests { let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let _t = thread::spawn(move|| { - set_stdout(box w); + set_stdout(Box::new(w)); println!("hello!"); }); assert_eq!(r.read_to_string().unwrap(), "hello!\n"); @@ -560,8 +561,9 @@ mod tests { let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. let _t = thread::spawn(move || -> () { - set_stderr(box w); + set_stderr(Box::new(w)); panic!("my special message"); }); let s = r.read_to_string().unwrap(); diff --git a/src/libstd/old_io/timer.rs b/src/libstd/old_io/timer.rs index 1f2ef50fcae..de5f2141095 100644 --- a/src/libstd/old_io/timer.rs +++ b/src/libstd/old_io/timer.rs @@ -15,6 +15,7 @@ // FIXME: These functions take Durations but only pass ms to the backend impls. +use boxed::Box; use sync::mpsc::{Receiver, Sender, channel}; use time::Duration; use old_io::IoResult; @@ -143,7 +144,7 @@ impl Timer { let (tx, rx) = channel(); // Short-circuit the timer backend for 0 duration if in_ms_u64(duration) != 0 { - self.inner.oneshot(in_ms_u64(duration), box TimerCallback { tx: tx }); + self.inner.oneshot(in_ms_u64(duration), Box::new(TimerCallback { tx: tx })); } else { tx.send(()).unwrap(); } @@ -204,7 +205,7 @@ impl Timer { // not clear what use a 0ms period is anyway... let ms = if ms == 0 { 1 } else { ms }; let (tx, rx) = channel(); - self.inner.period(ms, box TimerCallback { tx: tx }); + self.inner.period(ms, Box::new(TimerCallback { tx: tx })); return rx } } diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index 4dda3ea8c99..ebb2a2e4827 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -166,7 +166,7 @@ fn rust_panic(cause: Box) -> ! { rtdebug!("begin_unwind()"); unsafe { - let exception = box Exception { + let exception: Box<_> = box Exception { uwe: uw::_Unwind_Exception { exception_class: rust_exception_class(), exception_cleanup: exception_cleanup, @@ -506,7 +506,7 @@ pub fn begin_unwind_fmt(msg: fmt::Arguments, file_line: &(&'static str, uint)) - let mut s = String::new(); let _ = write!(&mut s, "{}", msg); - begin_unwind_inner(box s, file_line) + begin_unwind_inner(Box::new(s), file_line) } /// This is the entry point of unwinding for panic!() and assert!(). @@ -521,7 +521,7 @@ pub fn begin_unwind(msg: M, file_line: &(&'static str, uint)) -> // panicking. // see below for why we do the `Any` coercion here. - begin_unwind_inner(box msg, file_line) + begin_unwind_inner(Box::new(msg), file_line) } /// The core of the unwinding. diff --git a/src/libstd/thunk.rs b/src/libstd/thunk.rs index 5bede984f13..a9cb05b368f 100644 --- a/src/libstd/thunk.rs +++ b/src/libstd/thunk.rs @@ -33,7 +33,7 @@ impl<'a,A,R> Thunk<'a,A,R> { where F : FnOnce(A) -> R, F : Send + 'a { Thunk { - invoke: box func + invoke: Box::::new(func) } } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index a6f4974502c..e094cbcac53 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -223,7 +223,7 @@ pub fn mk_span_handler(handler: Handler, cm: codemap::CodeMap) -> SpanHandler { pub fn default_handler(color_config: ColorConfig, registry: Option, can_emit_warnings: bool) -> Handler { - mk_handler(can_emit_warnings, box EmitterWriter::stderr(color_config, registry)) + mk_handler(can_emit_warnings, Box::new(EmitterWriter::stderr(color_config, registry))) } pub fn mk_handler(can_emit_warnings: bool, e: Box) -> Handler { @@ -352,11 +352,11 @@ impl EmitterWriter { if use_color { let dst = match term::stderr() { Some(t) => Terminal(t), - None => Raw(box stderr), + None => Raw(Box::new(stderr)), }; EmitterWriter { dst: dst, registry: registry } } else { - EmitterWriter { dst: Raw(box stderr), registry: registry } + EmitterWriter { dst: Raw(Box::new(stderr)), registry: registry } } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index e5d1fe2388c..ad5ca627a93 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -465,7 +465,7 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>) -> SyntaxEnv { // utility function to simplify creating NormalTT syntax extensions fn builtin_normal_expander(f: MacroExpanderFn) -> SyntaxExtension { - NormalTT(box f, None) + NormalTT(Box::new(f), None) } let mut syntax_expanders = SyntaxEnv::new(); @@ -489,9 +489,9 @@ fn initial_syntax_expander_table<'feat>(ecfg: &expand::ExpansionConfig<'feat>) builtin_normal_expander( ext::log_syntax::expand_syntax_ext)); syntax_expanders.insert(intern("derive"), - Decorator(box ext::deriving::expand_meta_derive)); + Decorator(Box::new(ext::deriving::expand_meta_derive))); syntax_expanders.insert(intern("deriving"), - Decorator(box ext::deriving::expand_deprecated_deriving)); + Decorator(Box::new(ext::deriving::expand_deprecated_deriving))); if ecfg.enable_quotes() { // Quasi-quoting expanders diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 5f460264216..f89f3ab55f3 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -40,9 +40,9 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt, args: Vec::new(), ret_ty: Self_, attributes: attrs, - combine_substructure: combine_substructure(box |c, s, sub| { + combine_substructure: combine_substructure(Box::new(|c, s, sub| { cs_clone("Clone", c, s, sub) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/cmp/eq.rs b/src/libsyntax/ext/deriving/cmp/eq.rs index 80ef882745f..c02af437b1c 100644 --- a/src/libsyntax/ext/deriving/cmp/eq.rs +++ b/src/libsyntax/ext/deriving/cmp/eq.rs @@ -40,7 +40,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, cx.expr_binary(span, ast::BiAnd, subexpr, eq) }, cx.expr_bool(span, true), - box |cx, span, _, _| cx.expr_bool(span, false), + Box::new(|cx, span, _, _| cx.expr_bool(span, false)), cx, span, substr) } fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P { @@ -57,7 +57,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, cx.expr_binary(span, ast::BiOr, subexpr, eq) }, cx.expr_bool(span, false), - box |cx, span, _, _| cx.expr_bool(span, true), + Box::new(|cx, span, _, _| cx.expr_bool(span, true)), cx, span, substr) } @@ -72,9 +72,9 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(path_local!(bool)), attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { $f(a, b, c) - }) + })) } } } } diff --git a/src/libsyntax/ext/deriving/cmp/ord.rs b/src/libsyntax/ext/deriving/cmp/ord.rs index be4a33002aa..b2b26548018 100644 --- a/src/libsyntax/ext/deriving/cmp/ord.rs +++ b/src/libsyntax/ext/deriving/cmp/ord.rs @@ -38,9 +38,9 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(path_local!(bool)), attributes: attrs, - combine_substructure: combine_substructure(box |cx, span, substr| { + combine_substructure: combine_substructure(Box::new(|cx, span, substr| { cs_op($op, $equal, cx, span, substr) - }) + })) } } } } @@ -61,9 +61,9 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, args: vec![borrowed_self()], ret_ty: ret_ty, attributes: attrs, - combine_substructure: combine_substructure(box |cx, span, substr| { + combine_substructure: combine_substructure(Box::new(|cx, span, substr| { cs_partial_cmp(cx, span, substr) - }) + })) }; let trait_def = TraitDef { @@ -175,13 +175,13 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span, cx.expr_block(cx.block(span, vec!(assign), Some(if_))) }, equals_expr.clone(), - box |cx, span, (self_args, tag_tuple), _non_self_args| { + Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") } else { some_ordering_collapsed(cx, span, PartialCmpOp, tag_tuple) } - }, + }), cx, span, substr) } @@ -223,7 +223,7 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, cx.expr_binary(span, ast::BiOr, cmp, and) }, cx.expr_bool(span, equal), - box |cx, span, (self_args, tag_tuple), _non_self_args| { + Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") } else { @@ -233,6 +233,6 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt, }; some_ordering_collapsed(cx, span, op, tag_tuple) } - }, + }), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/cmp/totaleq.rs b/src/libsyntax/ext/deriving/cmp/totaleq.rs index 31a754a1254..83164d242e8 100644 --- a/src/libsyntax/ext/deriving/cmp/totaleq.rs +++ b/src/libsyntax/ext/deriving/cmp/totaleq.rs @@ -32,7 +32,8 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, let block = cx.block(span, stmts, None); cx.expr_block(block) }, - box |cx, sp, _, _| cx.span_bug(sp, "non matching enums in derive(Eq)?"), + Box::new(|cx, sp, _, _| { + cx.span_bug(sp, "non matching enums in derive(Eq)?") }), cx, span, substr) @@ -57,9 +58,9 @@ pub fn expand_deriving_totaleq(cx: &mut ExtCtxt, args: vec!(), ret_ty: nil_ty(), attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { cs_total_eq_assert(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/cmp/totalord.rs b/src/libsyntax/ext/deriving/cmp/totalord.rs index 2f6f99bc1ee..1de955856e7 100644 --- a/src/libsyntax/ext/deriving/cmp/totalord.rs +++ b/src/libsyntax/ext/deriving/cmp/totalord.rs @@ -41,9 +41,9 @@ pub fn expand_deriving_totalord(cx: &mut ExtCtxt, args: vec!(borrowed_self()), ret_ty: Literal(path_std!(cx, core::cmp::Ordering)), attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { cs_cmp(a, b, c) - }), + })), } ), associated_types: Vec::new(), @@ -131,12 +131,12 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span, cx.expr_block(cx.block(span, vec!(assign), Some(if_))) }, cx.expr_path(equals_path.clone()), - box |cx, span, (self_args, tag_tuple), _non_self_args| { + Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derives(Ord)`") } else { ordering_collapsed(cx, span, tag_tuple) } - }, + }), cx, span, substr) } diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index f27bbc338e5..6ce68948e4b 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -82,9 +82,9 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt, true )), attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { decodable_substructure(a, b, c, krate) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index c10975a2d32..f9991a23354 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -40,9 +40,9 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt, args: Vec::new(), ret_ty: Self_, attributes: attrs, - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { default_substructure(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 17687534d75..d7961d7da00 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -158,9 +158,9 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt, true )), attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { encodable_substructure(a, b, c) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index 2149c7a7f77..da80c7a0e6d 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -45,9 +45,9 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt, args: vec!(Ptr(box Literal(arg), Borrowed(None, MutMutable))), ret_ty: nil_ty(), attributes: vec![], - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { hash_substructure(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/primitive.rs b/src/libsyntax/ext/deriving/primitive.rs index 3b96292323a..b2d0a9f6b51 100644 --- a/src/libsyntax/ext/deriving/primitive.rs +++ b/src/libsyntax/ext/deriving/primitive.rs @@ -45,9 +45,9 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, true)), // #[inline] liable to cause code-bloat attributes: attrs.clone(), - combine_substructure: combine_substructure(box |c, s, sub| { + combine_substructure: combine_substructure(Box::new(|c, s, sub| { cs_from("i64", c, s, sub) - }), + })), }, MethodDef { name: "from_u64", @@ -60,9 +60,9 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt, true)), // #[inline] liable to cause code-bloat attributes: attrs, - combine_substructure: combine_substructure(box |c, s, sub| { + combine_substructure: combine_substructure(Box::new(|c, s, sub| { cs_from("u64", c, s, sub) - }), + })), } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 029b6535108..8a764fded6f 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -55,9 +55,9 @@ pub fn expand_deriving_rand(cx: &mut ExtCtxt, ), ret_ty: Self_, attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { rand_substructure(a, b, c) - }) + })) } ), associated_types: Vec::new(), diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index 281f23f9e61..ce89c541fd4 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -46,9 +46,9 @@ pub fn expand_deriving_show(cx: &mut ExtCtxt, args: vec!(fmtr), ret_ty: Literal(path_std!(cx, core::fmt::Result)), attributes: Vec::new(), - combine_substructure: combine_substructure(box |a, b, c| { + combine_substructure: combine_substructure(Box::new(|a, b, c| { show_substructure(a, b, c) - }) + })) } ], associated_types: Vec::new(), diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index ce513bc91f5..0ac78209b6f 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -479,7 +479,7 @@ pub fn parse(sess: &ParseSess, } rdr.next_token(); } else /* bb_eis.len() == 1 */ { - let mut rust_parser = Parser::new(sess, cfg.clone(), box rdr.clone()); + let mut rust_parser = Parser::new(sess, cfg.clone(), Box::new(rdr.clone())); let mut ei = bb_eis.pop().unwrap(); match ei.top_elts.get_tt(ei.idx) { diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 67011ad21a6..db7db4b83ac 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -180,7 +180,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt, Some(named_matches), imported_from, rhs); - let mut p = Parser::new(cx.parse_sess(), cx.cfg(), box trncbr); + let mut p = Parser::new(cx.parse_sess(), cx.cfg(), Box::new(trncbr)); p.check_unknown_macro_variable(); // Let the context choose how to interpret the result. // Weird, but useful for X-macros. @@ -267,7 +267,7 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt, _ => cx.span_bug(def.span, "wrong-structured rhs") }; - let exp = box MacroRulesMacroExpander { + let exp: Box<_> = box MacroRulesMacroExpander { name: def.ident, imported_from: def.imported_from, lhses: lhses, diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index f5201d4a8bc..25f1f9b8480 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -30,7 +30,7 @@ impl fmt::Debug for OwnedSlice { impl OwnedSlice { pub fn empty() -> OwnedSlice { - OwnedSlice { data: box [] } + OwnedSlice { data: Box::new([]) } } #[inline(never)] diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 83d2bb0cc70..bbe1ddfd4cf 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1484,8 +1484,9 @@ mod test { use std::old_io::util; fn mk_sh() -> diagnostic::SpanHandler { - let emitter = diagnostic::EmitterWriter::new(box util::NullWriter, None); - let handler = diagnostic::mk_handler(true, box emitter); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let emitter = diagnostic::EmitterWriter::new(Box::new(util::NullWriter), None); + let handler = diagnostic::mk_handler(true, Box::new(emitter)); diagnostic::mk_span_handler(handler, CodeMap::new()) } diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 01bfbd3dbce..d9afc1df28e 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -36,10 +36,12 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_macro("identity", expand_identity); reg.register_syntax_extension( token::intern("into_foo"), - Modifier(box expand_into_foo)); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + Modifier(Box::new(expand_into_foo))); reg.register_syntax_extension( token::intern("into_multi_foo"), - MultiModifier(box expand_into_foo_multi)); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + MultiModifier(Box::new(expand_into_foo_multi))); } fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) diff --git a/src/test/auxiliary/plugin_args.rs b/src/test/auxiliary/plugin_args.rs index 1775bbf4af2..20c84c4ba5b 100644 --- a/src/test/auxiliary/plugin_args.rs +++ b/src/test/auxiliary/plugin_args.rs @@ -46,5 +46,6 @@ impl TTMacroExpander for Expander { pub fn plugin_registrar(reg: &mut Registry) { let args = reg.args().clone(); reg.register_syntax_extension(token::intern("plugin_args"), - NormalTT(box Expander { args: args, }, None)); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + NormalTT(Box::new(Expander { args: args, }), None)); } diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs index 9c10f01e027..8bbecfd48c6 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs @@ -16,9 +16,10 @@ extern crate collections; use std::collections::HashMap; fn main() { - let tmp; + let tmp: Box<_>; let mut buggy_map: HashMap = HashMap::new(); - buggy_map.insert(42, &*box 1); //~ ERROR borrowed value does not live long enough + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough // but it is ok if we use a temporary tmp = box 2; diff --git a/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs b/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs index 9ea5fbbdb1a..7626f354eb4 100644 --- a/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs +++ b/src/test/compile-fail/borrowck-call-is-borrow-issue-12224.rs @@ -11,7 +11,6 @@ // Ensure that invoking a closure counts as a unique immutable borrow #![feature(unboxed_closures)] -#![feature(box_syntax)] type Fn<'a> = Box; @@ -19,11 +18,12 @@ struct Test<'a> { f: Box } +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. fn call(mut f: F) where F: FnMut(Fn) { - f(box || { + f(Box::new(|| { //~^ ERROR: cannot borrow `f` as mutable more than once - f(box || {}) - }); + f((Box::new(|| {}))) + })); } fn test1() { @@ -58,11 +58,12 @@ fn test6() { fn test7() { fn foo(_: F) where F: FnMut(Box, isize) {} let mut f = |g: Box, b: isize| {}; - f(box |a| { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + f(Box::new(|a| { foo(f); //~^ ERROR cannot move `f` into closure because it is borrowed //~| ERROR cannot move out of captured outer variable in an `FnMut` closure - }, 3); + }), 3); } fn main() {} diff --git a/src/test/compile-fail/cross-borrow-trait.rs b/src/test/compile-fail/cross-borrow-trait.rs index 6bd21101a60..871f52cbebd 100644 --- a/src/test/compile-fail/cross-borrow-trait.rs +++ b/src/test/compile-fail/cross-borrow-trait.rs @@ -11,14 +11,13 @@ // Test that cross-borrowing (implicitly converting from `Box` to `&T`) is // forbidden when `T` is a trait. -#![feature(box_syntax)] - struct Foo; trait Trait { fn foo(&self) {} } impl Trait for Foo {} pub fn main() { - let x: Box = box Foo; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let x: Box = Box::new(Foo); let _y: &Trait = x; //~ ERROR mismatched types //~| expected `&Trait` //~| found `Box` diff --git a/src/test/compile-fail/dst-bad-assign-2.rs b/src/test/compile-fail/dst-bad-assign-2.rs index 7dbb8fc92e3..8441f3a99e1 100644 --- a/src/test/compile-fail/dst-bad-assign-2.rs +++ b/src/test/compile-fail/dst-bad-assign-2.rs @@ -10,8 +10,6 @@ // Forbid assignment into a dynamically sized type. -#![feature(box_syntax)] - struct Fat { f1: isize, f2: &'static str, @@ -43,7 +41,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box = box Bar1 {f: 36}; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let z: Box = Box::new(Bar1 {f: 36}); f5.ptr = *z; //~^ ERROR the trait `core::marker::Sized` is not implemented } diff --git a/src/test/compile-fail/dst-bad-assign.rs b/src/test/compile-fail/dst-bad-assign.rs index 152864b601c..d3029bc6a99 100644 --- a/src/test/compile-fail/dst-bad-assign.rs +++ b/src/test/compile-fail/dst-bad-assign.rs @@ -10,8 +10,6 @@ // Forbid assignment into a dynamically sized type. -#![feature(box_syntax)] - struct Fat { f1: isize, f2: &'static str, @@ -43,7 +41,8 @@ impl ToBar for Bar1 { pub fn main() { // Assignment. let f5: &mut Fat = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} }; - let z: Box = box Bar1 {f: 36}; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let z: Box = Box::new(Bar1 {f: 36}); f5.ptr = Bar1 {f: 36}; //~^ ERROR mismatched types //~| expected `ToBar` diff --git a/src/test/compile-fail/issue-10291.rs b/src/test/compile-fail/issue-10291.rs index 45f6e55914a..9711d760ae6 100644 --- a/src/test/compile-fail/issue-10291.rs +++ b/src/test/compile-fail/issue-10291.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - fn test<'x>(x: &'x isize) { - drop:: FnMut(&'z isize) -> &'z isize>>(box |z| { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + drop:: FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { x //~^ ERROR cannot infer an appropriate lifetime - }); + })); } fn main() {} diff --git a/src/test/compile-fail/issue-11515.rs b/src/test/compile-fail/issue-11515.rs index 4ff574e939d..f682d618ab6 100644 --- a/src/test/compile-fail/issue-11515.rs +++ b/src/test/compile-fail/issue-11515.rs @@ -15,6 +15,7 @@ struct Test { } fn main() { - let closure: Box = box || (); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let closure: Box = Box::new(|| ()); let test = box Test { func: closure }; //~ ERROR mismatched types } diff --git a/src/test/compile-fail/issue-17441.rs b/src/test/compile-fail/issue-17441.rs index 9f76f360f26..68ddef67188 100644 --- a/src/test/compile-fail/issue-17441.rs +++ b/src/test/compile-fail/issue-17441.rs @@ -8,18 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - fn main() { let _foo = &[1_usize, 2] as [usize]; //~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]` //~^^ HELP consider using an implicit coercion to `&[usize]` instead - let _bar = box 1_usize as std::fmt::Debug; + + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let _bar = Box::new(1_usize) as std::fmt::Debug; //~^ ERROR cast to unsized type: `Box` as `core::fmt::Debug` //~^^ HELP did you mean `Box`? + let _baz = 1_usize as std::fmt::Debug; //~^ ERROR cast to unsized type: `usize` as `core::fmt::Debug` //~^^ HELP consider using a box or reference as appropriate + let _quux = [1_usize, 2] as [usize]; //~^ ERROR cast to unsized type: `[usize; 2]` as `[usize]` //~^^ HELP consider using a box or reference as appropriate diff --git a/src/test/compile-fail/issue-17651.rs b/src/test/compile-fail/issue-17651.rs index 172f37af834..d6471ca018d 100644 --- a/src/test/compile-fail/issue-17651.rs +++ b/src/test/compile-fail/issue-17651.rs @@ -11,10 +11,8 @@ // Test that moves of unsized values within closures are caught // and rejected. -#![feature(box_syntax)] - fn main() { - (|| box *[0_usize].as_slice())(); - //~^ ERROR cannot move out of borrowed content - //~^^ ERROR cannot move a value of type [usize] + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + (|| Box::new(*[0_usize].as_slice()))(); + //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[usize]` } diff --git a/src/test/compile-fail/issue-18783.rs b/src/test/compile-fail/issue-18783.rs index 13908bda9d8..f6a3da81857 100644 --- a/src/test/compile-fail/issue-18783.rs +++ b/src/test/compile-fail/issue-18783.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - use std::cell::RefCell; +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + fn main() { let mut y = 1_usize; let c = RefCell::new(vec![]); - c.push(box || y = 0); - c.push(box || y = 0); + c.push(Box::new(|| y = 0)); + c.push(Box::new(|| y = 0)); //~^ ERROR cannot borrow `y` as mutable more than once at a time } @@ -24,8 +24,8 @@ fn ufcs() { let mut y = 1_usize; let c = RefCell::new(vec![]); - Push::push(&c, box || y = 0); - Push::push(&c, box || y = 0); + Push::push(&c, Box::new(|| y = 0)); + Push::push(&c, Box::new(|| y = 0)); //~^ ERROR cannot borrow `y` as mutable more than once at a time } diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs index 6e6c19a5bf6..085b4e76afb 100644 --- a/src/test/compile-fail/issue-3763.rs +++ b/src/test/compile-fail/issue-3763.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - mod my_mod { pub struct MyStruct { priv_field: isize @@ -26,10 +24,15 @@ fn main() { let my_struct = my_mod::MyStruct(); let _woohoo = (&my_struct).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private - let _woohoo = (box my_struct).priv_field; + + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let _woohoo = (Box::new(my_struct)).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private + (&my_struct).happyfun(); //~ ERROR method `happyfun` is private - (box my_struct).happyfun(); //~ ERROR method `happyfun` is private + + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + (Box::new(my_struct)).happyfun(); //~ ERROR method `happyfun` is private let nope = my_struct.priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private } diff --git a/src/test/compile-fail/issue-4335.rs b/src/test/compile-fail/issue-4335.rs index 85298e4c6e0..55a793f7480 100644 --- a/src/test/compile-fail/issue-4335.rs +++ b/src/test/compile-fail/issue-4335.rs @@ -9,12 +9,12 @@ // except according to those terms. #![feature(unboxed_closures)] -#![feature(box_syntax)] fn id(t: T) -> T { t } fn f<'r, T>(v: &'r T) -> Box T + 'r> { - id(box || *v) + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + id(Box::new(|| *v)) //~^ ERROR `v` does not live long enough //~| ERROR cannot move out of borrowed content } diff --git a/src/test/compile-fail/issue-5543.rs b/src/test/compile-fail/issue-5543.rs index 4d721ad7666..c27362eea3e 100644 --- a/src/test/compile-fail/issue-5543.rs +++ b/src/test/compile-fail/issue-5543.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - trait Foo { fn foo(&self) {} } impl Foo for u8 {} fn main() { - let r: Box = box 5; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let r: Box = Box::new(5); let _m: Box = r as Box; //~^ ERROR `core::marker::Sized` is not implemented for the type `Foo` } diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index 6e8719eeace..e298a0f62cd 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -26,6 +26,7 @@ impl Map for HashMap {} fn main() { let x: Box> = box HashMap::new(); let x: Box> = x; - let y: Box> = box x; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let y: Box> = Box::new(x); //~^ ERROR the trait `Map` is not implemented } diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index f410541f0b7..5af326b4298 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -12,7 +12,6 @@ // bound must be noncopyable. For details see // http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/ -#![feature(box_syntax)] #![feature(unboxed_closures)] struct R<'a> { @@ -41,7 +40,8 @@ fn innocent_looking_victim() { } fn conspirator(mut f: F) where F: FnMut(&mut R, bool) { - let mut r = R {c: box f}; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let mut r = R {c: Box::new(f)}; f(&mut r, false) //~ ERROR use of moved value } diff --git a/src/test/compile-fail/region-object-lifetime-in-coercion.rs b/src/test/compile-fail/region-object-lifetime-in-coercion.rs index 2da414befd8..1bb2bb5a154 100644 --- a/src/test/compile-fail/region-object-lifetime-in-coercion.rs +++ b/src/test/compile-fail/region-object-lifetime-in-coercion.rs @@ -11,32 +11,36 @@ // Test that attempts to implicitly coerce a value into an // object respect the lifetime bound on the object type. -#![feature(box_syntax)] - trait Foo : ::std::marker::MarkerTrait {} impl<'a> Foo for &'a [u8] {} +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + fn a(v: &[u8]) -> Box { - let x: Box = box v; //~ ERROR does not fulfill the required lifetime + let x: Box = Box::new(v); + //~^ ERROR cannot infer an appropriate lifetime due to conflicting x } fn b(v: &[u8]) -> Box { - box v //~ ERROR does not fulfill the required lifetime + Box::new(v) + //~^ ERROR cannot infer an appropriate lifetime due to conflicting } fn c(v: &[u8]) -> Box { // same as previous case due to RFC 599 - box v //~ ERROR does not fulfill the required lifetime + Box::new(v) + //~^ ERROR cannot infer an appropriate lifetime due to conflicting } fn d<'a,'b>(v: &'a [u8]) -> Box { - box v //~ ERROR does not fulfill the required lifetime + Box::new(v) + //~^ ERROR cannot infer an appropriate lifetime due to conflicting } fn e<'a:'b,'b>(v: &'a [u8]) -> Box { - box v // OK, thanks to 'a:'b + Box::new(v) // OK, thanks to 'a:'b } fn main() { } diff --git a/src/test/compile-fail/regions-close-associated-type-into-object.rs b/src/test/compile-fail/regions-close-associated-type-into-object.rs index 979c1e997d0..72a024e563c 100644 --- a/src/test/compile-fail/regions-close-associated-type-into-object.rs +++ b/src/test/compile-fail/regions-close-associated-type-into-object.rs @@ -10,6 +10,8 @@ #![feature(box_syntax)] +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + use std::marker::MarkerTrait; trait X : MarkerTrait {} @@ -24,48 +26,48 @@ trait Iter { fn bad1(v: T) -> Box { let item = v.into_item(); - box item //~ ERROR associated type `::Item` may not live long enough + Box::new(item) //~ ERROR associated type `::Item` may not live long enough } fn bad2(v: T) -> Box where Box : X { - let item = box v.into_item(); - box item //~ ERROR associated type `::Item` may not live long enough + let item: Box<_> = box v.into_item(); + Box::new(item) //~ ERROR associated type `::Item` may not live long enough } fn bad3<'a, T: Iter>(v: T) -> Box { let item = v.into_item(); - box item //~ ERROR associated type `::Item` may not live long enough + Box::new(item) //~ ERROR associated type `::Item` may not live long enough } fn bad4<'a, T: Iter>(v: T) -> Box where Box : X { - let item = box v.into_item(); - box item //~ ERROR associated type `::Item` may not live long enough + let item: Box<_> = box v.into_item(); + Box::new(item) //~ ERROR associated type `::Item` may not live long enough } fn ok1<'a, T: Iter>(v: T) -> Box where T::Item : 'a { let item = v.into_item(); - box item // OK, T::Item : 'a is declared + Box::new(item) // OK, T::Item : 'a is declared } fn ok2<'a, T: Iter>(v: &T, w: &'a T::Item) -> Box where T::Item : Clone { let item = Clone::clone(w); - box item // OK, T::Item : 'a is implied + Box::new(item) // OK, T::Item : 'a is implied } fn ok3<'a, T: Iter>(v: &'a T) -> Box where T::Item : Clone + 'a { let item = Clone::clone(v.as_item()); - box item // OK, T::Item : 'a was declared + Box::new(item) // OK, T::Item : 'a was declared } fn meh1<'a, T: Iter>(v: &'a T) -> Box @@ -78,7 +80,7 @@ fn meh1<'a, T: Iter>(v: &'a T) -> Box // T::Item`. But we're not that smart at present. let item = Clone::clone(v.as_item()); - box item //~ ERROR associated type `::Item` may not live + Box::new(item) //~ ERROR associated type `::Item` may not live } fn main() {} diff --git a/src/test/compile-fail/regions-close-param-into-object.rs b/src/test/compile-fail/regions-close-param-into-object.rs index 655ac6f66c9..eebf93bc893 100644 --- a/src/test/compile-fail/regions-close-param-into-object.rs +++ b/src/test/compile-fail/regions-close-param-into-object.rs @@ -8,32 +8,32 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. trait X { fn foo(&self) {} } fn p1(v: T) -> Box where T : X { - box v //~ ERROR parameter type `T` may not live long enough + Box::new(v) //~ ERROR parameter type `T` may not live long enough } fn p2(v: Box) -> Box where Box : X { - box v //~ ERROR parameter type `T` may not live long enough + Box::new(v) //~ ERROR parameter type `T` may not live long enough } fn p3<'a,T>(v: T) -> Box where T : X { - box v //~ ERROR parameter type `T` may not live long enough + Box::new(v) //~ ERROR parameter type `T` may not live long enough } fn p4<'a,T>(v: Box) -> Box where Box : X { - box v //~ ERROR parameter type `T` may not live long enough + Box::new(v) //~ ERROR parameter type `T` may not live long enough } fn main() {} diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs index 58386c319f8..f114a8bc7ce 100644 --- a/src/test/compile-fail/regions-nested-fns.rs +++ b/src/test/compile-fail/regions-nested-fns.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. fn ignore(t: T) {} @@ -16,17 +16,17 @@ fn nested<'x>(x: &'x isize) { let y = 3; let mut ay = &y; - ignore:: FnMut(&'z isize)>>(box |z| { + ignore:: FnMut(&'z isize)>>(Box::new(|z| { ay = x; //~ ERROR cannot infer ay = &y; ay = z; - }); + })); - ignore::< Box FnMut(&'z isize) -> &'z isize>>(box |z| { + ignore::< Box FnMut(&'z isize) -> &'z isize>>(Box::new(|z| { if false { return x; } //~ ERROR cannot infer an appropriate lifetime for automatic if false { return ay; } return z; - }); + })); } fn main() {} diff --git a/src/test/compile-fail/regions-proc-bound-capture.rs b/src/test/compile-fail/regions-proc-bound-capture.rs index cc33d112417..3c137133c98 100644 --- a/src/test/compile-fail/regions-proc-bound-capture.rs +++ b/src/test/compile-fail/regions-proc-bound-capture.rs @@ -8,17 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. fn borrowed_proc<'a>(x: &'a isize) -> Box(isize) + 'a> { // This is legal, because the region bound on `proc` // states that it captures `x`. - box move|| { *x } + Box::new(move|| { *x }) } fn static_proc(x: &isize) -> Box(isize) + 'static> { // This is illegal, because the region bound on `proc` is 'static. - box move|| { *x } //~ ERROR captured variable `x` does not outlive the enclosing closure + Box::new(move|| { *x }) //~ ERROR captured variable `x` does not outlive the enclosing closure } fn main() { } diff --git a/src/test/compile-fail/regions-steal-closure.rs b/src/test/compile-fail/regions-steal-closure.rs index c9b378d1df2..a30d8471a31 100644 --- a/src/test/compile-fail/regions-steal-closure.rs +++ b/src/test/compile-fail/regions-steal-closure.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] #![feature(unboxed_closures)] struct closure_box<'a> { @@ -22,7 +21,8 @@ fn box_it<'r>(x: Box) -> closure_box<'r> { fn main() { let mut cl_box = { let mut i = 3; - box_it(box || i += 1) //~ ERROR `i` does not live long enough + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + box_it(Box::new(|| i += 1)) //~ ERROR `i` does not live long enough }; cl_box.cl.call_mut(()); } diff --git a/src/test/compile-fail/trait-coercion-generic-bad.rs b/src/test/compile-fail/trait-coercion-generic-bad.rs index 1ddfc5b7ccd..b25af522b24 100644 --- a/src/test/compile-fail/trait-coercion-generic-bad.rs +++ b/src/test/compile-fail/trait-coercion-generic-bad.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - struct Struct { person: &'static str } @@ -25,7 +23,8 @@ impl Trait<&'static str> for Struct { } fn main() { - let s: Box> = box Struct { person: "Fred" }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let s: Box> = Box::new(Struct { person: "Fred" }); //~^ ERROR the trait `Trait` is not implemented for the type `Struct` s.f(1); } diff --git a/src/test/compile-fail/trait-coercion-generic-regions.rs b/src/test/compile-fail/trait-coercion-generic-regions.rs index 7b426a4c033..bbe256d1c8f 100644 --- a/src/test/compile-fail/trait-coercion-generic-regions.rs +++ b/src/test/compile-fail/trait-coercion-generic-regions.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - struct Struct { person: &'static str } @@ -27,6 +25,7 @@ impl Trait<&'static str> for Struct { fn main() { let person = "Fred".to_string(); let person: &str = &person; //~ ERROR `person` does not live long enough - let s: Box> = box Struct { person: person }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let s: Box> = Box::new(Struct { person: person }); } diff --git a/src/test/compile-fail/unboxed-closure-illegal-move.rs b/src/test/compile-fail/unboxed-closure-illegal-move.rs index 800126450c9..86e326f3c5a 100644 --- a/src/test/compile-fail/unboxed-closure-illegal-move.rs +++ b/src/test/compile-fail/unboxed-closure-illegal-move.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] #![feature(unboxed_closures)] // Tests that we can't move out of an unboxed closure environment @@ -19,31 +18,33 @@ fn to_fn>(f: F) -> F { f } fn to_fn_mut>(f: F) -> F { f } fn to_fn_once>(f: F) -> F { f } +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + fn main() { // By-ref cases { - let x = box 0_usize; + let x = Box::new(0_usize); let f = to_fn(|| drop(x)); //~ ERROR cannot move } { - let x = box 0_usize; + let x = Box::new(0_usize); let f = to_fn_mut(|| drop(x)); //~ ERROR cannot move } { - let x = box 0_usize; + let x = Box::new(0_usize); let f = to_fn_once(|| drop(x)); // OK -- FnOnce } // By-value cases { - let x = box 0_usize; + let x = Box::new(0_usize); let f = to_fn(move || drop(x)); //~ ERROR cannot move } { - let x = box 0_usize; + let x = Box::new(0_usize); let f = to_fn_mut(move || drop(x)); //~ ERROR cannot move } { - let x = box 0_usize; + let x = Box::new(0_usize); let f = to_fn_once(move || drop(x)); // this one is ok } } diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index 88535ee04fb..2ec10d08bb4 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - #[derive(Debug)] struct r { b: bool, @@ -20,7 +18,8 @@ impl Drop for r { } fn main() { - let i = box r { b: true }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let i = Box::new(r { b: true }); let _j = i.clone(); //~ ERROR not implement println!("{:?}", i); } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index 046337c33f0..86fe4da3429 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -8,15 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - use std::rc::Rc; fn f(__isize: T) { } fn main() { - let i = box Rc::new(100); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let i = Box::new(Rc::new(100)); f(i); //~^ ERROR `core::marker::Send` is not implemented } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index 91a41ad6a49..938abbf2c20 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -10,8 +10,6 @@ #![feature(unsafe_destructor)] -#![feature(box_syntax)] - use std::cell::Cell; #[derive(Debug)] @@ -36,8 +34,9 @@ fn clone(t: &T) -> T { t.clone() } fn main() { let i1 = &Cell::new(0); let i2 = &Cell::new(1); - let r1 = vec!(box r { i: i1 }); - let r2 = vec!(box r { i: i2 }); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let r1 = vec!(Box::new(r { i: i1 })); + let r2 = vec!(Box::new(r { i: i2 })); f(clone(&r1), clone(&r2)); //~^ ERROR the trait `core::clone::Clone` is not implemented for the type //~^^ ERROR the trait `core::clone::Clone` is not implemented for the type diff --git a/src/test/debuginfo/closure-in-generic-function.rs b/src/test/debuginfo/closure-in-generic-function.rs index b92f5de21b5..448e157a251 100644 --- a/src/test/debuginfo/closure-in-generic-function.rs +++ b/src/test/debuginfo/closure-in-generic-function.rs @@ -60,7 +60,7 @@ fn some_generic_fun(a: T1, b: T2) -> (T2, T1) { fn main() { some_generic_fun(0.5f64, 10); - some_generic_fun(&29, box 110); + some_generic_fun(&29, Box::new(110)); } fn zzz() { () } diff --git a/src/test/run-fail/panic-macro-any-wrapped.rs b/src/test/run-fail/panic-macro-any-wrapped.rs index 89e47bf46ab..4d0f7c29cb9 100644 --- a/src/test/run-fail/panic-macro-any-wrapped.rs +++ b/src/test/run-fail/panic-macro-any-wrapped.rs @@ -10,9 +10,6 @@ // error-pattern:panicked at 'Box' -#![allow(unknown_features)] -#![feature(box_syntax)] - fn main() { - panic!(box 612_i64); + panic!(Box::new(612_i64)); } diff --git a/src/test/run-fail/unique-panic.rs b/src/test/run-fail/unique-panic.rs index 9f643c09795..83b2bb91f00 100644 --- a/src/test/run-fail/unique-panic.rs +++ b/src/test/run-fail/unique-panic.rs @@ -10,7 +10,4 @@ // error-pattern: panic -#![allow(unknown_features)] -#![feature(box_syntax)] - -fn main() { box panic!(); } +fn main() { Box::new(panic!()); } diff --git a/src/test/run-fail/unwind-unique.rs b/src/test/run-fail/unwind-unique.rs index e1176b1bcdb..f4ba789d6bf 100644 --- a/src/test/run-fail/unwind-unique.rs +++ b/src/test/run-fail/unwind-unique.rs @@ -10,14 +10,11 @@ // error-pattern:fail -#![allow(unknown_features)] -#![feature(box_syntax)] - fn failfn() { panic!(); } fn main() { - box 0; + Box::new(0); failfn(); } diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 38381da3670..7d94f4c7b17 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -245,9 +245,10 @@ fn hello((z, a) : (u32, String), ex: X) { let x = 32.0f32; let _ = (x + ((x * x) + 1.0).sqrt()).ln(); - let s: Box = box some_fields {field1: 43}; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let s: Box = Box::new(some_fields {field1: 43}); let s2: Box = box some_fields {field1: 43}; - let s3 = box nofields; + let s3: Box<_> = box nofields; s.Method(43); s3.Method(43); @@ -282,7 +283,7 @@ pub struct blah { } fn main() { // foo - let s = box some_fields {field1: 43}; + let s: Box<_> = box some_fields {field1: 43}; hello((43, "a".to_string()), *s); sub::sub2::hello(); sub2::sub3::hello(); diff --git a/src/test/run-pass-valgrind/dst-dtor-1.rs b/src/test/run-pass-valgrind/dst-dtor-1.rs index c49a684de94..d051b7b491b 100644 --- a/src/test/run-pass-valgrind/dst-dtor-1.rs +++ b/src/test/run-pass-valgrind/dst-dtor-1.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - static mut DROP_RAN: bool = false; struct Foo; @@ -28,7 +26,8 @@ struct Fat { pub fn main() { { - let _x: Box> = box Fat { f: Foo }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let _x: Box> = Box::>::new(Fat { f: Foo }); } unsafe { assert!(DROP_RAN); diff --git a/src/test/run-pass-valgrind/dst-dtor-2.rs b/src/test/run-pass-valgrind/dst-dtor-2.rs index 2c7b89d680a..2cb5f77fdc3 100644 --- a/src/test/run-pass-valgrind/dst-dtor-2.rs +++ b/src/test/run-pass-valgrind/dst-dtor-2.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] - static mut DROP_RAN: int = 0; struct Foo; @@ -25,7 +23,8 @@ struct Fat { pub fn main() { { - let _x: Box> = box Fat { f: [Foo, Foo, Foo] }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let _x: Box> = Box::>::new(Fat { f: [Foo, Foo, Foo] }); } unsafe { assert!(DROP_RAN == 3); diff --git a/src/test/run-pass/assert-eq-macro-success.rs b/src/test/run-pass/assert-eq-macro-success.rs index e55a2d39cbf..c52e04322e9 100644 --- a/src/test/run-pass/assert-eq-macro-success.rs +++ b/src/test/run-pass/assert-eq-macro-success.rs @@ -8,15 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - #[derive(PartialEq, Debug)] struct Point { x : int } pub fn main() { assert_eq!(14,14); assert_eq!("abc".to_string(),"abc".to_string()); - assert_eq!(box Point{x:34},box Point{x:34}); + assert_eq!(Box::new(Point{x:34}),Box::new(Point{x:34})); assert_eq!(&Point{x:34},&Point{x:34}); } diff --git a/src/test/run-pass/associated-types-doubleendediterator-object.rs b/src/test/run-pass/associated-types-doubleendediterator-object.rs index 7365e052171..941e9a84538 100644 --- a/src/test/run-pass/associated-types-doubleendediterator-object.rs +++ b/src/test/run-pass/associated-types-doubleendediterator-object.rs @@ -25,6 +25,7 @@ fn pairwise_sub(mut t: Box>) -> int { fn main() { let v = vec!(1, 2, 3, 4, 5, 6); - let r = pairwise_sub(box v.into_iter()); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let r = pairwise_sub(Box::new(v.into_iter())); assert_eq!(r, 9); } diff --git a/src/test/run-pass/coerce-expect-unsized.rs b/src/test/run-pass/coerce-expect-unsized.rs index ee19d9e69b3..8a9325aecb1 100644 --- a/src/test/run-pass/coerce-expect-unsized.rs +++ b/src/test/run-pass/coerce-expect-unsized.rs @@ -17,12 +17,21 @@ use std::fmt::Debug; // rvalue expressions to be unsized. See #20169 for more information. pub fn main() { - let _: Box<[int]> = box { [1, 2, 3] }; - let _: Box<[int]> = box if true { [1, 2, 3] } else { [1, 3, 4] }; - let _: Box<[int]> = box match true { true => [1, 2, 3], false => [1, 3, 4] }; - let _: Box _> = box { |x| (x as u8) }; - let _: Box = box if true { false } else { true }; - let _: Box = box match true { true => 'a', false => 'b' }; + // FIXME #22405: We cannot infer the type `Box<[int; k]>` for + // the r-value expression from the context `Box<[int]>`, and + // therefore the `box EXPR` desugaring breaks down. + // + // One could reasonably claim that the `box EXPR` desugaring is + // effectively regressing half of Issue #20169. Hopefully we will + // eventually fix that, at which point the `Box::new` calls below + // should be replaced wth uses of `box`. + + let _: Box<[int]> = Box::new({ [1, 2, 3] }); + let _: Box<[int]> = Box::new(if true { [1, 2, 3] } else { [1, 3, 4] }); + let _: Box<[int]> = Box::new(match true { true => [1, 2, 3], false => [1, 3, 4] }); + let _: Box _> = Box::new({ |x| (x as u8) }); + let _: Box = Box::new(if true { false } else { true }); + let _: Box = Box::new(match true { true => 'a', false => 'b' }); let _: &[int] = &{ [1, 2, 3] }; let _: &[int] = &if true { [1, 2, 3] } else { [1, 3, 4] }; @@ -36,6 +45,6 @@ pub fn main() { let _: Vec _>> = vec![ Box::new(|x| (x as u8)), - box |x| (x as i16 as u8), + Box::new(|x| (x as i16 as u8)), ]; } diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 93a7d3e1c36..3a64f53dbb0 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -11,9 +11,6 @@ // Make sure const bounds work on things, and test that a few types // are const. -#![allow(unknown_features)] -#![feature(box_syntax)] - fn foo(x: T) -> T { x } struct F { field: int } @@ -25,5 +22,5 @@ pub fn main() { foo(F{field: 42}); foo((1, 2_usize)); foo(@1);*/ - foo(box 1); + foo(Box::new(1)); } diff --git a/src/test/run-pass/deriving-default-box.rs b/src/test/run-pass/deriving-default-box.rs index b00ceb6ed22..4d157f64fb9 100644 --- a/src/test/run-pass/deriving-default-box.rs +++ b/src/test/run-pass/deriving-default-box.rs @@ -20,6 +20,7 @@ struct A { pub fn main() { let a: A = Default::default(); - let b: Box<[_]> = box []; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let b: Box<[_]> = Box::<[bool; 0]>::new([]); assert_eq!(a.foo, b); } diff --git a/src/test/run-pass/deriving-encodable-decodable-box.rs b/src/test/run-pass/deriving-encodable-decodable-box.rs index 838d05cf0d5..454156b4c9e 100644 --- a/src/test/run-pass/deriving-encodable-decodable-box.rs +++ b/src/test/run-pass/deriving-encodable-decodable-box.rs @@ -23,7 +23,8 @@ struct A { } fn main() { - let obj = A { foo: box [true, false] }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let obj = A { foo: Box::new([true, false]) }; let s = json::encode(&obj).unwrap(); let obj2: A = json::decode(&s).unwrap(); assert!(obj.foo == obj2.foo); diff --git a/src/test/run-pass/deriving-eq-ord-boxed-slice.rs b/src/test/run-pass/deriving-eq-ord-boxed-slice.rs index 3b89c943edb..03c93d3ab94 100644 --- a/src/test/run-pass/deriving-eq-ord-boxed-slice.rs +++ b/src/test/run-pass/deriving-eq-ord-boxed-slice.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - #[derive(PartialEq, PartialOrd, Eq, Ord)] struct Foo(Box<[u8]>); pub fn main() { - let a = Foo(box [0, 1, 2]); - let b = Foo(box [0, 1, 2]); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let a = Foo(Box::new([0, 1, 2])); + let b = Foo(Box::new([0, 1, 2])); assert!(a == b); println!("{}", a != b); println!("{}", a < b); diff --git a/src/test/run-pass/dst-deref-mut.rs b/src/test/run-pass/dst-deref-mut.rs index 909f7f4897a..33548d5e298 100644 --- a/src/test/run-pass/dst-deref-mut.rs +++ b/src/test/run-pass/dst-deref-mut.rs @@ -10,9 +10,6 @@ // Test that a custom deref with a fat pointer return type does not ICE -#![allow(unknown_features)] -#![feature(box_syntax)] - use std::ops::{Deref, DerefMut}; pub struct Arr { @@ -41,6 +38,7 @@ pub fn foo(arr: &mut Arr) { } fn main() { - let mut a = Arr { ptr: box [1, 2, 3] }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let mut a = Arr { ptr: Box::new([1, 2, 3]) }; foo(&mut a); } diff --git a/src/test/run-pass/dst-deref.rs b/src/test/run-pass/dst-deref.rs index ad4456b5b59..147a27afa80 100644 --- a/src/test/run-pass/dst-deref.rs +++ b/src/test/run-pass/dst-deref.rs @@ -10,9 +10,6 @@ // Test that a custom deref with a fat pointer return type does not ICE -#![allow(unknown_features)] -#![feature(box_syntax)] - use std::ops::Deref; pub struct Arr { @@ -36,6 +33,7 @@ pub fn foo(arr: &Arr) { } fn main() { - let a = Arr { ptr: box [1, 2, 3] }; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let a = Arr { ptr: Box::new([1, 2, 3]) }; foo(&a); } diff --git a/src/test/run-pass/dst-struct.rs b/src/test/run-pass/dst-struct.rs index ee5193adbc6..15558414bf5 100644 --- a/src/test/run-pass/dst-struct.rs +++ b/src/test/run-pass/dst-struct.rs @@ -115,7 +115,7 @@ pub fn main() { foo3(f5); // Box. - let f1 = box [1, 2, 3]; + let f1 = Box::new([1, 2, 3]); assert!((*f1)[1] == 2); let f2: Box<[int]> = f1; assert!((*f2)[1] == 2); @@ -125,6 +125,9 @@ pub fn main() { foo(&*f1); let f2 : Box> = f1; foo(&*f2); - let f3 : Box> = box Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }; + + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let f3 : Box> = + Box::>::new(Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] }); foo(&*f3); } diff --git a/src/test/run-pass/dst-trait.rs b/src/test/run-pass/dst-trait.rs index fd1c7247e37..6590a8e1847 100644 --- a/src/test/run-pass/dst-trait.rs +++ b/src/test/run-pass/dst-trait.rs @@ -95,7 +95,9 @@ pub fn main() { assert!(f6.ptr.to_bar() == Bar); // &* - let f7: Box = box Bar1 {f :42}; + // + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let f7: Box = Box::new(Bar1 {f :42}); bar(&*f7); // Deep nesting diff --git a/src/test/run-pass/empty-allocation-non-null.rs b/src/test/run-pass/empty-allocation-non-null.rs index 269e0ee6ce4..0459206c5b9 100644 --- a/src/test/run-pass/empty-allocation-non-null.rs +++ b/src/test/run-pass/empty-allocation-non-null.rs @@ -8,18 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. pub fn main() { - assert!(Some(box() ()).is_some()); + assert!(Some(Box::new(())).is_some()); - let xs: Box<[()]> = box []; + let xs: Box<[()]> = Box::<[(); 0]>::new([]); assert!(Some(xs).is_some()); struct Foo; - assert!(Some(box Foo).is_some()); + assert!(Some(Box::new(Foo)).is_some()); - let ys: Box<[Foo]> = box []; + let ys: Box<[Foo]> = Box::<[Foo; 0]>::new([]); assert!(Some(ys).is_some()); } diff --git a/src/test/run-pass/empty-allocation-rvalue-non-null.rs b/src/test/run-pass/empty-allocation-rvalue-non-null.rs index e95d58c706b..f56d8843acd 100644 --- a/src/test/run-pass/empty-allocation-rvalue-non-null.rs +++ b/src/test/run-pass/empty-allocation-rvalue-non-null.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - pub fn main() { - let x = *box() (); + let x = *Box::new(()); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 677038af9a9..81c4054d009 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -9,7 +9,6 @@ // except according to those terms. #![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unboxed_closures)] /** @@ -61,7 +60,8 @@ mod map_reduce { } let ctrl_clone = ctrl.clone(); - ::map(input, box |a,b| emit(&mut intermediates, ctrl.clone(), a, b) ); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + ::map(input, Box::new(|a,b| emit(&mut intermediates, ctrl.clone(), a, b))); ctrl_clone.send(ctrl_proto::mapper_done).unwrap(); } diff --git a/src/test/run-pass/hrtb-precedence-of-plus.rs b/src/test/run-pass/hrtb-precedence-of-plus.rs index b59e7b67d4e..f4daf9a4f62 100644 --- a/src/test/run-pass/hrtb-precedence-of-plus.rs +++ b/src/test/run-pass/hrtb-precedence-of-plus.rs @@ -9,7 +9,6 @@ // except according to those terms. #![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unboxed_closures)] // Test that `Fn(int) -> int + 'static` parses as `(Fn(int) -> int) + @@ -17,7 +16,8 @@ // cause a compilation error. Issue #18772. fn adder(y: int) -> Box int + 'static> { - box move |x| y + x + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + Box::new(move |x| y + x) } fn main() {} diff --git a/src/test/run-pass/issue-11205.rs b/src/test/run-pass/issue-11205.rs index 1325b51a54f..c67ce92ee0a 100644 --- a/src/test/run-pass/issue-11205.rs +++ b/src/test/run-pass/issue-11205.rs @@ -9,8 +9,8 @@ // except according to those terms. #![allow(dead_code)] -#![allow(unknown_features)] -#![feature(box_syntax)] + +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. trait Foo { fn dummy(&self) { } } impl Foo for int {} @@ -39,16 +39,16 @@ fn main() { let r = &1; foog(x, &[r]); - let x: [Box; 2] = [box 1, box 2]; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; bar(x); - bar([box 1, box 2]); + bar([Box::new(1), Box::new(2)]); - let x: &[Box] = &[box 1, box 2]; + let x: &[Box] = &[Box::new(1), Box::new(2)]; bars(x); - bars(&[box 1, box 2]); + bars(&[Box::new(1), Box::new(2)]); - let x: &[Box] = &[box 1, box 2]; - foog(x, &[box 1]); + let x: &[Box] = &[Box::new(1), Box::new(2)]; + foog(x, &[Box::new(1)]); struct T<'a> { t: [&'a (Foo+'a); 2] @@ -85,9 +85,9 @@ fn main() { t: &'a [Box] } let _n = M { - t: &[box 1, box 2] + t: &[Box::new(1), Box::new(2)] }; - let x: [Box; 2] = [box 1, box 2]; + let x: [Box; 2] = [Box::new(1), Box::new(2)]; let _n = M { t: &x }; diff --git a/src/test/run-pass/issue-11677.rs b/src/test/run-pass/issue-11677.rs index 7cccac4483d..4b2b3e87024 100644 --- a/src/test/run-pass/issue-11677.rs +++ b/src/test/run-pass/issue-11677.rs @@ -9,8 +9,6 @@ // except according to those terms. #![allow(dead_code)] -#![allow(unknown_features)] -#![feature(box_syntax)] // this code used to cause an ICE @@ -28,5 +26,6 @@ impl X for F { } fn main() { - S {f: box F, g: box F}; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + S {f: Box::new(F), g: Box::new(F) }; } diff --git a/src/test/run-pass/issue-12744.rs b/src/test/run-pass/issue-12744.rs index 2f7ba315aa1..56d1d3599c7 100644 --- a/src/test/run-pass/issue-12744.rs +++ b/src/test/run-pass/issue-12744.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - fn main() { - fn test() -> Box { box 1 } + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + fn test() -> Box { Box::new(1) } println!("{:?}", test()) } diff --git a/src/test/run-pass/issue-13808.rs b/src/test/run-pass/issue-13808.rs index 3c5ece87b73..96e2a0dc485 100644 --- a/src/test/run-pass/issue-13808.rs +++ b/src/test/run-pass/issue-13808.rs @@ -8,16 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - struct Foo<'a> { listener: Box, } impl<'a> Foo<'a> { fn new(listener: F) -> Foo<'a> where F: FnMut() + 'a { - Foo { listener: box listener } + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + Foo { listener: Box::new(listener) } } } diff --git a/src/test/run-pass/issue-14589.rs b/src/test/run-pass/issue-14589.rs index 71d88ee6215..5924aa44d4d 100644 --- a/src/test/run-pass/issue-14589.rs +++ b/src/test/run-pass/issue-14589.rs @@ -11,13 +11,12 @@ // All 3 expressions should work in that the argument gets // coerced to a trait object -#![allow(unknown_features)] -#![feature(box_syntax)] +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. fn main() { - send::>(box Output(0)); - Test::>::foo(box Output(0)); - Test::>::new().send(box Output(0)); + send::>(Box::new(Output(0))); + Test::>::foo(Box::new(Output(0))); + Test::>::new().send(Box::new(Output(0))); } fn send(_: T) {} diff --git a/src/test/run-pass/issue-14919.rs b/src/test/run-pass/issue-14919.rs index 933e7e40f06..fbf08ab564d 100644 --- a/src/test/run-pass/issue-14919.rs +++ b/src/test/run-pass/issue-14919.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - trait Matcher { fn next_match(&mut self) -> Option<(uint, uint)>; } @@ -32,9 +29,10 @@ trait IntoMatcher<'a, T> { impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b { fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. CharPredMatcher { str: s, - pred: box self, + pred: Box::new(self), } } } diff --git a/src/test/run-pass/issue-15571.rs b/src/test/run-pass/issue-15571.rs index ab9554f65d4..5b093d16cbf 100644 --- a/src/test/run-pass/issue-15571.rs +++ b/src/test/run-pass/issue-15571.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] fn match_on_local() { - let mut foo = Some(box 5); + let mut foo: Option> = Some(box 5); match foo { None => {}, Some(x) => { @@ -33,7 +33,7 @@ fn match_on_arg(mut foo: Option>) { } fn match_on_binding() { - match Some(box 7) { + match Some(Box::new(7)) { mut foo => { match foo { None => {}, @@ -47,7 +47,7 @@ fn match_on_binding() { } fn match_on_upvar() { - let mut foo = Some(box 8i32); + let mut foo: Option> = Some(box 8i32); let f = move|| { match foo { None => {}, diff --git a/src/test/run-pass/issue-16668.rs b/src/test/run-pass/issue-16668.rs index daf09047bef..786c701a042 100644 --- a/src/test/run-pass/issue-16668.rs +++ b/src/test/run-pass/issue-16668.rs @@ -11,7 +11,6 @@ // ignore-pretty #![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unboxed_closures)] struct Parser<'a, I, O> { @@ -20,13 +19,14 @@ struct Parser<'a, I, O> { impl<'a, I: 'a, O: 'a> Parser<'a, I, O> { fn compose(mut self, mut rhs: Parser<'a, O, K>) -> Parser<'a, I, K> { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. Parser { - parse: box move |x: I| { + parse: Box::new(move |x: I| { match (self.parse)(x) { Ok(r) => (rhs.parse)(r), Err(e) => Err(e) } - } + }) } } } diff --git a/src/test/run-pass/issue-17734.rs b/src/test/run-pass/issue-17734.rs index 3cff16409cb..497361969bf 100644 --- a/src/test/run-pass/issue-17734.rs +++ b/src/test/run-pass/issue-17734.rs @@ -10,16 +10,15 @@ // Test that generating drop glue for Box doesn't ICE -#![allow(unknown_features)] -#![feature(box_syntax)] - fn f(s: Box) -> Box { s } fn main() { // There is currently no safe way to construct a `Box`, so improvise - let box_arr: Box<[u8]> = box ['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8]; + // + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let box_arr: Box<[u8]> = Box::new(['h' as u8, 'e' as u8, 'l' as u8, 'l' as u8, 'o' as u8]); let box_str: Box = unsafe { std::mem::transmute(box_arr) }; assert_eq!(&*box_str, "hello"); f(box_str); diff --git a/src/test/run-pass/issue-18425.rs b/src/test/run-pass/issue-18425.rs index ec7481ead04..2011b87e731 100644 --- a/src/test/run-pass/issue-18425.rs +++ b/src/test/run-pass/issue-18425.rs @@ -11,9 +11,6 @@ // Check that trans doesn't ICE when translating an array repeat // expression with a count of 1 and a non-Copy element type. -#![allow(unknown_features)] -#![feature(box_syntax)] - fn main() { - let _ = [box 1_usize; 1]; + let _ = [Box::new(1_usize); 1]; } diff --git a/src/test/run-pass/issue-20575.rs b/src/test/run-pass/issue-20575.rs index f83150b9518..9ebd96a685e 100644 --- a/src/test/run-pass/issue-20575.rs +++ b/src/test/run-pass/issue-20575.rs @@ -10,10 +10,9 @@ // Test that overloaded calls work with zero arity closures -#![feature(box_syntax)] - fn main() { - let functions: [Box Option<()>>; 1] = [box || None]; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let functions: [Box Option<()>>; 1] = [Box::new(|| None)]; let _: Option> = functions.iter().map(|f| (*f)()).collect(); } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index b8a541a0fc4..ae146d8d353 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -11,8 +11,6 @@ // // ignore-lexer-test FIXME #15883 -#![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unsafe_destructor)] pub type Task = int; @@ -52,11 +50,11 @@ pub mod pipes { pub fn packet() -> *const packet { unsafe { - let p: *const packet = mem::transmute(box Stuff{ + let p: *const packet = mem::transmute(Box::new(Stuff{ state: empty, blocked_task: None::, payload: None:: - }); + })); p } } diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs index 3e7deee6ec1..0784c8be883 100644 --- a/src/test/run-pass/issue-3052.rs +++ b/src/test/run-pass/issue-3052.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - type Connection = Box) + 'static>; fn f() -> Option { - let mock_connection: Connection = box |_| {}; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let mock_connection: Connection = Box::new(|_| {}); Some(mock_connection) } diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index 0d85f61e513..e039be058de 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -11,7 +11,6 @@ // rustc --test ignores2.rs && ./ignores2 #![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unboxed_closures)] use std::old_path::{Path}; @@ -23,9 +22,10 @@ type rsrc_loader = Box (result::Result) + 'stati fn tester() { - let mut loader: rsrc_loader = box move|_path| { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let mut loader: rsrc_loader = Box::new(move|_path| { result::Result::Ok("more blah".to_string()) - }; + }); let path = old_path::Path::new("blah"); assert!(loader(&path).is_ok()); diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 4a28c34e5d9..28e44536892 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -9,7 +9,6 @@ // except according to those terms. #![allow(unknown_features)] -#![feature(box_syntax)] use std::thread::Thread; use std::sync::mpsc::Sender; @@ -27,8 +26,8 @@ fn foo(name: String, samples_chan: Sender) { let _t = Thread::spawn(move|| { let mut samples_chan = samples_chan; - // `box() (...)` syntax is needed to make pretty printer converge in one try: - let callback: SamplesFn = box() (move |buffer| { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let callback: SamplesFn = Box::new(move |buffer| { for i in 0_usize..buffer.len() { println!("{}: {}", i, buffer[i]) } diff --git a/src/test/run-pass/issue-6117.rs b/src/test/run-pass/issue-6117.rs index 93edffdcb47..562e2b68af1 100644 --- a/src/test/run-pass/issue-6117.rs +++ b/src/test/run-pass/issue-6117.rs @@ -8,13 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - enum Either { Left(T), Right(U) } pub fn main() { - match Either::Left(box 17) { + match Either::Left(Box::new(17)) { Either::Right(()) => {} _ => {} } diff --git a/src/test/run-pass/issue-8498.rs b/src/test/run-pass/issue-8498.rs index 494b6217855..d4d2603bfe2 100644 --- a/src/test/run-pass/issue-8498.rs +++ b/src/test/run-pass/issue-8498.rs @@ -8,18 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - pub fn main() { - match &[(box 5,box 7)] { + match &[(Box::new(5),Box::new(7))] { ps => { let (ref y, _) = ps[0]; assert!(**y == 5); } } - match Some(&[(box 5,)]) { + match Some(&[(Box::new(5),)]) { Some(ps) => { let (ref y,) = ps[0]; assert!(**y == 5); @@ -27,7 +24,7 @@ pub fn main() { None => () } - match Some(&[(box 5,box 7)]) { + match Some(&[(Box::new(5),Box::new(7))]) { Some(ps) => { let (ref y, ref z) = ps[0]; assert!(**y == 5); diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index 566d34e6d86..74ddb990c31 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -17,11 +17,12 @@ struct A { a: Box } fn foo() -> Box isize + 'static> { - let k = box 22; + let k: Box<_> = box 22; let _u = A {a: k.clone()}; // FIXME(#16640) suffix in `22_isize` suffix shouldn't be necessary let result = || 22_isize; - box result + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + Box::new(result) } pub fn main() { diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index 130cdc85b01..039e53cab80 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -11,10 +11,8 @@ // Test that the lambda kind is inferred correctly as a return // expression -#![allow(unknown_features)] -#![feature(box_syntax)] - -fn unique() -> Box { return box || (); } +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. +fn unique() -> Box { return Box::new(|| ()); } pub fn main() { } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 0952bedd6e3..b7216c87c30 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -11,10 +11,8 @@ // Test that the lambda kind is inferred correctly as a return // expression -#![allow(unknown_features)] -#![feature(box_syntax)] - -fn unique() -> Box { box || () } +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. +fn unique() -> Box { Box::new(|| ()) } pub fn main() { } diff --git a/src/test/run-pass/overloaded-autoderef.rs b/src/test/run-pass/overloaded-autoderef.rs index f40c9dc45ca..6436165968d 100644 --- a/src/test/run-pass/overloaded-autoderef.rs +++ b/src/test/run-pass/overloaded-autoderef.rs @@ -22,9 +22,10 @@ struct Point { } pub fn main() { - let box_5 = box 5_usize; + let box_5: Box<_> = box 5_usize; assert_eq!(Rc::new(5_usize).to_uint(), Some(5)); - assert_eq!((box &box &Rc::new(box box &box_5)).to_uint(), Some(5)); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + assert_eq!((Box::new(&Box::new(&Rc::new(Box::new(Box::new(&box_5)))))).to_uint(), Some(5)); let point = Rc::new(Point {x: 2, y: 4}); assert_eq!(point.x, 2); assert_eq!(point.y, 4); diff --git a/src/test/run-pass/overloaded-deref.rs b/src/test/run-pass/overloaded-deref.rs index f56e7d56fe1..bb1694be5e2 100644 --- a/src/test/run-pass/overloaded-deref.rs +++ b/src/test/run-pass/overloaded-deref.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - use std::cell::RefCell; use std::rc::Rc; use std::string::String; @@ -23,7 +20,7 @@ struct Point { pub fn main() { assert_eq!(*Rc::new(5), 5); - assert_eq!(***Rc::new(box box 5), 5); + assert_eq!(***Rc::new(Box::new(Box::new(5))), 5); assert_eq!(*Rc::new(Point {x: 2, y: 4}), Point {x: 2, y: 4}); let i = Rc::new(RefCell::new(2)); diff --git a/src/test/run-pass/owned-implies-static.rs b/src/test/run-pass/owned-implies-static.rs index 2db6f7ffaaa..9be6b212a3c 100644 --- a/src/test/run-pass/owned-implies-static.rs +++ b/src/test/run-pass/owned-implies-static.rs @@ -8,11 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - fn f(_x: T) {} pub fn main() { - f(box 5); + f(Box::new(5)); } diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index 6ebef9f34ad..3704fc1d8d1 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -9,7 +9,6 @@ // except according to those terms. #![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unboxed_closures)] struct closure_box<'a> { @@ -25,7 +24,8 @@ pub fn main() { assert_eq!(i, 3); { let cl = || i += 1; - let mut cl_box = box_it(box cl); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let mut cl_box = box_it(Box::new(cl)); cl_box.cl.call_mut(()); } assert_eq!(i, 4); diff --git a/src/test/run-pass/regions-fn-subtyping.rs b/src/test/run-pass/regions-fn-subtyping.rs index faa9b37bdcc..0057a51012d 100644 --- a/src/test/run-pass/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions-fn-subtyping.rs @@ -13,7 +13,8 @@ #![allow(dead_assignment)] #![allow(unused_variable)] #![allow(unknown_features)] -#![feature(box_syntax)] + +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. // Should pass region checking. fn ok(f: Box) { @@ -23,14 +24,14 @@ fn ok(f: Box) { // f's type should be a subtype of g's type), because f can be // used in any context that expects g's type. But this currently // fails. - let mut g: Box FnMut(&'r uint)> = box |x| { }; + let mut g: Box FnMut(&'r uint)> = Box::new(|x| { }); g = f; } // This version is the same as above, except that here, g's type is // inferred. fn ok_inferred(f: Box) { - let mut g: Box FnMut(&'r uint)> = box |_| {}; + let mut g: Box FnMut(&'r uint)> = Box::new(|_| {}); g = f; } diff --git a/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs b/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs index e779e002b29..1ad96d4bc55 100644 --- a/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs +++ b/src/test/run-pass/regions-relate-bound-regions-on-closures-to-inference-variables.rs @@ -30,7 +30,8 @@ struct Foo<'a,'tcx:'a> { impl<'a,'tcx> Foo<'a,'tcx> { fn bother(&mut self) -> int { - self.elaborate_bounds(box |this| { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + self.elaborate_bounds(Box::new(|this| { // (*) Here: type of `this` is `&'f0 Foo<&'f1, '_2>`, // where `'f0` and `'f1` are fresh, free regions that // result from the bound regions on the closure, and `'2` @@ -44,7 +45,7 @@ impl<'a,'tcx> Foo<'a,'tcx> { // `region_inference.rs` file (and the `givens` field, in // particular) for more details. this.foo() - }) + })) } fn foo(&mut self) -> int { diff --git a/src/test/run-pass/regions-static-closure.rs b/src/test/run-pass/regions-static-closure.rs index 7198c35944f..1bcde77261b 100644 --- a/src/test/run-pass/regions-static-closure.rs +++ b/src/test/run-pass/regions-static-closure.rs @@ -25,6 +25,7 @@ fn call_static_closure(mut cl: closure_box<'static>) { } pub fn main() { - let cl_box = box_it(box || println!("Hello, world!")); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let cl_box = box_it(Box::new(|| println!("Hello, world!"))); call_static_closure(cl_box); } diff --git a/src/test/run-pass/show-boxed-slice.rs b/src/test/run-pass/show-boxed-slice.rs index f496765edca..03971668182 100644 --- a/src/test/run-pass/show-boxed-slice.rs +++ b/src/test/run-pass/show-boxed-slice.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - #[derive(Debug)] struct Foo(Box<[u8]>); pub fn main() { - println!("{:?}", Foo(box [0, 1, 2])); + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + println!("{:?}", Foo(Box::new([0, 1, 2]))); } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 26772a5b22c..cf23785b844 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -104,9 +104,10 @@ fn check_legs(arc: Arc>>) { } fn check_names(arc: Arc>>) { for pet in &*arc { - pet.name(box |name| { + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + pet.name(Box::new(|name| { assert!(name.as_bytes()[0] == 'a' as u8 && name.as_bytes()[1] == 'l' as u8); - }) + })) } } fn check_pedigree(arc: Arc>>) { diff --git a/src/test/run-pass/trait-coercion-generic.rs b/src/test/run-pass/trait-coercion-generic.rs index fa02dabb373..1565ccfe459 100644 --- a/src/test/run-pass/trait-coercion-generic.rs +++ b/src/test/run-pass/trait-coercion-generic.rs @@ -8,9 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unknown_features)] -#![feature(box_syntax)] - trait Trait { fn f(&self, x: T); } @@ -29,7 +26,8 @@ impl Trait<&'static str> for Struct { pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: Box> = box a; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let b: Box> = Box::new(a); b.f("Mary"); let c: &Trait<&'static str> = &a; c.f("Joe"); diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs index 1ae9b3f0e95..6db7113b050 100644 --- a/src/test/run-pass/trait-coercion.rs +++ b/src/test/run-pass/trait-coercion.rs @@ -33,14 +33,16 @@ fn foo(mut a: Box) { a.write(b"Hello\n"); } +// FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: Box = box a; + let b: Box = Box::new(a); b.f(); let c: &Trait = &a; c.f(); let out = old_io::stdout(); - foo(box out); + foo(Box::new(out)); } diff --git a/src/test/run-pass/traits-conditional-dispatch.rs b/src/test/run-pass/traits-conditional-dispatch.rs index 5af2d4ee806..650688dd908 100644 --- a/src/test/run-pass/traits-conditional-dispatch.rs +++ b/src/test/run-pass/traits-conditional-dispatch.rs @@ -35,5 +35,5 @@ fn main() { assert_eq!(get_it(&1_u32), 1_u32); assert_eq!(get_it(&1_u16), 1_u16); assert_eq!(get_it(&Some(1_u16)), Some(1_u16)); - assert_eq!(get_it(&box 1), box 1); + assert_eq!(get_it(&Box::new(1)), Box::new(1)); } diff --git a/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs b/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs index da647e90c00..52311544297 100644 --- a/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs +++ b/src/test/run-pass/unboxed-closures-call-sugar-object-autoderef.rs @@ -11,13 +11,13 @@ // Test that the call operator autoderefs when calling to an object type. #![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unboxed_closures)] use std::ops::FnMut; fn make_adder(x: int) -> Boxint + 'static> { - box move |y| { x + y } + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + Box::new(move |y| { x + y }) } pub fn main() { diff --git a/src/test/run-pass/unboxed-closures-call-sugar-object.rs b/src/test/run-pass/unboxed-closures-call-sugar-object.rs index 8ee3c96f580..a34799fdcc5 100644 --- a/src/test/run-pass/unboxed-closures-call-sugar-object.rs +++ b/src/test/run-pass/unboxed-closures-call-sugar-object.rs @@ -9,13 +9,13 @@ // except according to those terms. #![allow(unknown_features)] -#![feature(box_syntax)] #![feature(unboxed_closures)] use std::ops::FnMut; fn make_adder(x: int) -> Boxint + 'static> { - box move |y| { x + y } + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + Box::new(move |y| { x + y }) } pub fn main() { diff --git a/src/test/run-pass/unboxed-closures-monomorphization.rs b/src/test/run-pass/unboxed-closures-monomorphization.rs index 535c4562362..056ae63b684 100644 --- a/src/test/run-pass/unboxed-closures-monomorphization.rs +++ b/src/test/run-pass/unboxed-closures-monomorphization.rs @@ -17,7 +17,8 @@ fn main(){ fn bar<'a, T:Clone+'a> (t: T) -> BoxT + 'a> { - box move || t.clone() + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + Box::new(move || t.clone()) } let mut f = bar(42_u32); diff --git a/src/test/run-pass/unboxed-closures-prelude.rs b/src/test/run-pass/unboxed-closures-prelude.rs index c8f0d5fde45..16a55ab550d 100644 --- a/src/test/run-pass/unboxed-closures-prelude.rs +++ b/src/test/run-pass/unboxed-closures-prelude.rs @@ -15,10 +15,11 @@ #![feature(unboxed_closures)] fn main() { - let task: Box int> = box |x| x; + // FIXME (#22405): Replace `Box::new` with `box` here when/if possible. + let task: Box int> = Box::new(|x| x); task.call((0, )); - let mut task: Box int> = box |x| x; + let mut task: Box int> = Box::new(|x| x); task(0); call(|x| x, 22); diff --git a/src/test/run-pass/unique-match-discrim.rs b/src/test/run-pass/unique-match-discrim.rs index a1502c2eb8c..93614e86c73 100644 --- a/src/test/run-pass/unique-match-discrim.rs +++ b/src/test/run-pass/unique-match-discrim.rs @@ -10,11 +10,8 @@ // Issue #961 -#![allow(unknown_features)] -#![feature(box_syntax)] - fn altsimple() { - match box true { + match Box::new(true) { _ => { } } }