Skip to content

Commit

Permalink
auto merge of rust-lang#14397 : nick29581/rust/coerce, r=pnkfelix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Aug 26, 2014
2 parents 1cad408 + 08364a4 commit 7932b71
Show file tree
Hide file tree
Showing 167 changed files with 4,276 additions and 2,320 deletions.
6 changes: 6 additions & 0 deletions src/liballoc/heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
// and `nonnull`

use core::ptr::RawPtr;
#[cfg(not(test))] use core::raw;
#[cfg(not(test))] use util;

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

Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ mod tests {
}

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

Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,8 @@ mod tests {
let n = list_from([1i,2,3]);
spawn(proc() {
check_links(&n);
assert_eq!(&[&1,&2,&3], n.iter().collect::<Vec<&int>>().as_slice());
let a: &[_] = &[&1,&2,&3];
assert_eq!(a, n.iter().collect::<Vec<&int>>().as_slice());
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ mod tests {
assert_eq!(hasher.hash(&'a'), 97);

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

unsafe {
let ptr: *const int = mem::transmute(5i);
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ mod tests {
assert!(s != t && t != u);
assert!(hash(&s) != hash(&t) && hash(&s) != hash(&u));

let v = (&[1u8], &[0u8, 0], &[0u8]);
let w = (&[1u8, 0, 0, 0], &[], &[]);
let v: (&[u8], &[u8], &[u8]) = (&[1u8], &[0u8, 0], &[0u8]);
let w: (&[u8], &[u8], &[u8]) = (&[1u8, 0, 0, 0], &[], &[]);

assert!(v != w);
assert!(hash(&v) != hash(&w));
Expand Down
24 changes: 18 additions & 6 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ impl<T> RingBuf<T> {
/// buf.push(5i);
/// buf.push(3);
/// buf.push(4);
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), &[&5, &3, &4]);
/// let b: &[_] = &[&5, &3, &4];
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), b);
/// ```
pub fn iter<'a>(&'a self) -> Items<'a, T> {
Items{index: 0, rindex: self.nelts, lo: self.lo, elts: self.elts.as_slice()}
Expand All @@ -263,7 +264,8 @@ impl<T> RingBuf<T> {
/// for num in buf.mut_iter() {
/// *num = *num - 2;
/// }
/// assert_eq!(buf.mut_iter().collect::<Vec<&mut int>>().as_slice(), &[&mut 3, &mut 1, &mut 2]);
/// let b: &[_] = &[&mut 3, &mut 1, &mut 2];
/// assert_eq!(buf.mut_iter().collect::<Vec<&mut int>>().as_slice(), b);
/// ```
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
let start_index = raw_index(self.lo, self.elts.len(), 0);
Expand Down Expand Up @@ -865,12 +867,18 @@ mod tests {
for i in range(0i, 5) {
d.push_back(i);
}
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), &[&0,&1,&2,&3,&4]);
{
let b: &[_] = &[&0,&1,&2,&3,&4];
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), b);
}

for i in range(6i, 9) {
d.push_front(i);
}
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), &[&8,&7,&6,&0,&1,&2,&3,&4]);
{
let b: &[_] = &[&8,&7,&6,&0,&1,&2,&3,&4];
assert_eq!(d.iter().collect::<Vec<&int>>().as_slice(), b);
}

let mut it = d.iter();
let mut len = d.len();
Expand All @@ -890,12 +898,16 @@ mod tests {
for i in range(0i, 5) {
d.push_back(i);
}
assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), &[&4,&3,&2,&1,&0]);
{
let b: &[_] = &[&4,&3,&2,&1,&0];
assert_eq!(d.iter().rev().collect::<Vec<&int>>().as_slice(), b);
}

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

#[test]
Expand Down
Loading

0 comments on commit 7932b71

Please sign in to comment.