diff options
| author | bors <bors@rust-lang.org> | 2015-03-03 20:17:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-03 20:17:08 +0000 |
| commit | fed12499e7d91f9cdfba5833e34d20e8fd19b898 (patch) | |
| tree | 2c5b377f6a53498f2555965e4903b77e4c8aad30 /src/libcoretest | |
| parent | 129173f1980e9ac03f7ef0fc0193c41235d07649 (diff) | |
| parent | cb1b0dd589c80c3edb94b8982ea33e000978f572 (diff) | |
| download | rust-fed12499e7d91f9cdfba5833e34d20e8fd19b898.tar.gz rust-fed12499e7d91f9cdfba5833e34d20e8fd19b898.zip | |
Auto merge of #23002 - pnkfelix:fsk-box-place-runway, r=nikomatsakis
Runway for RFC 809 (overloaded box/placement-in) by adding type annotations or explicit calls to `Box::new` where I found it necessary on PR #22086. I have broken this up into more than one PR because the entire commit chain (see PR #22086) is long, widespread and unwieldy to rebase frequently. To my knowledge this is not a breaking change. Also, there is in principle nothing stopping someone from reverting some/all of these annotations, since without the rest of the commit chain in #22086, the associated code would continue to compile. All I can do is ask: Try to discourage others from removing seemingly "unnecessary" uses of the `Box` type or the `Box::new()` function, until the rest of RFC 809 lands.
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/any.rs | 2 | ||||
| -rw-r--r-- | src/libcoretest/hash/mod.rs | 3 | ||||
| -rw-r--r-- | src/libcoretest/iter.rs | 11 | ||||
| -rw-r--r-- | src/libcoretest/option.rs | 2 |
4 files changed, 11 insertions, 7 deletions
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/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<str> 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/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(); |
