From 270f0eef733a625bcee68019189f19dc119f8f24 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 17 Feb 2015 21:41:32 +0100 Subject: [PATCH 1/4] Add `: Box<_>` or `::Box<_>` type annotations to various places. This is the kind of change that one is expected to need to make to accommodate overloaded-`box`. ---- Note that this is not *all* of the changes necessary to accommodate Issue 22181. It is merely the subset of those cases where there was already a let-binding in place that made it easy to add the necesasry type ascription. (For unnamed intermediate `Box` values, one must go down a different route; `Box::new` is the option that maximizes portability, but has potential inefficiency depending on whether the call is inlined.) ---- There is one place worth note, `run-pass/coerce-match.rs`, where I used an ugly form of `Box<_>` type ascription where I would have preferred to use `Box::new` to accommodate overloaded-`box`. I deliberately did not use `Box::new` here, because that is already done in coerce-match-calls.rs. ---- Precursor for overloaded-`box` and placement-`in`; see Issue 22181. --- src/liballoc/arc.rs | 4 ++- src/liballoc/heap.rs | 3 +- src/liballoc/lib.rs | 6 ++++ src/liballoc/rc.rs | 3 +- src/libarena/lib.rs | 8 ++--- src/libcollections/binary_heap.rs | 2 +- src/libcollections/linked_list.rs | 2 +- src/libcollections/slice.rs | 26 ++++++++------- src/libcollections/vec.rs | 4 +-- src/libcollections/vec_map.rs | 2 +- src/libcoretest/any.rs | 2 +- src/libcoretest/option.rs | 2 +- src/librustc_back/sha2.rs | 2 +- src/libstd/old_io/net/ip.rs | 12 +++---- src/libstd/sync/mpsc/mod.rs | 8 ++--- src/libstd/sync/mpsc/mpsc_queue.rs | 2 +- src/libstd/sync/mpsc/spsc_queue.rs | 2 +- src/libstd/thread.rs | 2 +- src/test/bench/shootout-k-nucleotide.rs | 4 +-- src/test/bench/sudoku.rs | 2 +- src/test/compile-fail/borrow-tuple-fields.rs | 2 +- .../borrowck-bad-nested-calls-free.rs | 4 +-- .../borrowck-bad-nested-calls-move.rs | 4 +-- ...rrowck-borrow-immut-deref-of-box-as-mut.rs | 2 +- .../borrowck-box-insensitivity.rs | 32 +++++++++---------- .../borrowck-closures-mut-and-imm.rs | 6 ++-- .../compile-fail/borrowck-closures-two-mut.rs | 2 +- .../borrowck-closures-use-after-free.rs | 2 +- ...rrowck-for-loop-correct-cmt-for-pattern.rs | 2 +- src/test/compile-fail/borrowck-issue-14498.rs | 4 +-- .../compile-fail/borrowck-issue-2657-1.rs | 2 +- .../compile-fail/borrowck-issue-2657-2.rs | 2 +- .../compile-fail/borrowck-lend-flow-if.rs | 4 +-- .../compile-fail/borrowck-lend-flow-loop.rs | 24 +++++++------- src/test/compile-fail/borrowck-lend-flow.rs | 4 +-- .../borrowck-loan-blocks-move-cc.rs | 4 +-- .../borrowck-loan-blocks-mut-uniq.rs | 2 +- .../compile-fail/borrowck-move-by-capture.rs | 2 +- ...owck-move-from-subpath-of-borrowed-path.rs | 2 +- .../borrowck-move-moved-value-into-closure.rs | 2 +- .../borrowck-multiple-captures.rs | 12 +++---- .../borrowck-no-cycle-in-exchange-heap.rs | 2 +- .../borrowck-overloaded-index-2.rs | 2 +- .../compile-fail/borrowck-uniq-via-lend.rs | 14 ++++---- src/test/compile-fail/issue-10398.rs | 2 +- src/test/compile-fail/issue-11192.rs | 2 +- src/test/compile-fail/issue-11925.rs | 2 +- src/test/compile-fail/issue-12127.rs | 2 +- src/test/compile-fail/issue-17263.rs | 4 +-- src/test/compile-fail/issue-17913.rs | 4 +-- .../compile-fail/kindck-impl-type-params-2.rs | 2 +- .../kindck-inherited-copy-bound.rs | 4 +-- .../compile-fail/liveness-use-after-move.rs | 2 +- src/test/compile-fail/move-in-guard-1.rs | 2 +- src/test/compile-fail/move-in-guard-2.rs | 2 +- .../compile-fail/move-out-of-tuple-field.rs | 2 +- src/test/compile-fail/mut-cross-borrowing.rs | 2 +- src/test/compile-fail/static-region-bound.rs | 2 +- ...use-after-move-implicity-coerced-object.rs | 4 +-- src/test/debuginfo/borrowed-struct.rs | 2 +- src/test/debuginfo/boxed-struct.rs | 4 +-- .../generic-method-on-generic-struct.rs | 2 +- src/test/debuginfo/method-on-enum.rs | 2 +- .../debuginfo/method-on-generic-struct.rs | 2 +- src/test/debuginfo/method-on-struct.rs | 2 +- src/test/debuginfo/method-on-trait.rs | 2 +- src/test/debuginfo/method-on-tuple-struct.rs | 2 +- src/test/debuginfo/self-in-default-method.rs | 2 +- .../self-in-generic-default-method.rs | 2 +- src/test/debuginfo/unique-enum.rs | 6 ++-- .../var-captured-in-nested-closure.rs | 2 +- .../var-captured-in-sendable-closure.rs | 2 +- .../var-captured-in-stack-closure.rs | 2 +- .../run-pass/autoderef-method-on-trait.rs | 2 +- .../run-pass/autoderef-method-priority.rs | 2 +- .../autoderef-method-twice-but-not-thrice.rs | 2 +- src/test/run-pass/autoderef-method-twice.rs | 2 +- src/test/run-pass/autoderef-method.rs | 2 +- .../autoref-intermediate-types-issue-3585.rs | 2 +- src/test/run-pass/bitv-perf-test.rs | 4 +-- .../run-pass/borrowck-move-by-capture-ok.rs | 2 +- src/test/run-pass/borrowck-mut-uniq.rs | 2 +- src/test/run-pass/cci_borrow.rs | 2 +- ...nup-rvalue-temp-during-incomplete-alloc.rs | 2 +- src/test/run-pass/clone-with-exterior.rs | 2 +- src/test/run-pass/coerce-match.rs | 8 +++-- .../crate-method-reexport-grrrrrrr.rs | 2 +- src/test/run-pass/deref-lval.rs | 2 +- src/test/run-pass/explicit-self-generic.rs | 2 +- src/test/run-pass/explicit-self.rs | 2 +- src/test/run-pass/expr-block-unique.rs | 2 +- src/test/run-pass/expr-if-unique.rs | 2 +- src/test/run-pass/expr-match-unique.rs | 2 +- .../run-pass/func-arg-incomplete-pattern.rs | 2 +- src/test/run-pass/func-arg-ref-pattern.rs | 2 +- src/test/run-pass/generic-alias-unique.rs | 2 +- src/test/run-pass/ifmt.rs | 2 +- src/test/run-pass/init-res-into-things.rs | 4 +-- src/test/run-pass/intrinsic-atomics.rs | 2 +- src/test/run-pass/intrinsic-move-val.rs | 2 +- src/test/run-pass/issue-10802.rs | 4 +-- src/test/run-pass/issue-14399.rs | 2 +- src/test/run-pass/issue-2633-2.rs | 2 +- src/test/run-pass/issue-2708.rs | 2 +- src/test/run-pass/issue-2935.rs | 2 +- src/test/run-pass/issue-3012-2.rs | 2 +- src/test/run-pass/issue-3026.rs | 2 +- src/test/run-pass/issue-3290.rs | 2 +- src/test/run-pass/issue-3878.rs | 2 +- src/test/run-pass/issue-5718.rs | 2 +- src/test/run-pass/last-use-is-capture.rs | 2 +- src/test/run-pass/let-assignability.rs | 2 +- .../run-pass/match-implicit-copy-unique.rs | 2 +- .../method-two-trait-defer-resolution-2.rs | 2 +- src/test/run-pass/move-1-unique.rs | 2 +- src/test/run-pass/move-2-unique.rs | 2 +- src/test/run-pass/move-2.rs | 2 +- src/test/run-pass/move-3-unique.rs | 2 +- src/test/run-pass/move-guard-const.rs | 2 +- .../run-pass/overloaded-index-autoderef.rs | 2 +- src/test/run-pass/pure-sum.rs | 4 +-- src/test/run-pass/rcvr-borrowed-to-region.rs | 2 +- src/test/run-pass/regions-borrow-at.rs | 2 +- src/test/run-pass/regions-borrow-uniq.rs | 2 +- .../run-pass/regions-escape-into-other-fn.rs | 2 +- ...gions-infer-borrow-scope-within-loop-ok.rs | 2 +- .../run-pass/regions-infer-borrow-scope.rs | 2 +- .../self-in-mut-slot-default-method.rs | 2 +- src/test/run-pass/self-re-assign.rs | 2 +- src/test/run-pass/sendfn-spawn-with-fn-arg.rs | 2 +- src/test/run-pass/task-spawn-move-and-copy.rs | 2 +- src/test/run-pass/type-param-constraints.rs | 8 ++--- src/test/run-pass/ufcs-explicit-self.rs | 4 +-- src/test/run-pass/uniq-self-in-mut-slot.rs | 2 +- src/test/run-pass/unique-assign-copy.rs | 2 +- src/test/run-pass/unique-assign-drop.rs | 4 +-- src/test/run-pass/unique-assign-generic.rs | 2 +- src/test/run-pass/unique-assign.rs | 2 +- src/test/run-pass/unique-autoderef-field.rs | 2 +- src/test/run-pass/unique-autoderef-index.rs | 2 +- src/test/run-pass/unique-cmp.rs | 2 +- src/test/run-pass/unique-containing-tag.rs | 2 +- src/test/run-pass/unique-create.rs | 2 +- src/test/run-pass/unique-decl-init-copy.rs | 2 +- src/test/run-pass/unique-decl-init.rs | 2 +- src/test/run-pass/unique-decl-move.rs | 2 +- src/test/run-pass/unique-deref.rs | 2 +- src/test/run-pass/unique-drop-complex.rs | 2 +- src/test/run-pass/unique-in-vec-copy.rs | 2 +- src/test/run-pass/unique-in-vec.rs | 2 +- src/test/run-pass/unique-init.rs | 2 +- src/test/run-pass/unique-kinds.rs | 24 +++++++------- src/test/run-pass/unique-log.rs | 2 +- src/test/run-pass/unique-move-drop.rs | 4 +-- src/test/run-pass/unique-move-temp.rs | 2 +- src/test/run-pass/unique-move.rs | 2 +- src/test/run-pass/unique-mutable.rs | 2 +- src/test/run-pass/unique-rec.rs | 2 +- src/test/run-pass/unique-send.rs | 2 +- src/test/run-pass/unique-swap.rs | 4 +-- src/test/run-pass/unsized3.rs | 7 ++-- src/test/run-pass/unused-move-capture.rs | 2 +- src/test/run-pass/unused-move.rs | 2 +- src/test/run-pass/unwind-unique.rs | 2 +- 164 files changed, 281 insertions(+), 264 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index c95b413b397..dc1938cac1a 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -69,6 +69,8 @@ //! } //! ``` +use boxed::Box; + use core::prelude::*; use core::atomic; @@ -170,7 +172,7 @@ impl Arc { pub fn new(data: T) -> Arc { // Start the weak pointer count as 1 which is the weak pointer that's // held by all the strong pointers (kinda), see std/rc.rs for more info - let x = box ArcInner { + let x: Box<_> = box ArcInner { strong: atomic::AtomicUsize::new(1), weak: atomic::AtomicUsize::new(1), data: data, diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 726d5c8a23b..3b93171386a 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -387,6 +387,7 @@ mod test { extern crate test; use self::test::Bencher; use core::ptr::PtrExt; + use boxed::Box; use heap; #[test] @@ -404,7 +405,7 @@ mod test { #[bench] fn alloc_owned_small(b: &mut Bencher) { b.iter(|| { - box 10 + let _: Box<_> = box 10; }) } } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 82bd13475c7..b1fdf139b0c 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -96,9 +96,15 @@ pub mod heap; // Primitive types using the heaps above +// Need to conditionally define the mod from `boxed.rs` to avoid +// duplicating the lang-items when building in test cfg; but also need +// to allow code to have `use boxed::HEAP;` +// and `use boxed::Box;` declarations. #[cfg(not(test))] pub mod boxed; #[cfg(test)] +mod boxed { pub use std::boxed::{Box, HEAP}; } +#[cfg(test)] mod boxed_test; pub mod arc; pub mod rc; diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index f57286bbf11..763dcc7f256 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -795,6 +795,7 @@ impl RcBoxPtr for Weak { #[cfg(test)] mod tests { use super::{Rc, Weak, weak_count, strong_count}; + use std::boxed::Box; use std::cell::RefCell; use std::option::Option; use std::option::Option::{Some, None}; @@ -826,7 +827,7 @@ mod tests { #[test] fn test_destructor() { - let x = Rc::new(box 5); + let x: Rc> = Rc::new(box 5); assert_eq!(**x, 5); } diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index b43f9adfb26..4678fe15c8b 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -581,11 +581,11 @@ mod tests { #[bench] pub fn bench_copy_nonarena(b: &mut Bencher) { b.iter(|| { - box Point { + let _: Box<_> = box Point { x: 1, y: 2, z: 3, - } + }; }) } @@ -634,10 +634,10 @@ mod tests { #[bench] pub fn bench_noncopy_nonarena(b: &mut Bencher) { b.iter(|| { - box Noncopy { + let _: Box<_> = box Noncopy { string: "hello world".to_string(), array: vec!( 1, 2, 3, 4, 5 ), - } + }; }) } diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index 36c76dbad14..2e575ddb00a 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -790,7 +790,7 @@ mod tests { #[test] fn test_push_unique() { - let mut heap = BinaryHeap::from_vec(vec![box 2, box 4, box 9]); + let mut heap = BinaryHeap::>::from_vec(vec![box 2, box 4, box 9]); assert_eq!(heap.len(), 3); assert!(*heap.peek().unwrap() == box 9); heap.push(box 11); diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index 9b5fbfc2511..5ca3cb38058 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -984,7 +984,7 @@ mod tests { #[test] fn test_basic() { - let mut m = LinkedList::new(); + let mut m = LinkedList::>::new(); assert_eq!(m.pop_front(), None); assert_eq!(m.pop_back(), None); assert_eq!(m.pop_front(), None); diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index b3706e20352..ecff2c7cc4b 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1509,6 +1509,7 @@ fn merge_sort(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Order #[cfg(test)] mod tests { + use alloc::boxed::Box; use core::cmp::Ordering::{Greater, Less, Equal}; use core::prelude::{Some, None, Clone}; use core::prelude::{Iterator, IteratorExt}; @@ -1799,7 +1800,7 @@ mod tests { #[test] fn test_swap_remove_noncopyable() { // Tests that we don't accidentally run destructors twice. - let mut v = Vec::new(); + let mut v: Vec> = Vec::new(); v.push(box 0u8); v.push(box 0u8); v.push(box 0u8); @@ -1828,7 +1829,7 @@ mod tests { #[test] fn test_truncate() { - let mut v = vec![box 6,box 5,box 4]; + let mut v: Vec> = vec![box 6,box 5,box 4]; v.truncate(1); let v = v; assert_eq!(v.len(), 1); @@ -1838,7 +1839,7 @@ mod tests { #[test] fn test_clear() { - let mut v = vec![box 6,box 5,box 4]; + let mut v: Vec> = vec![box 6,box 5,box 4]; v.clear(); assert_eq!(v.len(), 0); // If the unsafe block didn't drop things properly, we blow up here. @@ -1863,11 +1864,11 @@ mod tests { #[test] fn test_dedup_unique() { - let mut v0 = vec![box 1, box 1, box 2, box 3]; + let mut v0: Vec> = vec![box 1, box 1, box 2, box 3]; v0.dedup(); - let mut v1 = vec![box 1, box 2, box 2, box 3]; + let mut v1: Vec> = vec![box 1, box 2, box 2, box 3]; v1.dedup(); - let mut v2 = vec![box 1, box 2, box 3, box 3]; + let mut v2: Vec> = vec![box 1, box 2, box 3, box 3]; v2.dedup(); /* * If the boxed pointers were leaked or otherwise misused, valgrind @@ -1877,11 +1878,11 @@ mod tests { #[test] fn test_dedup_shared() { - let mut v0 = vec![box 1, box 1, box 2, box 3]; + let mut v0: Vec> = vec![box 1, box 1, box 2, box 3]; v0.dedup(); - let mut v1 = vec![box 1, box 2, box 2, box 3]; + let mut v1: Vec> = vec![box 1, box 2, box 2, box 3]; v1.dedup(); - let mut v2 = vec![box 1, box 2, box 3, box 3]; + let mut v2: Vec> = vec![box 1, box 2, box 3, box 3]; v2.dedup(); /* * If the pointers were leaked or otherwise misused, valgrind and/or @@ -2254,8 +2255,9 @@ mod tests { #[test] #[should_fail] fn test_permute_fail() { - let v = [(box 0, Rc::new(0)), (box 0, Rc::new(0)), - (box 0, Rc::new(0)), (box 0, Rc::new(0))]; + let v: [(Box<_>, Rc<_>); 4] = + [(box 0, Rc::new(0)), (box 0, Rc::new(0)), + (box 0, Rc::new(0)), (box 0, Rc::new(0))]; let mut i = 0; for _ in v.permutations() { if i == 2 { @@ -2849,7 +2851,7 @@ mod tests { #[test] fn test_to_vec() { - let xs = box [1, 2, 3]; + let xs: Box<_> = box [1, 2, 3]; let ys = xs.to_vec(); assert_eq!(ys, [1, 2, 3]); } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index a4d39974c70..2e947ea2460 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -2130,8 +2130,8 @@ mod tests { #[test] fn test_clone_from() { let mut v = vec!(); - let three = vec!(box 1, box 2, box 3); - let two = vec!(box 4, box 5); + let three: Vec> = vec!(box 1, box 2, box 3); + let two: Vec> = vec!(box 4, box 5); // zero, long v.clone_from(&three); assert_eq!(v, three); diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 5a0aa750bf5..515de74e340 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -1205,7 +1205,7 @@ mod test_map { #[test] fn test_move_iter() { - let mut m = VecMap::new(); + let mut m: VecMap> = VecMap::new(); m.insert(1, box 2); let mut called = false; for (k, v) in m { diff --git a/src/libcoretest/any.rs b/src/libcoretest/any.rs index 8b5e46f85fa..39f5d237a2b 100644 --- a/src/libcoretest/any.rs +++ b/src/libcoretest/any.rs @@ -68,7 +68,7 @@ fn any_downcast_ref() { #[test] fn any_downcast_mut() { let mut a = 5_usize; - let mut b = box 7_usize; + let mut b: Box<_> = box 7_usize; let a_r = &mut a as &mut Any; let tmp: &mut uint = &mut *b; diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs index 860bd40e21e..59116f23d44 100644 --- a/src/libcoretest/option.rs +++ b/src/libcoretest/option.rs @@ -16,7 +16,7 @@ use core::clone::Clone; #[test] fn test_get_ptr() { unsafe { - let x = box 0; + let x: Box<_> = box 0; let addr_x: *const int = mem::transmute(&*x); let opt = Some(x); let y = opt.unwrap(); diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index 8acb6851f11..844920ad5ec 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -606,7 +606,7 @@ mod tests { let tests = wikipedia_tests; - let mut sh = box Sha256::new(); + let mut sh: Box<_> = box Sha256::new(); test_hash(&mut *sh, &tests); } diff --git a/src/libstd/old_io/net/ip.rs b/src/libstd/old_io/net/ip.rs index 9c89c943994..f1634cd4229 100644 --- a/src/libstd/old_io/net/ip.rs +++ b/src/libstd/old_io/net/ip.rs @@ -323,22 +323,22 @@ impl<'a> Parser<'a> { } fn read_ip_addr(&mut self) -> Option { - let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr(); - let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr(); - self.read_or(&mut [box ipv4_addr, box ipv6_addr]) + let ipv4_addr: Box<_> = box |p: &mut Parser| p.read_ipv4_addr(); + let ipv6_addr: Box<_> = box |p: &mut Parser| p.read_ipv6_addr(); + self.read_or(&mut [ipv4_addr, ipv6_addr]) } fn read_socket_addr(&mut self) -> Option { let ip_addr = |p: &mut Parser| { - let ipv4_p = |p: &mut Parser| p.read_ip_addr(); - let ipv6_p = |p: &mut Parser| { + let ipv4_p: Box<_> = box |p: &mut Parser| p.read_ip_addr(); + let ipv6_p: Box<_> = box |p: &mut Parser| { let open_br = |p: &mut Parser| p.read_given_char('['); let ip_addr = |p: &mut Parser| p.read_ipv6_addr(); let clos_br = |p: &mut Parser| p.read_given_char(']'); p.read_seq_3::(open_br, ip_addr, clos_br) .map(|t| match t { (_, ip, _) => ip }) }; - p.read_or(&mut [box ipv4_p, box ipv6_p]) + p.read_or(&mut [ipv4_p, ipv6_p]) }; let colon = |p: &mut Parser| p.read_given_char(':'); let port = |p: &mut Parser| p.read_number(10, 5, 0x10000).map(|n| n as u16); diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index ee8bef50d89..1a1e9e69e71 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1044,13 +1044,13 @@ mod test { #[test] fn drop_full() { - let (tx, _rx) = channel(); + let (tx, _rx) = channel::>(); tx.send(box 1).unwrap(); } #[test] fn drop_full_shared() { - let (tx, _rx) = channel(); + let (tx, _rx) = channel::>(); drop(tx.clone()); drop(tx.clone()); tx.send(box 1).unwrap(); @@ -1389,7 +1389,7 @@ mod test { #[test] fn oneshot_multi_thread_send_recv_stress() { for _ in 0..stress_factor() { - let (tx, rx) = channel(); + let (tx, rx) = channel::>(); let _t = thread::spawn(move|| { tx.send(box 10).unwrap(); }); @@ -1566,7 +1566,7 @@ mod sync_tests { #[test] fn drop_full() { - let (tx, _rx) = sync_channel(1); + let (tx, _rx) = sync_channel::>(1); tx.send(box 1).unwrap(); } diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 59fa2e6bc9a..14ed253d8e2 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -164,7 +164,7 @@ mod tests { #[test] fn test_full() { - let q = Queue::new(); + let q: Queue> = Queue::new(); q.push(box 1); q.push(box 2); } diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index ce40fa2672a..3fb13739aa7 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -289,7 +289,7 @@ mod test { #[test] fn drop_full() { unsafe { - let q = Queue::new(0); + let q: Queue> = Queue::new(0); q.push(box 1); q.push(box 2); } diff --git a/src/libstd/thread.rs b/src/libstd/thread.rs index e8330820906..9be77e78ed1 100644 --- a/src/libstd/thread.rs +++ b/src/libstd/thread.rs @@ -804,7 +804,7 @@ mod test { fn avoid_copying_the_body(spawnfn: F) where F: FnOnce(Thunk<'static>) { let (tx, rx) = channel(); - let x = box 1; + let x: Box<_> = box 1; let x_in_parent = (&*x) as *const i32 as usize; spawnfn(Thunk::new(move|| { diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index f239a0d78d1..5cfe62d967c 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -146,7 +146,7 @@ impl Table { fn search_remainder(item: &mut Entry, key: Code, c: C) { match item.next { None => { - let mut entry = box Entry { + let mut entry: Box<_> = box Entry { code: key, count: 0, next: None, @@ -170,7 +170,7 @@ impl Table { { if self.items[index as usize].is_none() { - let mut entry = box Entry { + let mut entry: Box<_> = box Entry { code: key, count: 0, next: None, diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 40e1e7d2b76..f308743ad13 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -124,7 +124,7 @@ impl Sudoku { fn next_color(&mut self, row: u8, col: u8, start_color: u8) -> bool { if start_color < 10u8 { // colors not yet used - let mut avail = box Colors::new(start_color); + let mut avail: Box<_> = box Colors::new(start_color); // drop colors already in use in neighbourhood self.drop_colors(&mut *avail, row, col); diff --git a/src/test/compile-fail/borrow-tuple-fields.rs b/src/test/compile-fail/borrow-tuple-fields.rs index 40e077bd1b5..b1abbad5253 100644 --- a/src/test/compile-fail/borrow-tuple-fields.rs +++ b/src/test/compile-fail/borrow-tuple-fields.rs @@ -16,7 +16,7 @@ struct Foo(Box, isize); struct Bar(isize, isize); fn main() { - let x = (box 1, 2); + let x: (Box<_>, _) = (box 1, 2); let r = &x.0; let y = x; //~ ERROR cannot move out of `x` because it is borrowed diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs index 4d1939be5b9..7913f9ac903 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs @@ -23,7 +23,7 @@ fn add(v: &usize, w: usize) -> usize { } fn implicit() { - let mut a = box 1; + let mut a: Box<_> = box 1; // Note the danger here: // @@ -36,7 +36,7 @@ fn implicit() { } fn explicit() { - let mut a = box 1; + let mut a: Box<_> = box 1; add( &*a, rewrite(&mut a)); //~ ERROR cannot borrow diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs index 9eda3689334..e24d4e87add 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs @@ -23,7 +23,7 @@ fn add(v: &usize, w: Box) -> usize { } fn implicit() { - let mut a = box 1; + let mut a: Box<_> = box 1; // Note the danger here: // @@ -36,7 +36,7 @@ fn implicit() { } fn explicit() { - let mut a = box 1; + let mut a: Box<_> = box 1; add( &*a, a); //~ ERROR cannot move diff --git a/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs b/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs index 794e0fc6e3a..3662e23a412 100644 --- a/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs +++ b/src/test/compile-fail/borrowck-borrow-immut-deref-of-box-as-mut.rs @@ -18,7 +18,7 @@ impl A { } pub fn main() { - let a = box A; + let a: Box<_> = box A; a.foo(); //~^ ERROR cannot borrow immutable `Box` content `*a` as mutable } diff --git a/src/test/compile-fail/borrowck-box-insensitivity.rs b/src/test/compile-fail/borrowck-box-insensitivity.rs index 648d0d81ffb..59514f75a77 100644 --- a/src/test/compile-fail/borrowck-box-insensitivity.rs +++ b/src/test/compile-fail/borrowck-box-insensitivity.rs @@ -31,100 +31,100 @@ struct D { } fn copy_after_move() { - let a = box A { x: box 0, y: 1 }; + let a: Box<_> = box A { x: box 0, y: 1 }; let _x = a.x; let _y = a.y; //~ ERROR use of moved //~^^ NOTE `a` moved here (through moving `a.x`) } fn move_after_move() { - let a = box B { x: box 0, y: box 1 }; + let a: Box<_> = box B { x: box 0, y: box 1 }; let _x = a.x; let _y = a.y; //~ ERROR use of moved //~^^ NOTE `a` moved here (through moving `a.x`) } fn borrow_after_move() { - let a = box A { x: box 0, y: 1 }; + let a: Box<_> = box A { x: box 0, y: 1 }; let _x = a.x; let _y = &a.y; //~ ERROR use of moved //~^^ NOTE `a` moved here (through moving `a.x`) } fn move_after_borrow() { - let a = box B { x: box 0, y: box 1 }; + let a: Box<_> = box B { x: box 0, y: box 1 }; let _x = &a.x; let _y = a.y; //~ ERROR cannot move } fn copy_after_mut_borrow() { - let mut a = box A { x: box 0, y: 1 }; + let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &mut a.x; let _y = a.y; //~ ERROR cannot use } fn move_after_mut_borrow() { - let mut a = box B { x: box 0, y: box 1 }; + let mut a: Box<_> = box B { x: box 0, y: box 1 }; let _x = &mut a.x; let _y = a.y; //~ ERROR cannot move } fn borrow_after_mut_borrow() { - let mut a = box A { x: box 0, y: 1 }; + let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &mut a.x; let _y = &a.y; //~ ERROR cannot borrow } fn mut_borrow_after_borrow() { - let mut a = box A { x: box 0, y: 1 }; + let mut a: Box<_> = box A { x: box 0, y: 1 }; let _x = &a.x; let _y = &mut a.y; //~ ERROR cannot borrow } fn copy_after_move_nested() { - let a = box C { x: box A { x: box 0, y: 1 }, y: 2 }; + let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = a.x.x; let _y = a.y; //~ ERROR use of collaterally moved } fn move_after_move_nested() { - let a = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; + let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = a.x.x; let _y = a.y; //~ ERROR use of collaterally moved } fn borrow_after_move_nested() { - let a = box C { x: box A { x: box 0, y: 1 }, y: 2 }; + let a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = a.x.x; let _y = &a.y; //~ ERROR use of collaterally moved } fn move_after_borrow_nested() { - let a = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; + let a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = &a.x.x; let _y = a.y; //~ ERROR cannot move } fn copy_after_mut_borrow_nested() { - let mut a = box C { x: box A { x: box 0, y: 1 }, y: 2 }; + let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &mut a.x.x; let _y = a.y; //~ ERROR cannot use } fn move_after_mut_borrow_nested() { - let mut a = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; + let mut a: Box<_> = box D { x: box A { x: box 0, y: 1 }, y: box 2 }; let _x = &mut a.x.x; let _y = a.y; //~ ERROR cannot move } fn borrow_after_mut_borrow_nested() { - let mut a = box C { x: box A { x: box 0, y: 1 }, y: 2 }; + let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &mut a.x.x; let _y = &a.y; //~ ERROR cannot borrow } fn mut_borrow_after_borrow_nested() { - let mut a = box C { x: box A { x: box 0, y: 1 }, y: 2 }; + let mut a: Box<_> = box C { x: box A { x: box 0, y: 1 }, y: 2 }; let _x = &a.x.x; let _y = &mut a.y; //~ ERROR cannot borrow } diff --git a/src/test/compile-fail/borrowck-closures-mut-and-imm.rs b/src/test/compile-fail/borrowck-closures-mut-and-imm.rs index 851b11fac2b..aaa07661215 100644 --- a/src/test/compile-fail/borrowck-closures-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck-closures-mut-and-imm.rs @@ -52,7 +52,7 @@ fn e() { } fn f() { - let mut x = box 3; + let mut x: Box<_> = box 3; let c1 = || get(&*x); *x = 5; //~ ERROR cannot assign } @@ -62,7 +62,7 @@ fn g() { f: Box } - let mut x = box Foo { f: box 3 }; + let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); *x.f = 5; //~ ERROR cannot assign to `*x.f` } @@ -72,7 +72,7 @@ fn h() { f: Box } - let mut x = box Foo { f: box 3 }; + let mut x: Box<_> = box Foo { f: box 3 }; let c1 = || get(&*x.f); let c2 = || *x.f = 5; //~ ERROR cannot borrow `x` as mutable } diff --git a/src/test/compile-fail/borrowck-closures-two-mut.rs b/src/test/compile-fail/borrowck-closures-two-mut.rs index 8ab4e257b06..29546abe0bb 100644 --- a/src/test/compile-fail/borrowck-closures-two-mut.rs +++ b/src/test/compile-fail/borrowck-closures-two-mut.rs @@ -50,7 +50,7 @@ fn g() { f: Box } - let mut x = box Foo { f: box 3 }; + let mut x: Box<_> = box Foo { f: box 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 diff --git a/src/test/compile-fail/borrowck-closures-use-after-free.rs b/src/test/compile-fail/borrowck-closures-use-after-free.rs index 32cd364d1f2..bb474342a7c 100644 --- a/src/test/compile-fail/borrowck-closures-use-after-free.rs +++ b/src/test/compile-fail/borrowck-closures-use-after-free.rs @@ -25,7 +25,7 @@ impl Drop for Foo { } fn main() { - let mut ptr = box Foo { x: 0 }; + let mut ptr: Box<_> = box Foo { x: 0 }; let mut test = |foo: &Foo| { ptr = box Foo { x: ptr.x + 1 }; }; diff --git a/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs b/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs index 492fd4a2c84..b6b26006555 100644 --- a/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs +++ b/src/test/compile-fail/borrowck-for-loop-correct-cmt-for-pattern.rs @@ -28,7 +28,7 @@ fn main() { for &a in &f.a { //~ ERROR cannot move out } - let x = Some(box 1); + let x: Option> = Some(box 1); for &a in x.iter() { //~ ERROR cannot move out } } diff --git a/src/test/compile-fail/borrowck-issue-14498.rs b/src/test/compile-fail/borrowck-issue-14498.rs index cc562afa9f8..deae1fbad20 100644 --- a/src/test/compile-fail/borrowck-issue-14498.rs +++ b/src/test/compile-fail/borrowck-issue-14498.rs @@ -18,7 +18,7 @@ struct B<'a> { a: Box<&'a mut isize> } fn borrow_in_var_from_var() { let mut x: isize = 1; - let y = box &mut x; + let y: Box<_> = box &mut x; let p = &y; let q = &***p; **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed @@ -28,7 +28,7 @@ fn borrow_in_var_from_var() { fn borrow_in_var_from_field() { let mut x = A { a: 1 }; - let y = box &mut x.a; + let y: Box<_> = box &mut x.a; let p = &y; let q = &***p; **y = 2; //~ ERROR cannot assign to `**y` because it is borrowed diff --git a/src/test/compile-fail/borrowck-issue-2657-1.rs b/src/test/compile-fail/borrowck-issue-2657-1.rs index 0c717d2ee5f..0e1712137d3 100644 --- a/src/test/compile-fail/borrowck-issue-2657-1.rs +++ b/src/test/compile-fail/borrowck-issue-2657-1.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] fn main() { - let x = Some(box 1); + let x: Option> = Some(box 1); match x { Some(ref _y) => { let _a = x; //~ ERROR cannot move diff --git a/src/test/compile-fail/borrowck-issue-2657-2.rs b/src/test/compile-fail/borrowck-issue-2657-2.rs index b4e5ae1c25b..a389a4a5593 100644 --- a/src/test/compile-fail/borrowck-issue-2657-2.rs +++ b/src/test/compile-fail/borrowck-issue-2657-2.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] fn main() { - let x = Some(box 1); + let x: Option> = Some(box 1); match x { Some(ref y) => { let _b = *y; //~ ERROR cannot move out diff --git a/src/test/compile-fail/borrowck-lend-flow-if.rs b/src/test/compile-fail/borrowck-lend-flow-if.rs index ca8efb5dc96..0efe8622621 100644 --- a/src/test/compile-fail/borrowck-lend-flow-if.rs +++ b/src/test/compile-fail/borrowck-lend-flow-if.rs @@ -30,7 +30,7 @@ fn pre_freeze_cond() { // In this instance, the freeze is conditional and starts before // the mut borrow. - let mut v = box 3; + let mut v: Box<_> = box 3; let _w; if cond() { _w = &v; @@ -42,7 +42,7 @@ fn pre_freeze_else() { // In this instance, the freeze and mut borrow are on separate sides // of the if. - let mut v = box 3; + let mut v: Box<_> = box 3; let _w; if cond() { _w = &v; diff --git a/src/test/compile-fail/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck-lend-flow-loop.rs index 5418a531fe6..f841fedf75a 100644 --- a/src/test/compile-fail/borrowck-lend-flow-loop.rs +++ b/src/test/compile-fail/borrowck-lend-flow-loop.rs @@ -28,7 +28,7 @@ fn inc(v: &mut Box) { fn loop_overarching_alias_mut() { // In this instance, the borrow encompasses the entire loop. - let mut v = box 3; + let mut v: Box<_> = box 3; let mut x = &mut v; **x += 1; loop { @@ -39,7 +39,7 @@ fn loop_overarching_alias_mut() { fn block_overarching_alias_mut() { // In this instance, the borrow encompasses the entire closure call. - let mut v = box 3; + let mut v: Box<_> = box 3; let mut x = &mut v; for _ in 0..3 { borrow(&*v); //~ ERROR cannot borrow @@ -50,8 +50,8 @@ fn block_overarching_alias_mut() { fn loop_aliased_mut() { // In this instance, the borrow is carried through the loop. - let mut v = box 3; - let mut w = box 4; + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; let mut _x = &w; loop { borrow_mut(&mut *v); //~ ERROR cannot borrow @@ -62,8 +62,8 @@ fn loop_aliased_mut() { fn while_aliased_mut() { // In this instance, the borrow is carried through the loop. - let mut v = box 3; - let mut w = box 4; + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; let mut _x = &w; while cond() { borrow_mut(&mut *v); //~ ERROR cannot borrow @@ -75,8 +75,8 @@ fn while_aliased_mut() { fn loop_aliased_mut_break() { // In this instance, the borrow is carried through the loop. - let mut v = box 3; - let mut w = box 4; + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; let mut _x = &w; loop { borrow_mut(&mut *v); @@ -89,8 +89,8 @@ fn loop_aliased_mut_break() { fn while_aliased_mut_break() { // In this instance, the borrow is carried through the loop. - let mut v = box 3; - let mut w = box 4; + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; let mut _x = &w; while cond() { borrow_mut(&mut *v); @@ -101,8 +101,8 @@ fn while_aliased_mut_break() { } fn while_aliased_mut_cond(cond: bool, cond2: bool) { - let mut v = box 3; - let mut w = box 4; + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; let mut x = &mut w; while cond { **x += 1; diff --git a/src/test/compile-fail/borrowck-lend-flow.rs b/src/test/compile-fail/borrowck-lend-flow.rs index 177976c15f0..6da8f088b32 100644 --- a/src/test/compile-fail/borrowck-lend-flow.rs +++ b/src/test/compile-fail/borrowck-lend-flow.rs @@ -29,7 +29,7 @@ fn inc(v: &mut Box) { fn pre_freeze() { // In this instance, the freeze starts before the mut borrow. - let mut v = box 3; + let mut v: Box<_> = box 3; let _w = &v; borrow_mut(&mut *v); //~ ERROR cannot borrow } @@ -37,7 +37,7 @@ fn pre_freeze() { fn post_freeze() { // In this instance, the const alias starts after the borrow. - let mut v = box 3; + let mut v: Box<_> = box 3; borrow_mut(&mut *v); let _w = &v; } diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index 7f676f5166f..57b584a8959 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -17,7 +17,7 @@ fn borrow(v: &isize, f: F) where F: FnOnce(&isize) { } fn box_imm() { - let v = box 3; + let v: Box<_> = box 3; let _w = &v; thread::spawn(move|| { println!("v={}", *v); @@ -26,7 +26,7 @@ fn box_imm() { } fn box_imm_explicit() { - let v = box 3; + let v: Box<_> = box 3; let _w = &v; thread::spawn(move|| { println!("v={}", *v); diff --git a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs index a52a4484b20..32d8088549d 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs @@ -15,7 +15,7 @@ fn borrow(v: &isize, f: F) where F: FnOnce(&isize) { } fn box_imm() { - let mut v = box 3; + let mut v: Box<_> = box 3; borrow(&*v, |w| { //~ ERROR cannot borrow `v` as mutable v = box 4; diff --git a/src/test/compile-fail/borrowck-move-by-capture.rs b/src/test/compile-fail/borrowck-move-by-capture.rs index a1708e7f497..bad52121043 100644 --- a/src/test/compile-fail/borrowck-move-by-capture.rs +++ b/src/test/compile-fail/borrowck-move-by-capture.rs @@ -14,7 +14,7 @@ fn to_fn_mut>(f: F) -> F { f } fn to_fn_once>(f: F) -> F { f } pub fn main() { - let bar = box 3; + let bar: Box<_> = box 3; let _g = to_fn_mut(|| { let _h = to_fn_once(move || -> isize { *bar }); //~ ERROR cannot move out of }); diff --git a/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs b/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs index 3d8d599970f..c02c6a71514 100644 --- a/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs +++ b/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs @@ -14,7 +14,7 @@ #![feature(box_syntax)] fn main() { - let a = box box 2; + let a: Box> = box box 2; let b = &a; let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed diff --git a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs index 43bf3f25d1a..c46bcbb32b9 100644 --- a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs +++ b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs @@ -15,7 +15,7 @@ fn call_f isize>(f: F) -> isize { } fn main() { - let t = box 3; + let t: Box<_> = box 3; call_f(move|| { *t + 1 }); call_f(move|| { *t + 1 }); //~ ERROR capture of moved value diff --git a/src/test/compile-fail/borrowck-multiple-captures.rs b/src/test/compile-fail/borrowck-multiple-captures.rs index 9db05d76284..f417416e7b5 100644 --- a/src/test/compile-fail/borrowck-multiple-captures.rs +++ b/src/test/compile-fail/borrowck-multiple-captures.rs @@ -15,9 +15,9 @@ use std::thread; fn borrow(_: &T) { } fn different_vars_after_borrows() { - let x1 = box 1; + let x1: Box<_> = box 1; let p1 = &x1; - let x2 = box 2; + let x2: Box<_> = box 2; let p2 = &x2; thread::spawn(move|| { drop(x1); //~ ERROR cannot move `x1` into closure because it is borrowed @@ -28,9 +28,9 @@ fn different_vars_after_borrows() { } fn different_vars_after_moves() { - let x1 = box 1; + let x1: Box<_> = box 1; drop(x1); - let x2 = box 2; + let x2: Box<_> = box 2; drop(x2); thread::spawn(move|| { drop(x1); //~ ERROR capture of moved value: `x1` @@ -39,7 +39,7 @@ fn different_vars_after_moves() { } fn same_var_after_borrow() { - let x = box 1; + let x: Box<_> = box 1; let p = &x; thread::spawn(move|| { drop(x); //~ ERROR cannot move `x` into closure because it is borrowed @@ -49,7 +49,7 @@ fn same_var_after_borrow() { } fn same_var_after_move() { - let x = box 1; + let x: Box<_> = box 1; drop(x); thread::spawn(move|| { drop(x); //~ ERROR capture of moved value: `x` diff --git a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs index 6985d203fb1..8cb7423f3cb 100644 --- a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs +++ b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs @@ -19,7 +19,7 @@ enum cycle { empty } fn main() { - let mut x = box cycle::node(node_ {a: box cycle::empty}); + let mut x: Box<_> = box cycle::node(node_ {a: box cycle::empty}); // Create a cycle! match *x { cycle::node(ref mut y) => { diff --git a/src/test/compile-fail/borrowck-overloaded-index-2.rs b/src/test/compile-fail/borrowck-overloaded-index-2.rs index e9d8544a06a..58668b73cbf 100644 --- a/src/test/compile-fail/borrowck-overloaded-index-2.rs +++ b/src/test/compile-fail/borrowck-overloaded-index-2.rs @@ -25,7 +25,7 @@ impl Index for MyVec { } fn main() { - let v = MyVec { data: vec!(box 1, box 2, box 3) }; + let v = MyVec::> { data: vec!(box 1, box 2, box 3) }; let good = &v[0]; // Shouldn't fail here let bad = v[0]; //~^ ERROR cannot move out of indexed content diff --git a/src/test/compile-fail/borrowck-uniq-via-lend.rs b/src/test/compile-fail/borrowck-uniq-via-lend.rs index 49a1b782a3d..f36dc0ca43f 100644 --- a/src/test/compile-fail/borrowck-uniq-via-lend.rs +++ b/src/test/compile-fail/borrowck-uniq-via-lend.rs @@ -13,7 +13,7 @@ fn borrow(_v: &isize) {} fn local() { - let mut v = box 3; + let mut v: Box<_> = box 3; borrow(&*v); } @@ -32,27 +32,27 @@ fn local_recs() { } fn aliased_imm() { - let mut v = box 3; + let mut v: Box<_> = box 3; let _w = &v; borrow(&*v); } fn aliased_mut() { - let mut v = box 3; + let mut v: Box<_> = box 3; let _w = &mut v; borrow(&*v); //~ ERROR cannot borrow `*v` } fn aliased_other() { - let mut v = box 3; - let mut w = box 4; + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; let _x = &mut w; borrow(&*v); } fn aliased_other_reassign() { - let mut v = box 3; - let mut w = box 4; + let mut v: Box<_> = box 3; + let mut w: Box<_> = box 4; let mut _x = &mut w; _x = &mut v; borrow(&*v); //~ ERROR cannot borrow `*v` diff --git a/src/test/compile-fail/issue-10398.rs b/src/test/compile-fail/issue-10398.rs index 736f9630127..08e8effc626 100644 --- a/src/test/compile-fail/issue-10398.rs +++ b/src/test/compile-fail/issue-10398.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] fn main() { - let x = box 1; + let x: Box<_> = box 1; let f = move|| { let _a = x; drop(x); diff --git a/src/test/compile-fail/issue-11192.rs b/src/test/compile-fail/issue-11192.rs index a95bcc73a9c..7313d357ffc 100644 --- a/src/test/compile-fail/issue-11192.rs +++ b/src/test/compile-fail/issue-11192.rs @@ -21,7 +21,7 @@ impl Drop for Foo { } fn main() { - let mut ptr = box Foo { x: 0 }; + let mut ptr: Box<_> = box Foo { x: 0 }; let mut test = |foo: &Foo| { println!("access {}", foo.x); ptr = box Foo { x: ptr.x + 1 }; diff --git a/src/test/compile-fail/issue-11925.rs b/src/test/compile-fail/issue-11925.rs index df4dab2552e..7bd072c6268 100644 --- a/src/test/compile-fail/issue-11925.rs +++ b/src/test/compile-fail/issue-11925.rs @@ -14,7 +14,7 @@ fn to_fn_once>(f: F) -> F { f } fn main() { let r = { - let x = box 42; + let x: Box<_> = box 42; let f = to_fn_once(move|| &x); //~ ERROR: `x` does not live long enough f() }; diff --git a/src/test/compile-fail/issue-12127.rs b/src/test/compile-fail/issue-12127.rs index 40d446b91a5..5565a9a5761 100644 --- a/src/test/compile-fail/issue-12127.rs +++ b/src/test/compile-fail/issue-12127.rs @@ -14,7 +14,7 @@ fn to_fn_once>(f: F) -> F { f } fn do_it(x: &isize) { } fn main() { - let x = box 22; + let x: Box<_> = box 22; let f = to_fn_once(move|| do_it(&*x)); to_fn_once(move|| { f(); diff --git a/src/test/compile-fail/issue-17263.rs b/src/test/compile-fail/issue-17263.rs index 543063b3fc9..f40d51f1d2f 100644 --- a/src/test/compile-fail/issue-17263.rs +++ b/src/test/compile-fail/issue-17263.rs @@ -13,12 +13,12 @@ struct Foo { a: isize, b: isize } fn main() { - let mut x = box Foo { a: 1, b: 2 }; + let mut x: Box<_> = box Foo { a: 1, b: 2 }; let (a, b) = (&mut x.a, &mut x.b); //~^ ERROR cannot borrow `x` (here through borrowing `x.b`) as mutable more than once at a time //~^^ NOTE previous borrow of `x` occurs here (through borrowing `x.a`) - let mut foo = box Foo { a: 1, b: 2 }; + let mut foo: Box<_> = box Foo { a: 1, b: 2 }; let (c, d) = (&mut foo.a, &foo.b); //~^ ERROR cannot borrow `foo` (here through borrowing `foo.b`) as immutable //~^^ NOTE previous borrow of `foo` occurs here (through borrowing `foo.a`) diff --git a/src/test/compile-fail/issue-17913.rs b/src/test/compile-fail/issue-17913.rs index 8035cffabda..80e5f2b6e21 100644 --- a/src/test/compile-fail/issue-17913.rs +++ b/src/test/compile-fail/issue-17913.rs @@ -16,13 +16,13 @@ #[cfg(target_pointer_width = "64")] fn main() { let n = 0_usize; - let a = box [&n; 0xF000000000000000_usize]; + let a: Box<_> = box [&n; 0xF000000000000000_usize]; println!("{}", a[0xFFFFFF_usize]); } #[cfg(target_pointer_width = "32")] fn main() { let n = 0_usize; - let a = box [&n; 0xFFFFFFFF_usize]; + let a: Box<_> = box [&n; 0xFFFFFFFF_usize]; println!("{}", a[0xFFFFFF_usize]); } diff --git a/src/test/compile-fail/kindck-impl-type-params-2.rs b/src/test/compile-fail/kindck-impl-type-params-2.rs index b575144f637..fd0789421e0 100644 --- a/src/test/compile-fail/kindck-impl-type-params-2.rs +++ b/src/test/compile-fail/kindck-impl-type-params-2.rs @@ -21,7 +21,7 @@ impl Foo for T { fn take_param(foo: &T) { } fn main() { - let x = box 3; + let x: Box<_> = box 3; take_param(&x); //~^ ERROR the trait `core::marker::Copy` is not implemented } diff --git a/src/test/compile-fail/kindck-inherited-copy-bound.rs b/src/test/compile-fail/kindck-inherited-copy-bound.rs index 0072b1228af..52ca24d0f54 100644 --- a/src/test/compile-fail/kindck-inherited-copy-bound.rs +++ b/src/test/compile-fail/kindck-inherited-copy-bound.rs @@ -24,12 +24,12 @@ impl Foo for T { fn take_param(foo: &T) { } fn a() { - let x = box 3; + let x: Box<_> = box 3; take_param(&x); //~ ERROR `core::marker::Copy` is not implemented } fn b() { - let x = box 3; + let x: Box<_> = box 3; let y = &x; let z = &x as &Foo; //~ ERROR `core::marker::Copy` is not implemented } diff --git a/src/test/compile-fail/liveness-use-after-move.rs b/src/test/compile-fail/liveness-use-after-move.rs index 985eb1cd7ba..6fcab380030 100644 --- a/src/test/compile-fail/liveness-use-after-move.rs +++ b/src/test/compile-fail/liveness-use-after-move.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] fn main() { - let x = box 5; + let x: Box<_> = box 5; let y = x; println!("{}", *x); //~ ERROR use of moved value: `*x` y.clone(); diff --git a/src/test/compile-fail/move-in-guard-1.rs b/src/test/compile-fail/move-in-guard-1.rs index 5d29d0e1fd0..068bfa3cd7c 100644 --- a/src/test/compile-fail/move-in-guard-1.rs +++ b/src/test/compile-fail/move-in-guard-1.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] pub fn main() { - let x = box 1; + let x: Box<_> = box 1; let v = (1, 2); diff --git a/src/test/compile-fail/move-in-guard-2.rs b/src/test/compile-fail/move-in-guard-2.rs index 23af2579797..984963b2f83 100644 --- a/src/test/compile-fail/move-in-guard-2.rs +++ b/src/test/compile-fail/move-in-guard-2.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] pub fn main() { - let x = box 1; + let x: Box<_> = box 1; let v = (1, 2); diff --git a/src/test/compile-fail/move-out-of-tuple-field.rs b/src/test/compile-fail/move-out-of-tuple-field.rs index 7e3a85569d4..b7393666719 100644 --- a/src/test/compile-fail/move-out-of-tuple-field.rs +++ b/src/test/compile-fail/move-out-of-tuple-field.rs @@ -13,7 +13,7 @@ struct Foo(Box); fn main() { - let x = (box 1,); + let x: (Box<_>,) = (box 1,); let y = x.0; let z = x.0; //~ ERROR use of moved value: `x.0` diff --git a/src/test/compile-fail/mut-cross-borrowing.rs b/src/test/compile-fail/mut-cross-borrowing.rs index 2cf6e67a909..6829cd574e1 100644 --- a/src/test/compile-fail/mut-cross-borrowing.rs +++ b/src/test/compile-fail/mut-cross-borrowing.rs @@ -13,7 +13,7 @@ fn f(_: &mut isize) {} fn main() { - let mut x = box 3; + let mut x: Box<_> = box 3; f(x) //~ ERROR mismatched types } diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index 200aa989193..eca22bfdda0 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -13,7 +13,7 @@ fn f(_: T) {} fn main() { - let x = box 3; + let x: Box<_> = box 3; f(x); let x = &3; //~ ERROR borrowed value does not live long enough f(x); diff --git a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs index 1998f8ab155..26d22b072eb 100644 --- a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs +++ b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs @@ -34,8 +34,8 @@ impl List { } fn main() { - let n = box Number { n: 42 }; - let mut l = box List { list: Vec::new() }; + let n: Box<_> = box Number { n: 42 }; + let mut l: Box<_> = box List { list: Vec::new() }; l.push(n); let x = n.to_string(); //~^ ERROR: use of moved value: `n` diff --git a/src/test/debuginfo/borrowed-struct.rs b/src/test/debuginfo/borrowed-struct.rs index 2cfc6855e5b..4430ea9380d 100644 --- a/src/test/debuginfo/borrowed-struct.rs +++ b/src/test/debuginfo/borrowed-struct.rs @@ -78,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 SomeStruct { x: 13, y: 26.5 }; + let unique_val: Box<_> = box SomeStruct { x: 13, y: 26.5 }; let unique_val_ref: &SomeStruct = &*unique_val; let unique_val_interior_ref_1: &int = &unique_val.x; let unique_val_interior_ref_2: &f64 = &unique_val.y; diff --git a/src/test/debuginfo/boxed-struct.rs b/src/test/debuginfo/boxed-struct.rs index 972d6ab12e1..9c6e197e65e 100644 --- a/src/test/debuginfo/boxed-struct.rs +++ b/src/test/debuginfo/boxed-struct.rs @@ -57,9 +57,9 @@ impl Drop for StructWithDestructor { fn main() { - let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }; + let unique: Box<_> = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }; - let unique_dtor = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }; + let unique_dtor: Box<_> = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }; zzz(); // #break } diff --git a/src/test/debuginfo/generic-method-on-generic-struct.rs b/src/test/debuginfo/generic-method-on-generic-struct.rs index 8c4eeb27c0f..8b698d900af 100644 --- a/src/test/debuginfo/generic-method-on-generic-struct.rs +++ b/src/test/debuginfo/generic-method-on-generic-struct.rs @@ -142,7 +142,7 @@ fn main() { let _ = stack.self_by_ref(-1, 2_u16); let _ = stack.self_by_val(-3, -4_i16); - let owned = box Struct { x: 1234.5f64 }; + let owned: Box<_> = box 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); diff --git a/src/test/debuginfo/method-on-enum.rs b/src/test/debuginfo/method-on-enum.rs index 7ad668791d3..638d73f0d4e 100644 --- a/src/test/debuginfo/method-on-enum.rs +++ b/src/test/debuginfo/method-on-enum.rs @@ -144,7 +144,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = box Enum::Variant1{ x: 1799, y: 1799 }; + let owned: Box<_> = box 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); diff --git a/src/test/debuginfo/method-on-generic-struct.rs b/src/test/debuginfo/method-on-generic-struct.rs index 6b56a7998c9..784d60eec9a 100644 --- a/src/test/debuginfo/method-on-generic-struct.rs +++ b/src/test/debuginfo/method-on-generic-struct.rs @@ -143,7 +143,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = box Struct { x: 1234.5f64 }; + let owned: Box<_> = box Struct { x: 1234.5f64 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debuginfo/method-on-struct.rs b/src/test/debuginfo/method-on-struct.rs index e32288a8e7d..a91586a6aa6 100644 --- a/src/test/debuginfo/method-on-struct.rs +++ b/src/test/debuginfo/method-on-struct.rs @@ -143,7 +143,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = box Struct { x: 200 }; + let owned: Box<_> = box Struct { x: 200 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debuginfo/method-on-trait.rs b/src/test/debuginfo/method-on-trait.rs index 6e9a695720a..e2c827ee517 100644 --- a/src/test/debuginfo/method-on-trait.rs +++ b/src/test/debuginfo/method-on-trait.rs @@ -149,7 +149,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = box Struct { x: 200 }; + let owned: Box<_> = box Struct { x: 200 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debuginfo/method-on-tuple-struct.rs b/src/test/debuginfo/method-on-tuple-struct.rs index cee04e92c2d..e8bc40f1810 100644 --- a/src/test/debuginfo/method-on-tuple-struct.rs +++ b/src/test/debuginfo/method-on-tuple-struct.rs @@ -141,7 +141,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = box TupleStruct(200, -200.5); + let owned: Box<_> = box TupleStruct(200, -200.5); let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debuginfo/self-in-default-method.rs b/src/test/debuginfo/self-in-default-method.rs index cb2b04f4d86..03a79993342 100644 --- a/src/test/debuginfo/self-in-default-method.rs +++ b/src/test/debuginfo/self-in-default-method.rs @@ -143,7 +143,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = box Struct { x: 200 }; + let owned: Box<_> = box Struct { x: 200 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debuginfo/self-in-generic-default-method.rs b/src/test/debuginfo/self-in-generic-default-method.rs index b96ec3b7b88..5869625bafe 100644 --- a/src/test/debuginfo/self-in-generic-default-method.rs +++ b/src/test/debuginfo/self-in-generic-default-method.rs @@ -144,7 +144,7 @@ fn main() { let _ = stack.self_by_ref(-1, 2_u16); let _ = stack.self_by_val(-3, -4_i16); - let owned = box Struct { x: 879 }; + let owned: Box<_> = box 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); diff --git a/src/test/debuginfo/unique-enum.rs b/src/test/debuginfo/unique-enum.rs index 69b5797007b..607a237d22e 100644 --- a/src/test/debuginfo/unique-enum.rs +++ b/src/test/debuginfo/unique-enum.rs @@ -67,15 +67,15 @@ fn main() { // 0b01111100011111000111110001111100 = 2088533116 // 0b0111110001111100 = 31868 // 0b01111100 = 124 - let the_a = box ABC::TheA { x: 0, y: 8970181431921507452 }; + let the_a: Box<_> = box ABC::TheA { x: 0, y: 8970181431921507452 }; // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 // 0b00010001000100010001000100010001 = 286331153 // 0b0001000100010001 = 4369 // 0b00010001 = 17 - let the_b = box ABC::TheB (0, 286331153, 286331153); + let the_b: Box<_> = box ABC::TheB (0, 286331153, 286331153); - let univariant = box Univariant::TheOnlyCase(123234); + let univariant: Box<_> = box Univariant::TheOnlyCase(123234); zzz(); // #break } diff --git a/src/test/debuginfo/var-captured-in-nested-closure.rs b/src/test/debuginfo/var-captured-in-nested-closure.rs index 9c9d82249ee..05872e3fc36 100644 --- a/src/test/debuginfo/var-captured-in-nested-closure.rs +++ b/src/test/debuginfo/var-captured-in-nested-closure.rs @@ -98,7 +98,7 @@ fn main() { }; let struct_ref = &a_struct; - let owned = box 6; + let owned: Box<_> = box 6; let mut closure = || { let closure_local = 8; diff --git a/src/test/debuginfo/var-captured-in-sendable-closure.rs b/src/test/debuginfo/var-captured-in-sendable-closure.rs index 3c442c95e0f..295d57f4cfa 100644 --- a/src/test/debuginfo/var-captured-in-sendable-closure.rs +++ b/src/test/debuginfo/var-captured-in-sendable-closure.rs @@ -58,7 +58,7 @@ fn main() { c: 4 }; - let owned = box 5; + let owned: Box<_> = box 5; let closure = move || { zzz(); // #break diff --git a/src/test/debuginfo/var-captured-in-stack-closure.rs b/src/test/debuginfo/var-captured-in-stack-closure.rs index e3bd1eade75..57dcac409ba 100644 --- a/src/test/debuginfo/var-captured-in-stack-closure.rs +++ b/src/test/debuginfo/var-captured-in-stack-closure.rs @@ -90,7 +90,7 @@ fn main() { }; let struct_ref = &a_struct; - let owned = box 6; + let owned: Box<_> = box 6; { let mut first_closure = || { diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 9e88eb6da6a..8121edfd2cc 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -20,6 +20,6 @@ impl double for uint { } pub fn main() { - let x = box() (box 3_usize as Box); + let x: Box<_> = box() (box 3_usize as Box); assert_eq!(x.double(), 6_usize); } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index 67dd25ddc53..537894bfd15 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -24,6 +24,6 @@ impl double for Box { } pub fn main() { - let x = box 3_usize; + let x: Box<_> = box 3_usize; assert_eq!(x.double(), 6_usize); } diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index 6437c78161c..2ffdd576ffb 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -20,6 +20,6 @@ impl double for Box { } pub fn main() { - let x = box box box box box 3_usize; + let x: Box>>>> = box box box box box 3_usize; assert_eq!(x.double(), 6_usize); } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index 8cbc151f0cd..82510aea162 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -20,6 +20,6 @@ impl double for uint { } pub fn main() { - let x = box box 3_usize; + let x: Box> = box box 3_usize; assert_eq!(x.double(), 6_usize); } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index c8fa3c9fd5f..c9aa1133101 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -20,6 +20,6 @@ impl double for uint { } pub fn main() { - let x = box 3_usize; + let x: Box<_> = box 3_usize; assert_eq!(x.double(), 6_usize); } diff --git a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs index 87157b9334f..6e6e58a7ddf 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -29,6 +29,6 @@ impl Foo for uint { } pub fn main() { - let x = box 3_usize; + let x: Box<_> = box 3_usize; assert_eq!(x.foo(), "box 3".to_string()); } diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index 7bb9f042fe8..24bfbd9eb44 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -16,8 +16,8 @@ extern crate collections; use std::collections::BitVec; fn bitv_test() { - let mut v1 = box BitVec::from_elem(31, false); - let v2 = box BitVec::from_elem(31, true); + let mut v1: Box<_> = box BitVec::from_elem(31, false); + let v2: Box<_> = box BitVec::from_elem(31, true); v1.union(&*v2); } diff --git a/src/test/run-pass/borrowck-move-by-capture-ok.rs b/src/test/run-pass/borrowck-move-by-capture-ok.rs index 1be57674fa1..27fbfc96410 100644 --- a/src/test/run-pass/borrowck-move-by-capture-ok.rs +++ b/src/test/run-pass/borrowck-move-by-capture-ok.rs @@ -13,7 +13,7 @@ #![feature(unboxed_closures)] pub fn main() { - let bar = box 3; + let bar: Box<_> = box 3; let h = || -> int *bar; assert_eq!(h(), 3); } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 2dbaec8fbb1..499650a6e51 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -30,7 +30,7 @@ fn iter_ints(x: &Ints, mut f: F) -> bool where F: FnMut(&int) -> bool { } pub fn main() { - let mut ints = box Ints {sum: box 0, values: Vec::new()}; + let mut ints: Box<_> = box Ints {sum: box 0, values: Vec::new()}; add_int(&mut *ints, 22); add_int(&mut *ints, 44); diff --git a/src/test/run-pass/cci_borrow.rs b/src/test/run-pass/cci_borrow.rs index 00c600ed006..89babb8f722 100644 --- a/src/test/run-pass/cci_borrow.rs +++ b/src/test/run-pass/cci_borrow.rs @@ -17,7 +17,7 @@ extern crate cci_borrow_lib; use cci_borrow_lib::foo; pub fn main() { - let p = box 22_usize; + let p: Box<_> = box 22_usize; let r = foo(&*p); println!("r={}", r); assert_eq!(r, 22_usize); diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index 96ae7e3d336..ff883294fd3 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -43,7 +43,7 @@ fn get_bar(x: uint) -> Vec { vec!(x * 2) } pub fn fails() { let x = 2; - let mut y = Vec::new(); + let mut y: Vec> = Vec::new(); y.push(box Conzabble::Bickwick(do_it(&get_bar(x)))); } diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index 8eeae7a28ac..5cc567cb14c 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -19,7 +19,7 @@ struct Pair { } pub fn main() { - let z = box Pair { a : 10, b : 12}; + let z: Box<_> = box Pair { a : 10, b : 12}; let _t = Thread::spawn(move|| { assert_eq!(z.a, 10); diff --git a/src/test/run-pass/coerce-match.rs b/src/test/run-pass/coerce-match.rs index 098a08b0787..2592957b738 100644 --- a/src/test/run-pass/coerce-match.rs +++ b/src/test/run-pass/coerce-match.rs @@ -14,9 +14,13 @@ #![feature(box_syntax)] pub fn main() { - let _: Box<[int]> = if true { box [1, 2, 3] } else { box [1] }; + let _: Box<[int]> = + if true { let b: Box<_> = box [1, 2, 3]; b } else { let b: Box<_> = box [1]; b }; - let _: Box<[int]> = match true { true => box [1, 2, 3], false => box [1] }; + let _: Box<[int]> = match true { + true => { let b: Box<_> = box [1, 2, 3]; b } + false => { let b: Box<_> = box [1]; b } + }; // Check we don't get over-keen at propagating coercions in the case of casts. let x = if true { 42 } else { 42u8 } as u16; diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 1a3e87b55b6..043bfe429ad 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -22,7 +22,7 @@ extern crate crate_method_reexport_grrrrrrr2; pub fn main() { use crate_method_reexport_grrrrrrr2::rust::add; use crate_method_reexport_grrrrrrr2::rust::cx; - let x = box() (); + let x: Box<_> = box () (); x.cx(); let y = (); y.add("hi".to_string()); diff --git a/src/test/run-pass/deref-lval.rs b/src/test/run-pass/deref-lval.rs index 41c74250b3b..fc97b22a4a9 100644 --- a/src/test/run-pass/deref-lval.rs +++ b/src/test/run-pass/deref-lval.rs @@ -14,7 +14,7 @@ use std::cell::Cell; pub fn main() { - let x = box Cell::new(5); + let x: Box<_> = box Cell::new(5); x.set(1000); println!("{}", x.get()); } diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index 382c5c58e92..865fccbc3fa 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -33,6 +33,6 @@ impl HashMap { } pub fn main() { - let mut m = box linear_map::<(),()>(); + let mut m: Box<_> = box linear_map::<(),()>(); assert_eq!(m.len(), 0); } diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index e5d8ec3f8ad..3d06a556203 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -70,7 +70,7 @@ trait Nus { fn f(&self); } impl Nus for thing { fn f(&self) {} } pub fn main() { - let y = box thing(A {a: 10}); + let y: Box<_> = box thing(A {a: 10}); assert_eq!(y.clone().bar(), 10); assert_eq!(y.quux(), 10); diff --git a/src/test/run-pass/expr-block-unique.rs b/src/test/run-pass/expr-block-unique.rs index d10b209965f..d7d5a39f452 100644 --- a/src/test/run-pass/expr-block-unique.rs +++ b/src/test/run-pass/expr-block-unique.rs @@ -12,4 +12,4 @@ #![allow(unknown_features)] #![feature(box_syntax)] -pub fn main() { let x = { box 100 }; assert!((*x == 100)); } +pub fn main() { let x: Box<_> = { box 100 }; assert!((*x == 100)); } diff --git a/src/test/run-pass/expr-if-unique.rs b/src/test/run-pass/expr-if-unique.rs index 317e5434930..a5816127798 100644 --- a/src/test/run-pass/expr-if-unique.rs +++ b/src/test/run-pass/expr-if-unique.rs @@ -15,7 +15,7 @@ // Tests for if as expressions returning boxed types fn test_box() { - let rs = if true { box 100 } else { box 101 }; + let rs: Box<_> = if true { box 100 } else { box 101 }; assert_eq!(*rs, 100); } diff --git a/src/test/run-pass/expr-match-unique.rs b/src/test/run-pass/expr-match-unique.rs index 57ccfe1d5e0..9641cacddc0 100644 --- a/src/test/run-pass/expr-match-unique.rs +++ b/src/test/run-pass/expr-match-unique.rs @@ -13,7 +13,7 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { box 100 }, _ => panic!() }; + let res: Box<_> = match true { true => { box 100 }, _ => panic!() }; assert_eq!(*res, 100); } diff --git a/src/test/run-pass/func-arg-incomplete-pattern.rs b/src/test/run-pass/func-arg-incomplete-pattern.rs index b23d8db3cfd..581f71a7376 100644 --- a/src/test/run-pass/func-arg-incomplete-pattern.rs +++ b/src/test/run-pass/func-arg-incomplete-pattern.rs @@ -25,7 +25,7 @@ fn foo(Foo {x, ..}: Foo) -> *const uint { } pub fn main() { - let obj = box 1; + let obj: Box<_> = box 1; let objptr: *const uint = &*obj; let f = Foo {x: obj, y: box 2}; let xptr = foo(f); diff --git a/src/test/run-pass/func-arg-ref-pattern.rs b/src/test/run-pass/func-arg-ref-pattern.rs index 5d44a9461be..799b865bd2d 100644 --- a/src/test/run-pass/func-arg-ref-pattern.rs +++ b/src/test/run-pass/func-arg-ref-pattern.rs @@ -28,7 +28,7 @@ fn checkval(box ref x: Box) -> uint { } pub fn main() { - let obj = box 1; + let obj: Box<_> = box 1; let objptr: *const uint = &*obj; let xptr = getaddr(obj); assert_eq!(objptr, xptr); diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index db468ba1802..42062b89cfd 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -14,7 +14,7 @@ fn id(t: T) -> T { return t; } pub fn main() { - let expected = box 100; + let expected: Box<_> = box 100; let actual = id::>(expected.clone()); println!("{}", *actual); assert_eq!(*expected, *actual); diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 62b8ff528a5..41c859214e9 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -154,7 +154,7 @@ pub fn main() { test_order(); // make sure that format! doesn't move out of local variables - let a = box 3; + let a: Box<_> = box 3; format!("{}", a); format!("{}", a); diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs index ee793359fbc..4ee06d44e65 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -67,7 +67,7 @@ fn test_tup() { fn test_unique() { let i = &Cell::new(0); { - let _a = box r(i); + let _a: Box<_> = box r(i); } assert_eq!(i.get(), 1); } @@ -75,7 +75,7 @@ fn test_unique() { fn test_unique_rec() { let i = &Cell::new(0); { - let _a = box BoxR { + let _a: Box<_> = box BoxR { x: r(i) }; } diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index d3f62f9d04a..1d7a74b042f 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -40,7 +40,7 @@ mod rusti { pub fn main() { unsafe { - let mut x = box 1; + let mut x: Box<_> = box 1; assert_eq!(rusti::atomic_load(&*x), 1); *x = 5; diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index 0daf661c2f6..09dd5304ec5 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -23,7 +23,7 @@ mod rusti { pub fn main() { unsafe { - let x = box 1; + let x: Box<_> = box 1; let mut y = rusti::init(); let mut z: *const uint = transmute(&x); rusti::move_val_init(&mut y, x); diff --git a/src/test/run-pass/issue-10802.rs b/src/test/run-pass/issue-10802.rs index 174a69e1135..48ea00e47d6 100644 --- a/src/test/run-pass/issue-10802.rs +++ b/src/test/run-pass/issue-10802.rs @@ -42,13 +42,13 @@ impl Whatever { fn main() { { - let f = box DroppableStruct; + let f: Box<_> = box DroppableStruct; let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); unsafe { DROPPED = false; } { - let f = box DroppableEnum::DroppableVariant1; + let f: Box<_> = box DroppableEnum::DroppableVariant1; let _a = Whatever::new(box f as Box); } assert!(unsafe { DROPPED }); diff --git a/src/test/run-pass/issue-14399.rs b/src/test/run-pass/issue-14399.rs index db7eacce9d1..d413e323a09 100644 --- a/src/test/run-pass/issue-14399.rs +++ b/src/test/run-pass/issue-14399.rs @@ -23,6 +23,6 @@ trait A { fn foo(&self) {} } impl A for B1 {} fn main() { - let v = box B1; + let v: Box<_> = box B1; let _c: Box = v.clone(); } diff --git a/src/test/run-pass/issue-2633-2.rs b/src/test/run-pass/issue-2633-2.rs index 80e9ca47025..0bef42b6202 100644 --- a/src/test/run-pass/issue-2633-2.rs +++ b/src/test/run-pass/issue-2633-2.rs @@ -17,6 +17,6 @@ fn a_val(x: Box, y: Box) -> int { } pub fn main() { - let z = box 22; + let z: Box<_> = box 22; a_val(z.clone(), z.clone()); } diff --git a/src/test/run-pass/issue-2708.rs b/src/test/run-pass/issue-2708.rs index 1f072af0f5a..6aeec228c0d 100644 --- a/src/test/run-pass/issue-2708.rs +++ b/src/test/run-pass/issue-2708.rs @@ -31,5 +31,5 @@ fn Font() -> Font { } pub fn main() { - let _f = box Font(); + let _f: Box<_> = box Font(); } diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index 31599d0caad..e653dda8de5 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -28,7 +28,7 @@ pub fn main() { // let y = box ({a: 4}); // let z = box ({a: 4} as it); // let z = box ({a: true} as it); - let z = box() (box true as Box); + let z: Box<_> = box () (box true as Box); // x.f(); // y.f(); // (*z).f(); diff --git a/src/test/run-pass/issue-3012-2.rs b/src/test/run-pass/issue-3012-2.rs index de2d4374d78..6f107a37e9b 100644 --- a/src/test/run-pass/issue-3012-2.rs +++ b/src/test/run-pass/issue-3012-2.rs @@ -20,5 +20,5 @@ use socketlib::socket; pub fn main() { let fd: libc::c_int = 1 as libc::c_int; - let _sock = box socket::socket_handle(fd); + let _sock: Box<_> = box socket::socket_handle(fd); } diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs index 25663f2605f..98c9f3d5ec5 100644 --- a/src/test/run-pass/issue-3026.rs +++ b/src/test/run-pass/issue-3026.rs @@ -17,7 +17,7 @@ extern crate collections; use std::collections::HashMap; pub fn main() { - let x; + let x: Box<_>; let mut buggy_map: HashMap = HashMap::new(); x = box 1; buggy_map.insert(42, &*x); diff --git a/src/test/run-pass/issue-3290.rs b/src/test/run-pass/issue-3290.rs index c8d6e69801f..1c1b329e314 100644 --- a/src/test/run-pass/issue-3290.rs +++ b/src/test/run-pass/issue-3290.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let mut x = box 3; + let mut x: Box<_> = box 3; x = x; assert_eq!(*x, 3); } diff --git a/src/test/run-pass/issue-3878.rs b/src/test/run-pass/issue-3878.rs index c1d19f228db..1f53d9ce542 100644 --- a/src/test/run-pass/issue-3878.rs +++ b/src/test/run-pass/issue-3878.rs @@ -13,6 +13,6 @@ #![feature(box_syntax)] pub fn main() { - let y = box 1; + let y: Box<_> = box 1; y; } diff --git a/src/test/run-pass/issue-5718.rs b/src/test/run-pass/issue-5718.rs index 36aa8a9cbca..7e773cd7994 100644 --- a/src/test/run-pass/issue-5718.rs +++ b/src/test/run-pass/issue-5718.rs @@ -16,7 +16,7 @@ struct Element; macro_rules! foo { ($tag: expr, $string: expr) => { if $tag == $string { - let element = box Element; + let element: Box<_> = box Element; unsafe { return std::mem::transmute::<_, uint>(element); } diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index 19a780d180f..7b11aae168c 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -17,7 +17,7 @@ struct A { a: Box } pub fn main() { fn invoke(f: F) where F: FnOnce() { f(); } - let k = box 22; + let k: Box<_> = box 22; let _u = A {a: k.clone()}; invoke(|| println!("{}", k.clone()) ) } diff --git a/src/test/run-pass/let-assignability.rs b/src/test/run-pass/let-assignability.rs index 9ac016d534f..1500edce779 100644 --- a/src/test/run-pass/let-assignability.rs +++ b/src/test/run-pass/let-assignability.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] fn f() { - let a = box 1; + let a: Box<_> = box 1; let b: &int = &*a; println!("{}", b); } diff --git a/src/test/run-pass/match-implicit-copy-unique.rs b/src/test/run-pass/match-implicit-copy-unique.rs index 6883187c402..cd4802f4b39 100644 --- a/src/test/run-pass/match-implicit-copy-unique.rs +++ b/src/test/run-pass/match-implicit-copy-unique.rs @@ -14,7 +14,7 @@ struct Pair { a: Box, b: Box } pub fn main() { - let mut x = box Pair {a: box 10, b: box 20}; + let mut x: Box<_> = box Pair {a: box 10, b: box 20}; let x_internal = &mut *x; match *x_internal { Pair {a: ref mut a, b: ref mut _b} => { diff --git a/src/test/run-pass/method-two-trait-defer-resolution-2.rs b/src/test/run-pass/method-two-trait-defer-resolution-2.rs index 7463783be59..a49ce826170 100644 --- a/src/test/run-pass/method-two-trait-defer-resolution-2.rs +++ b/src/test/run-pass/method-two-trait-defer-resolution-2.rs @@ -39,7 +39,7 @@ fn call_foo_copy() -> int { } fn call_foo_other() -> int { - let mut x = Vec::new(); + let mut x: Vec> = Vec::new(); let y = x.foo(); x.push(box 0); y diff --git a/src/test/run-pass/move-1-unique.rs b/src/test/run-pass/move-1-unique.rs index 018cd440cad..ff06df079b0 100644 --- a/src/test/run-pass/move-1-unique.rs +++ b/src/test/run-pass/move-1-unique.rs @@ -26,7 +26,7 @@ fn test(x: bool, foo: Box) -> int { } pub fn main() { - let x = box Triple{x: 1, y: 2, z: 3}; + let x: Box<_> = box Triple{x: 1, y: 2, z: 3}; assert_eq!(test(true, x.clone()), 2); assert_eq!(test(true, x.clone()), 2); assert_eq!(test(true, x.clone()), 2); diff --git a/src/test/run-pass/move-2-unique.rs b/src/test/run-pass/move-2-unique.rs index 50187ef8baa..590caff3c2d 100644 --- a/src/test/run-pass/move-2-unique.rs +++ b/src/test/run-pass/move-2-unique.rs @@ -14,7 +14,7 @@ struct X { x: int, y: int, z: int } pub fn main() { - let x = box X{x: 1, y: 2, z: 3}; + let x: Box<_> = box X{x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } diff --git a/src/test/run-pass/move-2.rs b/src/test/run-pass/move-2.rs index 6561a9b2d5b..0bff2c2292e 100644 --- a/src/test/run-pass/move-2.rs +++ b/src/test/run-pass/move-2.rs @@ -13,4 +13,4 @@ struct X { x: int, y: int, z: int } -pub fn main() { let x = box X {x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } +pub fn main() { let x: Box<_> = box X {x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } diff --git a/src/test/run-pass/move-3-unique.rs b/src/test/run-pass/move-3-unique.rs index 07d0594b494..8241424124e 100644 --- a/src/test/run-pass/move-3-unique.rs +++ b/src/test/run-pass/move-3-unique.rs @@ -26,7 +26,7 @@ fn test(x: bool, foo: Box) -> int { } pub fn main() { - let x = box Triple{x: 1, y: 2, z: 3}; + let x: Box<_> = box Triple{x: 1, y: 2, z: 3}; for _ in 0_usize..10000_usize { assert_eq!(test(true, x.clone()), 2); } diff --git a/src/test/run-pass/move-guard-const.rs b/src/test/run-pass/move-guard-const.rs index 64c4f1fdbae..d68a7c831f2 100644 --- a/src/test/run-pass/move-guard-const.rs +++ b/src/test/run-pass/move-guard-const.rs @@ -11,7 +11,7 @@ #![feature(box_syntax)] fn main() { - let x = box 1; + let x: Box<_> = box 1; let v = (1, 2); diff --git a/src/test/run-pass/overloaded-index-autoderef.rs b/src/test/run-pass/overloaded-index-autoderef.rs index d5ccf8cd2be..8f655f0517d 100644 --- a/src/test/run-pass/overloaded-index-autoderef.rs +++ b/src/test/run-pass/overloaded-index-autoderef.rs @@ -55,7 +55,7 @@ impl Int for int { } fn main() { - let mut f = box Foo { + let mut f: Box<_> = box Foo { x: 1, y: 2, }; diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index f7adb0f6e44..1fd83041f62 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -25,7 +25,7 @@ fn sums_to(v: Vec , sum: int) -> bool { fn sums_to_using_uniq(v: Vec , sum: int) -> bool { let mut i = 0_usize; - let mut sum0 = box 0; + let mut sum0: Box<_> = box 0; while i < v.len() { *sum0 += v[i]; i += 1_usize; @@ -47,7 +47,7 @@ struct F { f: T } fn sums_to_using_uniq_rec(v: Vec , sum: int) -> bool { let mut i = 0_usize; - let mut sum0 = F {f: box 0}; + let mut sum0 = F::> {f: box 0}; while i < v.len() { *sum0.f += v[i]; i += 1_usize; diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index 84a230fd576..7bc761d2f60 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -25,7 +25,7 @@ impl<'a> get for &'a int { } pub fn main() { - let x = box 6; + let x: Box<_> = box 6; let y = x.get(); println!("y={}", y); assert_eq!(y, 6); diff --git a/src/test/run-pass/regions-borrow-at.rs b/src/test/run-pass/regions-borrow-at.rs index 89779fa4d2d..1e91ab7e921 100644 --- a/src/test/run-pass/regions-borrow-at.rs +++ b/src/test/run-pass/regions-borrow-at.rs @@ -16,7 +16,7 @@ fn foo(x: &uint) -> uint { } pub fn main() { - let p = box 22_usize; + let p: Box<_> = box 22_usize; let r = foo(&*p); println!("r={}", r); assert_eq!(r, 22_usize); diff --git a/src/test/run-pass/regions-borrow-uniq.rs b/src/test/run-pass/regions-borrow-uniq.rs index a1af7159a93..7c9b1ae226f 100644 --- a/src/test/run-pass/regions-borrow-uniq.rs +++ b/src/test/run-pass/regions-borrow-uniq.rs @@ -16,7 +16,7 @@ fn foo(x: &uint) -> uint { } pub fn main() { - let p = box 3_usize; + let p: Box<_> = box 3_usize; let r = foo(&*p); assert_eq!(r, 3_usize); } diff --git a/src/test/run-pass/regions-escape-into-other-fn.rs b/src/test/run-pass/regions-escape-into-other-fn.rs index b15f9d34859..0ca17e218d2 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -15,6 +15,6 @@ fn foo(x: &uint) -> &uint { x } fn bar(x: &uint) -> uint { *x } pub fn main() { - let p = box 3_usize; + let p: Box<_> = box 3_usize; assert_eq!(bar(foo(&*p)), 3); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index d07110fd721..86f4f2dd18e 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -14,7 +14,7 @@ fn borrow(x: &T) -> &T {x} pub fn main() { - let x = box 3; + let x: Box<_> = box 3; loop { let y = borrow(&*x); assert_eq!(*x, *y); diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index 708d031a68a..ebbc5b70f60 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -18,7 +18,7 @@ fn x_coord(p: &Point) -> &int { } pub fn main() { - let p = box Point {x: 3, y: 4}; + let p: Box<_> = box Point {x: 3, y: 4}; let xc = x_coord(&*p); assert_eq!(*xc, 3); } diff --git a/src/test/run-pass/self-in-mut-slot-default-method.rs b/src/test/run-pass/self-in-mut-slot-default-method.rs index e934498ea05..92582177989 100644 --- a/src/test/run-pass/self-in-mut-slot-default-method.rs +++ b/src/test/run-pass/self-in-mut-slot-default-method.rs @@ -40,7 +40,7 @@ pub fn main() { let new_x = x.change(); assert_eq!(new_x.a, 55); - let x = box new_x; + let x: Box<_> = box new_x; let new_x = x.change_again(); assert_eq!(new_x.a, 45); } diff --git a/src/test/run-pass/self-re-assign.rs b/src/test/run-pass/self-re-assign.rs index cf09737e32e..b71b907fcf0 100644 --- a/src/test/run-pass/self-re-assign.rs +++ b/src/test/run-pass/self-re-assign.rs @@ -17,7 +17,7 @@ use std::rc::Rc; pub fn main() { - let mut x = box 3; + let mut x: Box<_> = box 3; x = x; assert!(*x == 3); diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index 523b7528103..264ee5f55b9 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -20,7 +20,7 @@ fn test05_start(f: F) { } fn test05() { - let three = box 3; + let three: Box<_> = box 3; let fn_to_send = move|n:int| { println!("{}", *three + n); // will copy x into the closure assert_eq!(*three, 3); diff --git a/src/test/run-pass/task-spawn-move-and-copy.rs b/src/test/run-pass/task-spawn-move-and-copy.rs index ca2a8cf5506..46f9e991347 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -17,7 +17,7 @@ use std::sync::mpsc::channel; pub fn main() { let (tx, rx) = channel::(); - let x = box 1; + let x: Box<_> = box 1; let x_in_parent = &(*x) as *const int as uint; let _t = Thread::spawn(move || { diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 7d1fad5d281..432dbd72a29 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -32,13 +32,13 @@ fn r(i:int) -> r { pub fn main() { p_foo(r(10)); - p_foo(box r(10)); - p_foo(box 10); + p_foo::>(box r(10)); + p_foo::>(box 10); p_foo(10); - s_foo(box 10); + s_foo::>(box 10); s_foo(10); - u_foo(box 10); + u_foo::>(box 10); u_foo(10); } diff --git a/src/test/run-pass/ufcs-explicit-self.rs b/src/test/run-pass/ufcs-explicit-self.rs index 2be9f75dae1..832c1f8802d 100644 --- a/src/test/run-pass/ufcs-explicit-self.rs +++ b/src/test/run-pass/ufcs-explicit-self.rs @@ -46,11 +46,11 @@ impl Bar { } fn main() { - let foo = box Foo { + let foo: Box<_> = box Foo { f: 1, }; println!("{} {} {}", foo.foo(2), foo.bar(2), foo.baz(2)); - let bar = box Bar { + let bar: Box<_> = box Bar { f: 1, }; println!("{} {} {}", bar.foo(2), bar.bar(2), bar.baz(2)); diff --git a/src/test/run-pass/uniq-self-in-mut-slot.rs b/src/test/run-pass/uniq-self-in-mut-slot.rs index b7980ed9021..d44a8cdcc24 100644 --- a/src/test/run-pass/uniq-self-in-mut-slot.rs +++ b/src/test/run-pass/uniq-self-in-mut-slot.rs @@ -27,7 +27,7 @@ impl Changer for X { } pub fn main() { - let x = box X { a: 32 }; + let x: Box<_> = box X { a: 32 }; let new_x = x.change(); assert_eq!(new_x.a, 55); } diff --git a/src/test/run-pass/unique-assign-copy.rs b/src/test/run-pass/unique-assign-copy.rs index c19063fe464..78578bdb3c3 100644 --- a/src/test/run-pass/unique-assign-copy.rs +++ b/src/test/run-pass/unique-assign-copy.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let mut i = box 1; + let mut i: Box<_> = box 1; // Should be a copy let mut j; j = i.clone(); diff --git a/src/test/run-pass/unique-assign-drop.rs b/src/test/run-pass/unique-assign-drop.rs index 241258f089c..9edd83d2c7c 100644 --- a/src/test/run-pass/unique-assign-drop.rs +++ b/src/test/run-pass/unique-assign-drop.rs @@ -13,8 +13,8 @@ #![feature(box_syntax)] pub fn main() { - let i = box 1; - let mut j = box 2; + let i: Box<_> = box 1; + let mut j: Box<_> = box 2; // Should drop the previous value of j j = i; assert_eq!(*j, 1); diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index c8abb080848..64f8b998096 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -18,6 +18,6 @@ fn f(t: T) -> T { } pub fn main() { - let t = f(box 100); + let t = f::>(box 100); assert_eq!(t, box 100); } diff --git a/src/test/run-pass/unique-assign.rs b/src/test/run-pass/unique-assign.rs index cbcb6afb4c8..c9cbaf27c4f 100644 --- a/src/test/run-pass/unique-assign.rs +++ b/src/test/run-pass/unique-assign.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let mut i; + let mut i: Box<_>; i = box 1; assert_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-autoderef-field.rs b/src/test/run-pass/unique-autoderef-field.rs index aab7f4108fb..3bab3a6b79a 100644 --- a/src/test/run-pass/unique-autoderef-field.rs +++ b/src/test/run-pass/unique-autoderef-field.rs @@ -14,7 +14,7 @@ struct J { j: int } pub fn main() { - let i = box J { + let i: Box<_> = box J { j: 100 }; assert_eq!(i.j, 100); diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index 30c4b2d7b56..1c944473921 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -12,6 +12,6 @@ #![feature(box_syntax)] pub fn main() { - let i = box vec!(100); + let i: Box<_> = box vec!(100); assert_eq!((*i)[0], 100); } diff --git a/src/test/run-pass/unique-cmp.rs b/src/test/run-pass/unique-cmp.rs index a2962dc00d5..8fe86455b45 100644 --- a/src/test/run-pass/unique-cmp.rs +++ b/src/test/run-pass/unique-cmp.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let i = box 100; + let i: Box<_> = box 100; assert!(i == box 100); assert!(i < box 101); assert!(i <= box 100); diff --git a/src/test/run-pass/unique-containing-tag.rs b/src/test/run-pass/unique-containing-tag.rs index e4099c94c2f..cb6e84ae1aa 100644 --- a/src/test/run-pass/unique-containing-tag.rs +++ b/src/test/run-pass/unique-containing-tag.rs @@ -14,7 +14,7 @@ pub fn main() { enum t { t1(int), t2(int), } - let _x = box t::t1(10); + let _x: Box<_> = box t::t1(10); /*alt *x { t1(a) { diff --git a/src/test/run-pass/unique-create.rs b/src/test/run-pass/unique-create.rs index 975f1e9da82..7264b9fee95 100644 --- a/src/test/run-pass/unique-create.rs +++ b/src/test/run-pass/unique-create.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - box 100; + let _: Box<_> = box 100; } fn vec() { diff --git a/src/test/run-pass/unique-decl-init-copy.rs b/src/test/run-pass/unique-decl-init-copy.rs index 3af38784add..14bb72f4412 100644 --- a/src/test/run-pass/unique-decl-init-copy.rs +++ b/src/test/run-pass/unique-decl-init-copy.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let mut i = box 1; + let mut i: Box<_> = box 1; // Should be a copy let mut j = i.clone(); *i = 2; diff --git a/src/test/run-pass/unique-decl-init.rs b/src/test/run-pass/unique-decl-init.rs index c9192748809..803e7ba16ed 100644 --- a/src/test/run-pass/unique-decl-init.rs +++ b/src/test/run-pass/unique-decl-init.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let i = box 1; + let i: Box<_> = box 1; let j = i; assert_eq!(*j, 1); } diff --git a/src/test/run-pass/unique-decl-move.rs b/src/test/run-pass/unique-decl-move.rs index 96dd9f51fbe..360adaa638f 100644 --- a/src/test/run-pass/unique-decl-move.rs +++ b/src/test/run-pass/unique-decl-move.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let i = box 100; + let i: Box<_> = box 100; let j = i; assert_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-deref.rs b/src/test/run-pass/unique-deref.rs index 41d3b87a003..1c1228f9241 100644 --- a/src/test/run-pass/unique-deref.rs +++ b/src/test/run-pass/unique-deref.rs @@ -12,6 +12,6 @@ #![feature(box_syntax)] pub fn main() { - let i = box 100; + let i: Box<_> = box 100; assert_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-drop-complex.rs b/src/test/run-pass/unique-drop-complex.rs index c5a0a4df275..745a55e0651 100644 --- a/src/test/run-pass/unique-drop-complex.rs +++ b/src/test/run-pass/unique-drop-complex.rs @@ -12,5 +12,5 @@ #![feature(box_syntax)] pub fn main() { - let _x = box vec!(0,0,0,0,0); + let _x: Box<_> = box vec!(0,0,0,0,0); } diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index 3bde79fdce0..20bf4bef171 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let mut a = vec!(box 10); + let mut a: Vec> = vec!(box 10); let b = a.clone(); assert_eq!(*a[0], 10); diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index 05b0c7244de..c24ec8fe44a 100644 --- a/src/test/run-pass/unique-in-vec.rs +++ b/src/test/run-pass/unique-in-vec.rs @@ -12,6 +12,6 @@ #![feature(box_syntax)] pub fn main() { - let vect = vec!(box 100); + let vect : Vec> = vec!(box 100); assert!(vect[0] == box 100); } diff --git a/src/test/run-pass/unique-init.rs b/src/test/run-pass/unique-init.rs index d3f13f1609f..44e8703aaf2 100644 --- a/src/test/run-pass/unique-init.rs +++ b/src/test/run-pass/unique-init.rs @@ -12,5 +12,5 @@ #![feature(box_syntax)] pub fn main() { - let _i = box 100; + let _i: Box<_> = box 100; } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 4c93c379b48..6bb1fdcf562 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -23,11 +23,11 @@ fn sendable() { assert!(i != j); } - let i = box 100; - let j = box 100; + let i: Box<_> = box 100; + let j: Box<_> = box 100; f(i, j); - let i = box 100; - let j = box 101; + let i: Box<_> = box 100; + let j: Box<_> = box 101; g(i, j); } @@ -41,11 +41,11 @@ fn copyable() { assert!(i != j); } - let i = box 100; - let j = box 100; + let i: Box<_> = box 100; + let j: Box<_> = box 100; f(i, j); - let i = box 100; - let j = box 101; + let i: Box<_> = box 100; + let j: Box<_> = box 101; g(i, j); } @@ -59,11 +59,11 @@ fn noncopyable() { assert!(i != j); } - let i = box 100; - let j = box 100; + let i: Box<_> = box 100; + let j: Box<_> = box 100; f(i, j); - let i = box 100; - let j = box 101; + let i: Box<_> = box 100; + let j: Box<_> = box 101; g(i, j); } diff --git a/src/test/run-pass/unique-log.rs b/src/test/run-pass/unique-log.rs index 4b21b949f88..148ca4757ae 100644 --- a/src/test/run-pass/unique-log.rs +++ b/src/test/run-pass/unique-log.rs @@ -12,6 +12,6 @@ #![feature(box_syntax)] pub fn main() { - let i = box 100; + let i: Box<_> = box 100; println!("{}", i); } diff --git a/src/test/run-pass/unique-move-drop.rs b/src/test/run-pass/unique-move-drop.rs index 705b9d6e92c..126cc646833 100644 --- a/src/test/run-pass/unique-move-drop.rs +++ b/src/test/run-pass/unique-move-drop.rs @@ -13,8 +13,8 @@ #![feature(box_syntax)] pub fn main() { - let i = box 100; - let j = box 200; + let i: Box<_> = box 100; + let j: Box<_> = box 200; let j = i; assert_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-move-temp.rs b/src/test/run-pass/unique-move-temp.rs index b6c24f5be28..9ac5e86f87b 100644 --- a/src/test/run-pass/unique-move-temp.rs +++ b/src/test/run-pass/unique-move-temp.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let mut i; + let mut i: Box<_>; i = box 100; assert_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-move.rs b/src/test/run-pass/unique-move.rs index ed13bf6a5c4..a54b343f2fa 100644 --- a/src/test/run-pass/unique-move.rs +++ b/src/test/run-pass/unique-move.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let i = box 100; + let i: Box<_> = box 100; let mut j; j = i; assert_eq!(*j, 100); diff --git a/src/test/run-pass/unique-mutable.rs b/src/test/run-pass/unique-mutable.rs index 403b8bf18b8..ca01c07ab80 100644 --- a/src/test/run-pass/unique-mutable.rs +++ b/src/test/run-pass/unique-mutable.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let mut i = box 0; + let mut i: Box<_> = box 0; *i = 1; assert_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-rec.rs b/src/test/run-pass/unique-rec.rs index 756911d29fc..c20604406b9 100644 --- a/src/test/run-pass/unique-rec.rs +++ b/src/test/run-pass/unique-rec.rs @@ -14,7 +14,7 @@ struct X { x: int } pub fn main() { - let x = box X {x: 1}; + let x: Box<_> = box X {x: 1}; let bar = x; assert_eq!(bar.x, 1); } diff --git a/src/test/run-pass/unique-send.rs b/src/test/run-pass/unique-send.rs index 2a462e9cdd8..72022afe5fd 100644 --- a/src/test/run-pass/unique-send.rs +++ b/src/test/run-pass/unique-send.rs @@ -14,7 +14,7 @@ use std::sync::mpsc::channel; pub fn main() { - let (tx, rx) = channel(); + let (tx, rx) = channel::>(); tx.send(box 100).unwrap(); let v = rx.recv().unwrap(); assert_eq!(v, box 100); diff --git a/src/test/run-pass/unique-swap.rs b/src/test/run-pass/unique-swap.rs index 2adb9c22f60..1315e443816 100644 --- a/src/test/run-pass/unique-swap.rs +++ b/src/test/run-pass/unique-swap.rs @@ -14,8 +14,8 @@ use std::mem::swap; pub fn main() { - let mut i = box 100; - let mut j = box 200; + let mut i: Box<_> = box 100; + let mut j: Box<_> = box 200; swap(&mut i, &mut j); assert_eq!(i, box 200); assert_eq!(j, box 100); diff --git a/src/test/run-pass/unsized3.rs b/src/test/run-pass/unsized3.rs index 983152cd056..c9a9d6ad147 100644 --- a/src/test/run-pass/unsized3.rs +++ b/src/test/run-pass/unsized3.rs @@ -66,7 +66,7 @@ pub fn main() { f: [T; 3] } - let data = box Foo_{f: [1i32, 2, 3] }; + let data: Box<_> = box Foo_{f: [1i32, 2, 3] }; let x: &Foo = mem::transmute(raw::Slice { len: 3, data: &*data }); assert!(x.f.len() == 3); assert!(x.f[0] == 1); @@ -78,7 +78,8 @@ pub fn main() { f2: [u8; 5], } - let data = box Baz_{ f1: 42, f2: ['a' as u8, 'b' as u8, 'c' as u8, 'd' as u8, 'e' as u8] }; + let data: Box<_> = box Baz_ { + f1: 42, f2: ['a' as u8, 'b' as u8, 'c' as u8, 'd' as u8, 'e' as u8] }; let x: &Baz = mem::transmute( raw::Slice { len: 5, data: &*data } ); assert!(x.f1 == 42); let chs: Vec = x.f2.chars().collect(); @@ -96,7 +97,7 @@ pub fn main() { let obj: Box = box St { f: 42 }; let obj: &Tr = &*obj; let obj: raw::TraitObject = mem::transmute(&*obj); - let data = box Qux_{ f: St { f: 234 } }; + let data: Box<_> = box Qux_{ f: St { f: 234 } }; let x: &Qux = mem::transmute(raw::TraitObject { vtable: obj.vtable, data: mem::transmute(&*data) }); assert!(x.f.foo() == 234); diff --git a/src/test/run-pass/unused-move-capture.rs b/src/test/run-pass/unused-move-capture.rs index 4e8fdda9563..9f20426aa21 100644 --- a/src/test/run-pass/unused-move-capture.rs +++ b/src/test/run-pass/unused-move-capture.rs @@ -12,7 +12,7 @@ #![feature(box_syntax)] pub fn main() { - let _x = box 1; + let _x: Box<_> = box 1; let lam_move = || {}; lam_move(); } diff --git a/src/test/run-pass/unused-move.rs b/src/test/run-pass/unused-move.rs index d053b03a2ca..57534feec31 100644 --- a/src/test/run-pass/unused-move.rs +++ b/src/test/run-pass/unused-move.rs @@ -18,6 +18,6 @@ pub fn main() { - let y = box 1; + let y: Box<_> = box 1; y; } diff --git a/src/test/run-pass/unwind-unique.rs b/src/test/run-pass/unwind-unique.rs index 4d90f71c830..b7229a00480 100644 --- a/src/test/run-pass/unwind-unique.rs +++ b/src/test/run-pass/unwind-unique.rs @@ -14,7 +14,7 @@ use std::thread; fn f() { - let _a = box 0; + let _a: Box<_> = box 0; panic!(); } From b03279aaa2b20f6033e66fc7aea29c0b43e71082 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 16 Feb 2015 11:53:29 +0100 Subject: [PATCH 2/4] inline `Box::new` always. (You shouldn't use it, but it is a semi-reasonable way to annotate types when necessary.) --- src/liballoc/boxed.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index a93872dfe36..75160476d71 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -94,6 +94,7 @@ impl Box { /// let x = Box::new(5); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[inline(always)] pub fn new(x: T) -> Box { box x } From 0d5bcb14adb71900a99f06b92485de7e019734c2 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Sun, 15 Feb 2015 09:52:21 +0100 Subject: [PATCH 3/4] Switched to Box::new in many places. Many of the modifications putting in `Box::new` calls also include a pointer to Issue 22405, which tracks going back to `box ` if possible in the future. (Still tried to use `Box<_>` where it sufficed; thus some tests still have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.) Precursor for overloaded-`box` and placement-`in`; see Issue 22181. --- src/liballoc/boxed.rs | 2 +- src/libcoretest/hash/mod.rs | 3 ++- src/libcoretest/iter.rs | 11 +++++---- src/librustc/middle/const_eval.rs | 4 ++-- src/librustc/plugin/registry.rs | 2 +- src/librustc_trans/trans/base.rs | 2 +- src/librustc_trans/trans/inline.rs | 2 +- src/librustc_typeck/check/callee.rs | 12 +++++----- src/libstd/old_io/stdio.rs | 6 +++-- src/libstd/old_io/timer.rs | 5 ++-- src/libstd/rt/unwind.rs | 6 ++--- src/libstd/thunk.rs | 2 +- src/libsyntax/diagnostic.rs | 6 ++--- src/libsyntax/ext/base.rs | 6 ++--- src/libsyntax/ext/deriving/clone.rs | 4 ++-- src/libsyntax/ext/deriving/cmp/eq.rs | 8 +++---- src/libsyntax/ext/deriving/cmp/ord.rs | 16 ++++++------- src/libsyntax/ext/deriving/cmp/totaleq.rs | 7 +++--- src/libsyntax/ext/deriving/cmp/totalord.rs | 8 +++---- src/libsyntax/ext/deriving/decodable.rs | 4 ++-- src/libsyntax/ext/deriving/default.rs | 4 ++-- src/libsyntax/ext/deriving/encodable.rs | 4 ++-- src/libsyntax/ext/deriving/hash.rs | 4 ++-- src/libsyntax/ext/deriving/primitive.rs | 8 +++---- src/libsyntax/ext/deriving/rand.rs | 4 ++-- src/libsyntax/ext/deriving/show.rs | 4 ++-- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/ext/tt/macro_rules.rs | 4 ++-- src/libsyntax/owned_slice.rs | 2 +- src/libsyntax/parse/lexer/mod.rs | 5 ++-- src/test/auxiliary/macro_crate_test.rs | 6 +++-- src/test/auxiliary/plugin_args.rs | 3 ++- .../borrowck-borrowed-uniq-rvalue.rs | 5 ++-- .../borrowck-call-is-borrow-issue-12224.rs | 13 ++++++----- src/test/compile-fail/cross-borrow-trait.rs | 5 ++-- src/test/compile-fail/dst-bad-assign-2.rs | 5 ++-- src/test/compile-fail/dst-bad-assign.rs | 5 ++-- src/test/compile-fail/issue-10291.rs | 7 +++--- src/test/compile-fail/issue-11515.rs | 3 ++- src/test/compile-fail/issue-17441.rs | 8 ++++--- src/test/compile-fail/issue-17651.rs | 8 +++---- src/test/compile-fail/issue-18783.rs | 12 +++++----- src/test/compile-fail/issue-3763.rs | 11 +++++---- src/test/compile-fail/issue-4335.rs | 4 ++-- src/test/compile-fail/issue-5543.rs | 5 ++-- src/test/compile-fail/map-types.rs | 3 ++- ...ased-on-type-no-recursive-stack-closure.rs | 4 ++-- .../region-object-lifetime-in-coercion.rs | 18 +++++++++------ ...gions-close-associated-type-into-object.rs | 22 ++++++++++-------- .../regions-close-param-into-object.rs | 10 ++++---- src/test/compile-fail/regions-nested-fns.rs | 10 ++++---- .../regions-proc-bound-capture.rs | 6 ++--- .../compile-fail/regions-steal-closure.rs | 4 ++-- .../trait-coercion-generic-bad.rs | 5 ++-- .../trait-coercion-generic-regions.rs | 5 ++-- .../unboxed-closure-illegal-move.rs | 15 ++++++------ src/test/compile-fail/unique-pinned-nocopy.rs | 5 ++-- src/test/compile-fail/unique-unique-kind.rs | 5 ++-- src/test/compile-fail/unique-vec-res.rs | 7 +++--- .../debuginfo/closure-in-generic-function.rs | 2 +- src/test/run-fail/panic-macro-any-wrapped.rs | 5 +--- src/test/run-fail/unique-panic.rs | 5 +--- src/test/run-fail/unwind-unique.rs | 5 +--- src/test/run-make/save-analysis/foo.rs | 7 +++--- src/test/run-pass-valgrind/dst-dtor-1.rs | 5 ++-- src/test/run-pass-valgrind/dst-dtor-2.rs | 5 ++-- src/test/run-pass/assert-eq-macro-success.rs | 5 +--- ...ciated-types-doubleendediterator-object.rs | 3 ++- src/test/run-pass/coerce-expect-unsized.rs | 23 +++++++++++++------ src/test/run-pass/const-bound.rs | 5 +--- src/test/run-pass/deriving-default-box.rs | 3 ++- .../deriving-encodable-decodable-box.rs | 3 ++- .../run-pass/deriving-eq-ord-boxed-slice.rs | 8 +++---- src/test/run-pass/dst-deref-mut.rs | 6 ++--- src/test/run-pass/dst-deref.rs | 6 ++--- src/test/run-pass/dst-struct.rs | 7 ++++-- src/test/run-pass/dst-trait.rs | 4 +++- .../run-pass/empty-allocation-non-null.rs | 11 ++++----- .../empty-allocation-rvalue-non-null.rs | 5 +--- src/test/run-pass/hashmap-memory.rs | 4 ++-- src/test/run-pass/hrtb-precedence-of-plus.rs | 4 ++-- src/test/run-pass/issue-11205.rs | 20 ++++++++-------- src/test/run-pass/issue-11677.rs | 5 ++-- src/test/run-pass/issue-12744.rs | 6 ++--- src/test/run-pass/issue-13808.rs | 6 ++--- src/test/run-pass/issue-14589.rs | 9 ++++---- src/test/run-pass/issue-14919.rs | 6 ++--- src/test/run-pass/issue-15571.rs | 6 ++--- src/test/run-pass/issue-16668.rs | 6 ++--- src/test/run-pass/issue-17734.rs | 7 +++--- src/test/run-pass/issue-18425.rs | 5 +--- src/test/run-pass/issue-20575.rs | 5 ++-- src/test/run-pass/issue-2718.rs | 6 ++--- src/test/run-pass/issue-3052.rs | 6 ++--- src/test/run-pass/issue-3424.rs | 6 ++--- src/test/run-pass/issue-3609.rs | 5 ++-- src/test/run-pass/issue-6117.rs | 5 +--- src/test/run-pass/issue-8498.rs | 9 +++----- src/test/run-pass/last-use-in-cap-clause.rs | 5 ++-- src/test/run-pass/newlambdas-ret-infer.rs | 6 ++--- src/test/run-pass/newlambdas-ret-infer2.rs | 6 ++--- src/test/run-pass/overloaded-autoderef.rs | 5 ++-- src/test/run-pass/overloaded-deref.rs | 5 +--- src/test/run-pass/owned-implies-static.rs | 5 +--- src/test/run-pass/regions-copy-closure.rs | 4 ++-- src/test/run-pass/regions-fn-subtyping.rs | 7 +++--- ...ions-on-closures-to-inference-variables.rs | 5 ++-- src/test/run-pass/regions-static-closure.rs | 3 ++- src/test/run-pass/show-boxed-slice.rs | 6 ++--- src/test/run-pass/trait-bounds-in-arc.rs | 5 ++-- src/test/run-pass/trait-coercion-generic.rs | 6 ++--- src/test/run-pass/trait-coercion.rs | 6 +++-- .../run-pass/traits-conditional-dispatch.rs | 2 +- ...ed-closures-call-sugar-object-autoderef.rs | 4 ++-- .../unboxed-closures-call-sugar-object.rs | 4 ++-- .../unboxed-closures-monomorphization.rs | 3 ++- src/test/run-pass/unboxed-closures-prelude.rs | 5 ++-- src/test/run-pass/unique-match-discrim.rs | 5 +--- 118 files changed, 349 insertions(+), 373 deletions(-) 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) { _ => { } } } From cb1b0dd589c80c3edb94b8982ea33e000978f572 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Thu, 26 Feb 2015 18:27:11 +0100 Subject: [PATCH 4/4] Fix doc example to accommodate overloaded-box. --- src/doc/trpl/pointers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/trpl/pointers.md b/src/doc/trpl/pointers.md index 0f46b4da0d6..e56706500a0 100644 --- a/src/doc/trpl/pointers.md +++ b/src/doc/trpl/pointers.md @@ -709,7 +709,7 @@ fn main() { one_hundred: 100, }); - let y = box foo(x); + let y: Box = box foo(x); } ```