Skip to content

Commit bcdfb59

Browse files
committed
---
yaml --- r: 83953 b: refs/heads/dist-snap c: 58eb70a h: refs/heads/master i: 83951: 629746c v: v3
1 parent 0a2e8d3 commit bcdfb59

File tree

7 files changed

+39
-192
lines changed

7 files changed

+39
-192
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 20016b92c8c03e33ad9b965fba32ac851fe9f6bf
9+
refs/heads/dist-snap: 58eb70a5e2ce6602e5685f5cc18ab2fe0c327020
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/treemap.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,25 @@ impl<K: Eq + TotalOrd, V: Eq> Eq for TreeMap<K, V> {
5757
}
5858

5959
// Lexicographical comparison
60-
fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
60+
fn lt<K: Ord + TotalOrd, V: Ord>(a: &TreeMap<K, V>,
6161
b: &TreeMap<K, V>) -> bool {
6262
let mut x = a.iter();
6363
let mut y = b.iter();
6464

6565
let (a_len, b_len) = (a.len(), b.len());
6666
for uint::min(a_len, b_len).times {
67-
let (key_a,_) = x.next().unwrap();
68-
let (key_b,_) = y.next().unwrap();
67+
let (key_a, value_a) = x.next().unwrap();
68+
let (key_b, value_b) = y.next().unwrap();
6969
if *key_a < *key_b { return true; }
7070
if *key_a > *key_b { return false; }
71-
};
71+
if *value_a < *value_b { return true; }
72+
if *value_a > *value_b { return false; }
73+
}
7274

7375
a_len < b_len
7476
}
7577

76-
impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
78+
impl<K: Ord + TotalOrd, V: Ord> Ord for TreeMap<K, V> {
7779
#[inline]
7880
fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
7981
#[inline]
@@ -935,7 +937,7 @@ mod test_treemap {
935937
assert!(b.insert(0, 5));
936938
assert!(a < b);
937939
assert!(a.insert(0, 7));
938-
assert!(!(a < b) && !(b < a));
940+
assert!(!(a < b) && b < a);
939941
assert!(b.insert(-2, 0));
940942
assert!(b < a);
941943
assert!(a.insert(-5, 2));

branches/dist-snap/src/librustc/middle/trans/machine.rs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ use lib::llvm::{ValueRef};
1414
use lib::llvm::False;
1515
use lib::llvm::llvm;
1616
use middle::trans::common::*;
17-
use middle::trans::type_of;
18-
use middle::ty;
19-
use util::ppaux::ty_to_str;
2017

2118
use middle::trans::type_::Type;
2219

@@ -116,42 +113,3 @@ pub fn llalign_of(cx: &CrateContext, ty: Type) -> ValueRef {
116113
llvm::LLVMAlignOf(ty.to_ref()), cx.int_type.to_ref(), False);
117114
}
118115
}
119-
120-
// Computes the size of the data part of an enum.
121-
pub fn static_size_of_enum(cx: &mut CrateContext, t: ty::t) -> uint {
122-
if cx.enum_sizes.contains_key(&t) {
123-
return cx.enum_sizes.get_copy(&t);
124-
}
125-
126-
debug!("static_size_of_enum %s", ty_to_str(cx.tcx, t));
127-
128-
match ty::get(t).sty {
129-
ty::ty_enum(tid, ref substs) => {
130-
// Compute max(variant sizes).
131-
let mut max_size = 0;
132-
let variants = ty::enum_variants(cx.tcx, tid);
133-
for variants.iter().advance |variant| {
134-
if variant.args.len() == 0 {
135-
loop;
136-
}
137-
138-
let lltypes = variant.args.map(|&variant_arg| {
139-
let substituted = ty::subst(cx.tcx, substs, variant_arg);
140-
type_of::sizing_type_of(cx, substituted)
141-
});
142-
143-
debug!("static_size_of_enum: variant %s type %s",
144-
cx.tcx.sess.str_of(variant.name),
145-
cx.tn.type_to_str(Type::struct_(lltypes, false)));
146-
147-
let this_size = llsize_of_real(cx, Type::struct_(lltypes, false));
148-
if max_size < this_size {
149-
max_size = this_size;
150-
}
151-
}
152-
cx.enum_sizes.insert(t, max_size);
153-
return max_size;
154-
}
155-
_ => cx.sess.bug("static_size_of_enum called on non-enum")
156-
}
157-
}

branches/dist-snap/src/librustc/middle/trans/type_of.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ pub fn type_of_non_gc_box(cx: &mut CrateContext, t: ty::t) -> Type {
104104
//
105105
// (2) It won't make any recursive calls to determine the structure of the
106106
// type behind pointers. This can help prevent infinite loops for
107-
// recursive types. For example, `static_size_of_enum()` relies on this
108-
// behavior.
107+
// recursive types. For example, enum types rely on this behavior.
109108

110109
pub fn sizing_type_of(cx: &mut CrateContext, t: ty::t) -> Type {
111110
match cx.llsizingtypes.find_copy(&t) {

branches/dist-snap/src/librustc/util/enum_set.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ impl<E:CLike> Iterator<E> for EnumSetIterator<E> {
125125
Some(elem)
126126
}
127127

128-
fn size_hint(&self) -> (uint, Option<uint>) {
129-
let exact = self.bits.population_count();
130-
(exact, Some(exact))
128+
fn size_hint(&self) -> (Option<uint>, Option<uint>) {
129+
let exact = Some(self.bits.population_count());
130+
(exact, exact)
131131
}
132132
}
133133

branches/dist-snap/src/libstd/iterator.rs

Lines changed: 12 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use option::{Option, Some, None};
2626
use ops::{Add, Mul};
2727
use cmp::Ord;
2828
use clone::Clone;
29-
use uint;
3029

3130
/// Conversion from an `Iterator`
3231
pub trait FromIterator<A, T: Iterator<A>> {
@@ -44,7 +43,7 @@ pub trait Iterator<A> {
4443
/// Return a lower bound and upper bound on the remaining length of the iterator.
4544
///
4645
/// The common use case for the estimate is pre-allocating space to store the results.
47-
fn size_hint(&self) -> (uint, Option<uint>) { (0, None) }
46+
fn size_hint(&self) -> (Option<uint>, Option<uint>) { (None, None) }
4847
}
4948

5049
/// Iterator adaptors provided for every `Iterator` implementation. The adaptor objects are also
@@ -685,18 +684,18 @@ impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for ChainIterator<A, T, U> {
685684
}
686685

687686
#[inline]
688-
fn size_hint(&self) -> (uint, Option<uint>) {
687+
fn size_hint(&self) -> (Option<uint>, Option<uint>) {
689688
let (a_lower, a_upper) = self.a.size_hint();
690689
let (b_lower, b_upper) = self.b.size_hint();
691690

692-
let lower = if uint::max_value - a_lower < b_lower {
693-
uint::max_value
694-
} else {
695-
a_lower + b_lower
691+
let lower = match (a_lower, b_lower) {
692+
(Some(x), Some(y)) => Some(x + y),
693+
(Some(x), None) => Some(x),
694+
(None, Some(y)) => Some(y),
695+
(None, None) => None
696696
};
697697

698698
let upper = match (a_upper, b_upper) {
699-
(Some(x), Some(y)) if uint::max_value - x < y => Some(uint::max_value),
700699
(Some(x), Some(y)) => Some(x + y),
701700
_ => None
702701
};
@@ -720,23 +719,6 @@ impl<A, B, T: Iterator<A>, U: Iterator<B>> Iterator<(A, B)> for ZipIterator<A, T
720719
_ => None
721720
}
722721
}
723-
724-
#[inline]
725-
fn size_hint(&self) -> (uint, Option<uint>) {
726-
let (a_lower, a_upper) = self.a.size_hint();
727-
let (b_lower, b_upper) = self.b.size_hint();
728-
729-
let lower = cmp::min(a_lower, b_lower);
730-
731-
let upper = match (a_upper, b_upper) {
732-
(Some(x), Some(y)) => Some(cmp::min(x,y)),
733-
(Some(x), None) => Some(x),
734-
(None, Some(y)) => Some(y),
735-
(None, None) => None
736-
};
737-
738-
(lower, upper)
739-
}
740722
}
741723

742724
/// An iterator which maps the values of `iter` with `f`
@@ -755,7 +737,7 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for MapIterator<'self, A, B, T> {
755737
}
756738

757739
#[inline]
758-
fn size_hint(&self) -> (uint, Option<uint>) {
740+
fn size_hint(&self) -> (Option<uint>, Option<uint>) {
759741
self.iter.size_hint()
760742
}
761743
}
@@ -780,9 +762,9 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for FilterIterator<'self, A, T> {
780762
}
781763

782764
#[inline]
783-
fn size_hint(&self) -> (uint, Option<uint>) {
765+
fn size_hint(&self) -> (Option<uint>, Option<uint>) {
784766
let (_, upper) = self.iter.size_hint();
785-
(0, upper) // can't know a lower bound, due to the predicate
767+
(None, upper) // can't know a lower bound, due to the predicate
786768
}
787769
}
788770

@@ -805,9 +787,9 @@ impl<'self, A, B, T: Iterator<A>> Iterator<B> for FilterMapIterator<'self, A, B,
805787
}
806788

807789
#[inline]
808-
fn size_hint(&self) -> (uint, Option<uint>) {
790+
fn size_hint(&self) -> (Option<uint>, Option<uint>) {
809791
let (_, upper) = self.iter.size_hint();
810-
(0, upper) // can't know a lower bound, due to the predicate
792+
(None, upper) // can't know a lower bound, due to the predicate
811793
}
812794
}
813795

@@ -830,11 +812,6 @@ impl<A, T: Iterator<A>> Iterator<(uint, A)> for EnumerateIterator<A, T> {
830812
_ => None
831813
}
832814
}
833-
834-
#[inline]
835-
fn size_hint(&self) -> (uint, Option<uint>) {
836-
self.iter.size_hint()
837-
}
838815
}
839816

840817
/// An iterator which rejects elements while `predicate` is true
@@ -867,12 +844,6 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for SkipWhileIterator<'self, A, T> {
867844
}
868845
}
869846
}
870-
871-
#[inline]
872-
fn size_hint(&self) -> (uint, Option<uint>) {
873-
let (_, upper) = self.iter.size_hint();
874-
(0, upper) // can't know a lower bound, due to the predicate
875-
}
876847
}
877848

878849
/// An iterator which only accepts elements while `predicate` is true
@@ -901,12 +872,6 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for TakeWhileIterator<'self, A, T> {
901872
}
902873
}
903874
}
904-
905-
#[inline]
906-
fn size_hint(&self) -> (uint, Option<uint>) {
907-
let (_, upper) = self.iter.size_hint();
908-
(0, upper) // can't know a lower bound, due to the predicate
909-
}
910875
}
911876

912877
/// An iterator which skips over `n` elements of `iter`.
@@ -940,21 +905,6 @@ impl<A, T: Iterator<A>> Iterator<A> for SkipIterator<A, T> {
940905
next
941906
}
942907
}
943-
944-
#[inline]
945-
fn size_hint(&self) -> (uint, Option<uint>) {
946-
let (lower, upper) = self.iter.size_hint();
947-
948-
let lower = if lower >= self.n { lower - self.n } else { 0 };
949-
950-
let upper = match upper {
951-
Some(x) if x >= self.n => Some(x - self.n),
952-
Some(_) => Some(0),
953-
None => None
954-
};
955-
956-
(lower, upper)
957-
}
958908
}
959909

960910
/// An iterator which only iterates over the first `n` iterations of `iter`.
@@ -975,20 +925,6 @@ impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<A, T> {
975925
None
976926
}
977927
}
978-
979-
#[inline]
980-
fn size_hint(&self) -> (uint, Option<uint>) {
981-
let (lower, upper) = self.iter.size_hint();
982-
983-
let lower = cmp::min(lower, self.n);
984-
985-
let upper = match upper {
986-
Some(x) if x < self.n => Some(x),
987-
_ => Some(self.n)
988-
};
989-
990-
(lower, upper)
991-
}
992928
}
993929

994930
/// An iterator to maintain state while iterating another iterator
@@ -1005,12 +941,6 @@ impl<'self, A, B, T: Iterator<A>, St> Iterator<B> for ScanIterator<'self, A, B,
1005941
fn next(&mut self) -> Option<B> {
1006942
self.iter.next().chain(|a| (self.f)(&mut self.state, a))
1007943
}
1008-
1009-
#[inline]
1010-
fn size_hint(&self) -> (uint, Option<uint>) {
1011-
let (_, upper) = self.iter.size_hint();
1012-
(0, upper) // can't know a lower bound, due to the scan function
1013-
}
1014944
}
1015945

1016946
/// An iterator that maps each element to an iterator,
@@ -1092,11 +1022,6 @@ impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
10921022
self.state = self.state.add(&self.step); // FIXME: #6050
10931023
Some(result)
10941024
}
1095-
1096-
#[inline]
1097-
fn size_hint(&self) -> (uint, Option<uint>) {
1098-
(uint::max_value, None) // Too bad we can't specify an infinite lower bound
1099-
}
11001025
}
11011026

11021027
#[cfg(test)]
@@ -1312,43 +1237,6 @@ mod tests {
13121237
assert_eq!(v.slice(0, 0).iter().transform(|&x| x).min(), None);
13131238
}
13141239

1315-
#[test]
1316-
fn test_iterator_size_hint() {
1317-
let c = Counter::new(0, 1);
1318-
let v = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
1319-
let v2 = &[10, 11, 12];
1320-
let vi = v.iter();
1321-
1322-
assert_eq!(c.size_hint(), (uint::max_value, None));
1323-
assert_eq!(vi.size_hint(), (10, Some(10)));
1324-
1325-
assert_eq!(c.take_(5).size_hint(), (5, Some(5)));
1326-
assert_eq!(c.skip(5).size_hint().second(), None);
1327-
assert_eq!(c.take_while(|_| false).size_hint(), (0, None));
1328-
assert_eq!(c.skip_while(|_| false).size_hint(), (0, None));
1329-
assert_eq!(c.enumerate().size_hint(), (uint::max_value, None));
1330-
assert_eq!(c.chain_(vi.transform(|&i| i)).size_hint(), (uint::max_value, None));
1331-
assert_eq!(c.zip(vi).size_hint(), (10, Some(10)));
1332-
assert_eq!(c.scan(0, |_,_| Some(0)).size_hint(), (0, None));
1333-
assert_eq!(c.filter(|_| false).size_hint(), (0, None));
1334-
assert_eq!(c.transform(|_| 0).size_hint(), (uint::max_value, None));
1335-
assert_eq!(c.filter_map(|_| Some(0)).size_hint(), (0, None));
1336-
1337-
assert_eq!(vi.take_(5).size_hint(), (5, Some(5)));
1338-
assert_eq!(vi.take_(12).size_hint(), (10, Some(10)));
1339-
assert_eq!(vi.skip(3).size_hint(), (7, Some(7)));
1340-
assert_eq!(vi.skip(12).size_hint(), (0, Some(0)));
1341-
assert_eq!(vi.take_while(|_| false).size_hint(), (0, Some(10)));
1342-
assert_eq!(vi.skip_while(|_| false).size_hint(), (0, Some(10)));
1343-
assert_eq!(vi.enumerate().size_hint(), (10, Some(10)));
1344-
assert_eq!(vi.chain_(v2.iter()).size_hint(), (13, Some(13)));
1345-
assert_eq!(vi.zip(v2.iter()).size_hint(), (3, Some(3)));
1346-
assert_eq!(vi.scan(0, |_,_| Some(0)).size_hint(), (0, Some(10)));
1347-
assert_eq!(vi.filter(|_| false).size_hint(), (0, Some(10)));
1348-
assert_eq!(vi.transform(|i| i+1).size_hint(), (10, Some(10)));
1349-
assert_eq!(vi.filter_map(|_| Some(0)).size_hint(), (0, Some(10)));
1350-
}
1351-
13521240
#[test]
13531241
fn test_collect() {
13541242
let a = ~[1, 2, 3, 4, 5];

0 commit comments

Comments
 (0)