Skip to content

Commit 426ed7c

Browse files
committed
---
yaml --- r: 59892 b: refs/heads/master c: 326d966 h: refs/heads/master v: v3
1 parent 029b13f commit 426ed7c

File tree

11 files changed

+114
-16
lines changed

11 files changed

+114
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6883814a84d584e1fd65a1d40229807ff3d34efb
2+
refs/heads/master: 326d9661b7cdeb0e429468b378fb2af716a3a955
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/libcore/hashmap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ pub impl <T:Hash + Eq> HashSet<T> {
833833
}
834834
}
835835

836-
#[test]
836+
#[cfg(test)]
837837
mod test_map {
838838
use container::{Container, Map, Set};
839839
use option::{None, Some};
@@ -1009,7 +1009,7 @@ mod test_map {
10091009
}
10101010
}
10111011

1012-
#[test]
1012+
#[cfg(test)]
10131013
mod test_set {
10141014
use super::*;
10151015
use container::{Container, Map, Set};

trunk/src/libcore/iterator.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub trait Iterator<A> {
2929
///
3030
/// In the future these will be default methods instead of a utility trait.
3131
pub trait IteratorUtil<A> {
32-
fn chain(self, other: Self) -> ChainIterator<Self>;
32+
fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<Self, U>;
3333
fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<Self, U>;
3434
// FIXME: #5898: should be called map
3535
fn transform<'r, B>(self, f: &'r fn(A) -> B) -> MapIterator<'r, A, B, Self>;
@@ -50,7 +50,7 @@ pub trait IteratorUtil<A> {
5050
/// In the future these will be default methods instead of a utility trait.
5151
impl<A, T: Iterator<A>> IteratorUtil<A> for T {
5252
#[inline(always)]
53-
fn chain(self, other: T) -> ChainIterator<T> {
53+
fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<T, U> {
5454
ChainIterator{a: self, b: other, flag: false}
5555
}
5656

@@ -115,13 +115,13 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
115115
}
116116
}
117117

118-
pub struct ChainIterator<T> {
118+
pub struct ChainIterator<T, U> {
119119
priv a: T,
120-
priv b: T,
120+
priv b: U,
121121
priv flag: bool
122122
}
123123

124-
impl<A, T: Iterator<A>> Iterator<A> for ChainIterator<T> {
124+
impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for ChainIterator<T, U> {
125125
#[inline]
126126
fn next(&mut self) -> Option<A> {
127127
if self.flag {
@@ -385,7 +385,7 @@ mod tests {
385385
#[test]
386386
fn test_iterator_chain() {
387387
let xs = [0u, 1, 2, 3, 4, 5];
388-
let ys = [30, 40, 50, 60];
388+
let ys = [30u, 40, 50, 60];
389389
let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
390390
let mut it = xs.iter().chain(ys.iter());
391391
let mut i = 0;
@@ -394,6 +394,15 @@ mod tests {
394394
i += 1;
395395
}
396396
assert_eq!(i, expected.len());
397+
398+
let ys = Counter::new(30u, 10).take(4);
399+
let mut it = xs.iter().transform(|&x| x).chain(ys);
400+
let mut i = 0;
401+
for it.advance |x: uint| {
402+
assert_eq!(x, expected[i]);
403+
i += 1;
404+
}
405+
assert_eq!(i, expected.len());
397406
}
398407

399408
#[test]

trunk/src/libcore/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ pub fn write_repr<T>(writer: @Writer, object: &T) {
673673
}
674674
}
675675
676-
#[test]
676+
#[cfg(test)]
677677
struct P {a: int, b: float}
678678
679679
#[test]

trunk/src/libcore/task/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ fn test_run_basic() {
797797
po.recv();
798798
}
799799
800-
#[test]
800+
#[cfg(test)]
801801
struct Wrapper {
802802
mut f: Option<Chan<()>>
803803
}

trunk/src/librustc/front/test.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
141141
debug!("current path: %s",
142142
ast_util::path_name_i(copy cx.path, cx.sess.parse_sess.interner));
143143

144-
if is_test_fn(i) || is_bench_fn(i) {
144+
if is_test_fn(cx, i) || is_bench_fn(i) {
145145
match i.node {
146146
ast::item_fn(_, purity, _, _, _) if purity == ast::unsafe_fn => {
147147
let sess = cx.sess;
@@ -169,7 +169,7 @@ fn fold_item(cx: @mut TestCtxt, i: @ast::item, fld: @fold::ast_fold)
169169
return res;
170170
}
171171

172-
fn is_test_fn(i: @ast::item) -> bool {
172+
fn is_test_fn(cx: @mut TestCtxt, i: @ast::item) -> bool {
173173
let has_test_attr = !attr::find_attrs_by_name(i.attrs,
174174
~"test").is_empty();
175175

@@ -188,6 +188,13 @@ fn is_test_fn(i: @ast::item) -> bool {
188188
}
189189
}
190190

191+
if has_test_attr && !has_test_signature(i) {
192+
let sess = cx.sess;
193+
sess.span_err(
194+
i.span,
195+
~"functions used as tests must have signature fn() -> ()."
196+
);
197+
}
191198
return has_test_attr && has_test_signature(i);
192199
}
193200

trunk/src/librustc/middle/ty.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,15 @@ pub impl TypeContents {
18181818
if cx.vecs_implicitly_copyable {base} else {base + TC_OWNED_VEC}
18191819
}
18201820
1821+
fn is_safe_for_default_mode(&self, cx: ctxt) -> bool {
1822+
!self.intersects(TypeContents::nondefault_mode(cx))
1823+
}
1824+
1825+
fn nondefault_mode(cx: ctxt) -> TypeContents {
1826+
let tc = TypeContents::nonimplicitly_copyable(cx);
1827+
tc + TC_BIG + TC_OWNED_VEC // disregard cx.vecs_implicitly_copyable
1828+
}
1829+
18211830
fn needs_drop(&self, cx: ctxt) -> bool {
18221831
let tc = TC_MANAGED + TC_DTOR + TypeContents::owned(cx);
18231832
self.intersects(tc)
@@ -1877,6 +1886,9 @@ static TC_MUTABLE: TypeContents = TypeContents{bits:0b000010000000};
18771886
/// Mutable content, whether owned or by ref
18781887
static TC_ONCE_CLOSURE: TypeContents = TypeContents{bits:0b000100000000};
18791888
1889+
/// Something we estimate to be "big"
1890+
static TC_BIG: TypeContents = TypeContents{bits:0b001000000000};
1891+
18801892
/// An enum with no variants.
18811893
static TC_EMPTY_ENUM: TypeContents = TypeContents{bits:0b010000000000};
18821894
@@ -2097,6 +2109,10 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
20972109
}
20982110
};
20992111
2112+
if type_size(cx, ty) > 4 {
2113+
result = result + TC_BIG;
2114+
}
2115+
21002116
cache.insert(ty_id, result);
21012117
return result;
21022118
}
@@ -2172,6 +2188,68 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
21722188
debug!("result = %s", r.to_str());
21732189
return r;
21742190
}
2191+
2192+
/// gives a rough estimate of how much space it takes to represent
2193+
/// an instance of `ty`. Used for the mode transition.
2194+
fn type_size(cx: ctxt, ty: t) -> uint {
2195+
match get(ty).sty {
2196+
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
2197+
ty_ptr(_) | ty_box(_) | ty_uniq(_) | ty_estr(vstore_uniq) |
2198+
ty_trait(*) | ty_rptr(*) | ty_evec(_, vstore_uniq) |
2199+
ty_evec(_, vstore_box) | ty_estr(vstore_box) => {
2200+
1
2201+
}
2202+
2203+
ty_evec(_, vstore_slice(_)) |
2204+
ty_estr(vstore_slice(_)) |
2205+
ty_bare_fn(*) |
2206+
ty_closure(*) => {
2207+
2
2208+
}
2209+
2210+
ty_evec(t, vstore_fixed(n)) => {
2211+
type_size(cx, t.ty) * n
2212+
}
2213+
2214+
ty_estr(vstore_fixed(n)) => {
2215+
n
2216+
}
2217+
2218+
ty_struct(did, ref substs) => {
2219+
let flds = struct_fields(cx, did, substs);
2220+
flds.foldl(0, |s, f| *s + type_size(cx, f.mt.ty))
2221+
}
2222+
2223+
ty_tup(ref tys) => {
2224+
tys.foldl(0, |s, t| *s + type_size(cx, *t))
2225+
}
2226+
2227+
ty_enum(did, ref substs) => {
2228+
let variants = substd_enum_variants(cx, did, substs);
2229+
variants.foldl( // find max size of any variant
2230+
0,
2231+
|m, v| uint::max(
2232+
*m,
2233+
// find size of this variant:
2234+
v.args.foldl(0, |s, a| *s + type_size(cx, *a))))
2235+
}
2236+
2237+
ty_param(_) | ty_self(_) => {
2238+
1
2239+
}
2240+
2241+
ty_infer(_) => {
2242+
cx.sess.bug(~"Asked to compute kind of a type variable");
2243+
}
2244+
ty_type => 1,
2245+
ty_opaque_closure_ptr(_) => 1,
2246+
ty_opaque_box => 1,
2247+
ty_unboxed_vec(_) => 10,
2248+
ty_err => {
2249+
cx.sess.bug(~"Asked to compute kind of fictitious type");
2250+
}
2251+
}
2252+
}
21752253
}
21762254
21772255
pub fn type_moves_by_default(cx: ctxt, ty: t) -> bool {

trunk/src/libstd/cmp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn test_fuzzy_eq_eps() {
6464
assert!(!(&1.5f).fuzzy_eq_eps(&0.9, &0.5));
6565
}
6666

67-
#[test]
67+
#[cfg(test)]
6868
mod test_complex{
6969
use cmp::*;
7070

trunk/src/libstd/deque.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ mod tests {
353353
assert!(*deq.get(3) == d);
354354
}
355355

356-
#[test]
356+
#[cfg(test)]
357357
fn test_parameterized<T:Copy + Eq + Durable>(a: T, b: T, c: T, d: T) {
358358
let mut deq = Deque::new();
359359
assert!(deq.len() == 0);

trunk/src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ mod test {
418418
new_parser_from_source_str(ps,~[],~"bogofile",source_str)
419419
}
420420

421-
#[test] fn to_json_str<E : Encodable<std::json::Encoder>>(val: @E) -> ~str {
421+
#[cfg(test)] fn to_json_str<E : Encodable<std::json::Encoder>>(val: @E) -> ~str {
422422
do io::with_str_writer |writer| {
423423
val.encode(~std::json::Encoder(writer));
424424
}

trunk/src/rt/rust_task.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@
175175
#define RED_ZONE_SIZE RZ_MAC_32
176176
#endif
177177

178+
#ifndef RED_ZONE_SIZE
179+
# error "Red zone not defined for this platform"
180+
#endif
181+
178182
struct frame_glue_fns {
179183
uintptr_t mark_glue_off;
180184
uintptr_t drop_glue_off;

0 commit comments

Comments
 (0)