Permalink
Browse files

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.
  • Loading branch information...
bors committed Aug 26, 2014
2 parents 1cad408 + 08364a4 commit 7932b719ec2b65acfa8c3e74aad29346d47ee992
Showing with 4,276 additions and 2,320 deletions.
  1. +6 −0 src/liballoc/heap.rs
  2. +1 −1 src/libcollections/bitv.rs
  3. +2 −1 src/libcollections/dlist.rs
  4. +2 −1 src/libcollections/hash/mod.rs
  5. +2 −2 src/libcollections/hash/sip.rs
  6. +18 −6 src/libcollections/ringbuf.rs
  7. +143 −76 src/libcollections/slice.rs
  8. +39 −24 src/libcollections/str.rs
  9. +4 −2 src/libcollections/string.rs
  10. +2 −1 src/libcollections/treemap.rs
  11. +3 −2 src/libcore/cmp.rs
  12. +7 −0 src/libcore/intrinsics.rs
  13. +1 −1 src/libcore/mem.rs
  14. +12 −3 src/libcore/option.rs
  15. +6 −0 src/libcore/raw.rs
  16. +21 −1 src/libcore/slice.rs
  17. +12 −7 src/libcore/str.rs
  18. +2 −2 src/libcoretest/iter.rs
  19. +13 −0 src/libdebug/reflect.rs
  20. +14 −0 src/libdebug/repr.rs
  21. +1 −1 src/libgreen/context.rs
  22. +3 −3 src/libnum/bigint.rs
  23. +9 −9 src/librand/isaac.rs
  24. +4 −2 src/librand/lib.rs
  25. +12 −6 src/librbml/io.rs
  26. +0 −6 src/librustc/diagnostics.rs
  27. +6 −5 src/librustc/front/test.rs
  28. +8 −15 src/librustc/lint/builtin.rs
  29. +2 −2 src/librustc/metadata/tydecode.rs
  30. +5 −2 src/librustc/metadata/tyencode.rs
  31. +220 −60 src/librustc/middle/astencode.rs
  32. +4 −5 src/librustc/middle/borrowck/mod.rs
  33. +0 −1 src/librustc/middle/cfg/construct.rs
  34. +9 −10 src/librustc/middle/check_const.rs
  35. +4 −6 src/librustc/middle/check_static.rs
  36. +0 −10 src/librustc/middle/const_eval.rs
  37. +27 −35 src/librustc/middle/expr_use_visitor.rs
  38. +3 −2 src/librustc/middle/intrinsicck.rs
  39. +16 −4 src/librustc/middle/kind.rs
  40. +2 −7 src/librustc/middle/liveness.rs
  41. +50 −58 src/librustc/middle/mem_categorization.rs
  42. +0 −4 src/librustc/middle/region.rs
  43. +1 −1 src/librustc/middle/subst.rs
  44. +5 −5 src/librustc/middle/trans/_match.rs
  45. +48 −22 src/librustc/middle/trans/adt.rs
  46. +57 −32 src/librustc/middle/trans/base.rs
  47. +6 −1 src/librustc/middle/trans/callee.rs
  48. +5 −1 src/librustc/middle/trans/common.rs
  49. +97 −99 src/librustc/middle/trans/consts.rs
  50. +2 −2 src/librustc/middle/trans/controlflow.rs
  51. +26 −7 src/librustc/middle/trans/datum.rs
  52. +41 −153 src/librustc/middle/trans/debuginfo.rs
  53. +394 −136 src/librustc/middle/trans/expr.rs
  54. +201 −45 src/librustc/middle/trans/glue.rs
  55. +14 −4 src/librustc/middle/trans/intrinsic.rs
  56. +40 −18 src/librustc/middle/trans/meth.rs
  57. +37 −21 src/librustc/middle/trans/reflect.rs
  58. +132 −123 src/librustc/middle/trans/tvec.rs
  59. +10 −3 src/librustc/middle/trans/type_.rs
  60. +87 −45 src/librustc/middle/trans/type_of.rs
  61. +304 −182 src/librustc/middle/ty.rs
  62. +23 −6 src/librustc/middle/ty_fold.rs
  63. +42 −76 src/librustc/middle/typeck/astconv.rs
  64. +5 −5 src/librustc/middle/typeck/check/_match.rs
  65. +14 −0 src/librustc/middle/typeck/check/demand.rs
  66. +95 −71 src/librustc/middle/typeck/check/method.rs
  67. +175 −209 src/librustc/middle/typeck/check/mod.rs
  68. +36 −45 src/librustc/middle/typeck/check/regionck.rs
  69. +149 −104 src/librustc/middle/typeck/check/vtable.rs
  70. +7 −13 src/librustc/middle/typeck/check/writeback.rs
  71. +5 −2 src/librustc/middle/typeck/coherence.rs
  72. +199 −108 src/librustc/middle/typeck/infer/coercion.rs
  73. +3 −3 src/librustc/middle/typeck/infer/combine.rs
  74. +2 −2 src/librustc/middle/typeck/infer/error_reporting.rs
  75. +13 −0 src/librustc/middle/typeck/infer/sub.rs
  76. +1 −5 src/librustc/middle/typeck/variance.rs
  77. +6 −5 src/librustc/util/ppaux.rs
  78. +2 −8 src/librustc_back/abi.rs
  79. +0 −2 src/librustc_back/svh.rs
  80. +3 −2 src/librustdoc/clean/mod.rs
  81. +2 −1 src/librustdoc/html/render.rs
  82. +4 −2 src/librustuv/homing.rs
  83. +3 −2 src/librustuv/lib.rs
  84. +3 −2 src/libserialize/hex.rs
  85. +6 −6 src/libstd/ascii.rs
  86. +38 −24 src/libstd/io/buffered.rs
  87. +8 −5 src/libstd/io/comm_adapters.rs
  88. +25 −13 src/libstd/io/mem.rs
  89. +2 −1 src/libstd/io/result.rs
  90. +2 −1 src/libstd/os.rs
  91. +4 −1 src/libstd/path/mod.rs
  92. +52 −41 src/libstd/path/posix.rs
  93. +48 −37 src/libstd/path/windows.rs
  94. +6 −3 src/libstd/rand/mod.rs
  95. +0 −11 src/libsyntax/ast.rs
  96. +1 −10 src/libsyntax/ext/build.rs
  97. +0 −3 src/libsyntax/fold.rs
  98. +2 −1 src/libsyntax/parse/mod.rs
  99. +42 −67 src/libsyntax/parse/parser.rs
  100. +3 −15 src/libsyntax/print/pprust.rs
  101. +4 −1 src/libsyntax/util/small_vector.rs
  102. +0 −3 src/libsyntax/visit.rs
  103. +1 −2 src/libtime/lib.rs
  104. +6 −3 src/libunicode/u_str.rs
  105. +4 −2 src/liburl/lib.rs
  106. +2 −1 src/test/bench/core-map.rs
  107. +1 −1 src/test/bench/core-set.rs
  108. +4 −2 src/test/compile-fail/const-cast-different-types.rs
  109. +46 −0 src/test/compile-fail/dst-bad-assign-2.rs
  110. +46 −0 src/test/compile-fail/dst-bad-assign.rs
  111. +32 −0 src/test/compile-fail/dst-bad-coerce1.rs
  112. +31 −0 src/test/compile-fail/dst-bad-coerce2.rs
  113. +35 −0 src/test/compile-fail/dst-bad-coerce3.rs
  114. +22 −0 src/test/compile-fail/dst-bad-coerce4.rs
  115. +25 −0 src/test/compile-fail/dst-bad-deep.rs
  116. +2 −3 src/test/compile-fail/issue-10291.rs
  117. +3 −1 src/test/compile-fail/issue-13446.rs
  118. +3 −1 src/test/compile-fail/issue-3907-2.rs
  119. +2 −2 src/test/compile-fail/issue-4523.rs
  120. +1 −1 src/test/compile-fail/issue-4972.rs
  121. +3 −1 src/test/compile-fail/issue-5035-2.rs
  122. +3 −4 src/test/compile-fail/issue-5883.rs
  123. +1 −1 src/test/compile-fail/issue-7013.rs
  124. +4 −6 src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs
  125. +4 −4 src/test/compile-fail/lub-if.rs
  126. +2 −2 src/test/compile-fail/lub-match.rs
  127. +1 −1 src/test/compile-fail/regions-early-bound-error-method.rs
  128. +1 −1 src/test/compile-fail/regions-early-bound-error.rs
  129. +2 −2 src/test/compile-fail/regions-glb-free-free.rs
  130. +1 −2 src/test/compile-fail/regions-nested-fns.rs
  131. +1 −1 src/test/compile-fail/regions-ret-borrowed-1.rs
  132. +1 −1 src/test/compile-fail/regions-ret-borrowed.rs
  133. +1 −1 src/test/compile-fail/regions-return-stack-allocated-vec.rs
  134. +1 −1 src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
  135. +1 −1 src/test/compile-fail/tuple-arity-mismatch.rs
  136. +3 −3 src/test/pretty/issue-4264.pp
  137. +11 −11 src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot
  138. +2 −2 src/test/run-make/graphviz-flowgraph/f15.rs
  139. +11 −11 src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot
  140. +2 −2 src/test/run-make/graphviz-flowgraph/f16.rs
  141. +14 −8 src/test/run-pass/byte-literals.rs
  142. +40 −0 src/test/run-pass/check-static-slice.rs
  143. +12 −0 src/test/run-pass/const-enum-vec-index.rs
  144. +34 −0 src/test/run-pass/dst-dtor-1.rs
  145. +31 −0 src/test/run-pass/dst-dtor-2.rs
  146. +61 −0 src/test/run-pass/dst-struct-reflect.rs
  147. +84 −0 src/test/run-pass/dst-struct-sole.rs
  148. +127 −0 src/test/run-pass/dst-struct.rs
  149. +111 −0 src/test/run-pass/dst-trait.rs
  150. +1 −1 src/test/run-pass/evec-slice.rs
  151. +22 −0 src/test/run-pass/gc-vec.rs
  152. +2 −1 src/test/run-pass/issue-14936.rs
  153. +1 −1 src/test/run-pass/issue-15080.rs
  154. +2 −1 src/test/run-pass/issue-7012.rs
  155. +1 −1 src/test/run-pass/issue-9259.rs
  156. +14 −8 src/test/run-pass/match-vec-alternatives.rs
  157. +2 −1 src/test/run-pass/order-drop-with-match.rs
  158. +2 −1 src/test/run-pass/overloaded-deref-count.rs
  159. +3 −1 src/test/run-pass/reflect-visit-type.rs
  160. +16 −8 src/test/run-pass/running-with-no-runtime.rs
  161. +1 −0 src/test/run-pass/smallest-hello-world.rs
  162. +8 −4 src/test/run-pass/syntax-extension-bytes.rs
  163. +3 −2 src/test/run-pass/typeck_type_placeholder_1.rs
  164. +115 −0 src/test/run-pass/vec-dst.rs
  165. +1 −0 src/test/run-pass/vec-matching-legal-tail-element-borrow.rs
  166. +8 −4 src/test/run-pass/vec-matching.rs
  167. +1 −2 src/test/run-pass/vec-to_str.rs
@@ -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;

@@ -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)
}

@@ -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)
}

@@ -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());
});
}

@@ -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);
@@ -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));
@@ -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()}
@@ -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);
@@ -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();
@@ -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]
Oops, something went wrong.

0 comments on commit 7932b71

Please sign in to comment.