Skip to content

Commit 7932b71

Browse files
committed
auto merge of #14397 : nick29581/rust/coerce, r=pnkfelix
DST coercions and DST fields in structs The commits are not quite stand alone, I should probably squash them together before landing. In particular if you review the individual commits, then you'll see some scrappy stuff that gets fixed in later commits. But reading the commits in order might be easier to get an overall idea of what is going on. The first commit includes putting back time zone into our time library - @pcwalton removed that as part of his de-~str'ing, but I had already converted it to use StrBuf, so we may as well leave it in. Update: no longer, this is removed in a later commit.
2 parents 1cad408 + 08364a4 commit 7932b71

File tree

167 files changed

+4276
-2320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+4276
-2320
lines changed

src/liballoc/heap.rs

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
1313
// and `nonnull`
1414

15+
use core::ptr::RawPtr;
1516
#[cfg(not(test))] use core::raw;
1617
#[cfg(not(test))] use util;
1718

@@ -69,6 +70,11 @@ pub unsafe fn reallocate_inplace(ptr: *mut u8, size: uint, align: uint,
6970
/// the value returned by `usable_size` for the requested size.
7071
#[inline]
7172
pub unsafe fn deallocate(ptr: *mut u8, size: uint, align: uint) {
73+
// FIXME(14395) This is only required for DST ~[T], it should be removed once
74+
// we fix that representation to not use null pointers.
75+
if ptr.is_null() {
76+
return;
77+
}
7278
imp::deallocate(ptr, size, align)
7379
}
7480

src/libcollections/bitv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2557,7 +2557,7 @@ mod tests {
25572557
}
25582558

25592559
fn rng() -> rand::IsaacRng {
2560-
let seed = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
2560+
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
25612561
rand::SeedableRng::from_seed(seed)
25622562
}
25632563

src/libcollections/dlist.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,8 @@ mod tests {
10881088
let n = list_from([1i,2,3]);
10891089
spawn(proc() {
10901090
check_links(&n);
1091-
assert_eq!(&[&1,&2,&3], n.iter().collect::<Vec<&int>>().as_slice());
1091+
let a: &[_] = &[&1,&2,&3];
1092+
assert_eq!(a, n.iter().collect::<Vec<&int>>().as_slice());
10921093
});
10931094
}
10941095

src/libcollections/hash/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ mod tests {
346346
assert_eq!(hasher.hash(&'a'), 97);
347347

348348
assert_eq!(hasher.hash(&("a")), 97 + 0xFF);
349-
assert_eq!(hasher.hash(& &[1u8, 2u8, 3u8]), 9);
349+
let cs: &[u8] = &[1u8, 2u8, 3u8];
350+
assert_eq!(hasher.hash(& cs), 9);
350351

351352
unsafe {
352353
let ptr: *const int = mem::transmute(5i);

src/libcollections/hash/sip.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ mod tests {
495495
assert!(s != t && t != u);
496496
assert!(hash(&s) != hash(&t) && hash(&s) != hash(&u));
497497

498-
let v = (&[1u8], &[0u8, 0], &[0u8]);
499-
let w = (&[1u8, 0, 0, 0], &[], &[]);
498+
let v: (&[u8], &[u8], &[u8]) = (&[1u8], &[0u8, 0], &[0u8]);
499+
let w: (&[u8], &[u8], &[u8]) = (&[1u8, 0, 0, 0], &[], &[]);
500500

501501
assert!(v != w);
502502
assert!(hash(&v) != hash(&w));

src/libcollections/ringbuf.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ impl<T> RingBuf<T> {
243243
/// buf.push(5i);
244244
/// buf.push(3);
245245
/// buf.push(4);
246-
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), &[&5, &3, &4]);
246+
/// let b: &[_] = &[&5, &3, &4];
247+
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), b);
247248
/// ```
248249
pub fn iter<'a>(&'a self) -> Items<'a, T> {
249250
Items{index: 0, rindex: self.nelts, lo: self.lo, elts: self.elts.as_slice()}
@@ -263,7 +264,8 @@ impl<T> RingBuf<T> {
263264
/// for num in buf.mut_iter() {
264265
/// *num = *num - 2;
265266
/// }
266-
/// assert_eq!(buf.mut_iter().collect::<Vec<&mut int>>().as_slice(), &[&mut 3, &mut 1, &mut 2]);
267+
/// let b: &[_] = &[&mut 3, &mut 1, &mut 2];
268+
/// assert_eq!(buf.mut_iter().collect::<Vec<&mut int>>().as_slice(), b);
267269
/// ```
268270
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
269271
let start_index = raw_index(self.lo, self.elts.len(), 0);
@@ -865,12 +867,18 @@ mod tests {
865867
for i in range(0i, 5) {
866868
d.push_back(i);
867869
}
868-
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), &[&0,&1,&2,&3,&4]);
870+
{
871+
let b: &[_] = &[&0,&1,&2,&3,&4];
872+
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), b);
873+
}
869874

870875
for i in range(6i, 9) {
871876
d.push_front(i);
872877
}
873-
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), &[&8,&7,&6,&0,&1,&2,&3,&4]);
878+
{
879+
let b: &[_] = &[&8,&7,&6,&0,&1,&2,&3,&4];
880+
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), b);
881+
}
874882

875883
let mut it = d.iter();
876884
let mut len = d.len();
@@ -890,12 +898,16 @@ mod tests {
890898
for i in range(0i, 5) {
891899
d.push_back(i);
892900
}
893-
assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), &[&4,&3,&2,&1,&0]);
901+
{
902+
let b: &[_] = &[&4,&3,&2,&1,&0];
903+
assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), b);
904+
}
894905

895906
for i in range(6i, 9) {
896907
d.push_front(i);
897908
}
898-
assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), &[&4,&3,&2,&1,&0,&6,&7,&8]);
909+
let b: &[_] = &[&4,&3,&2,&1,&0,&6,&7,&8];
910+
assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), b);
899911
}
900912

901913
#[test]

0 commit comments

Comments
 (0)