Skip to content

Commit c94114a

Browse files
committed
---
yaml --- r: 120496 b: refs/heads/dist-snap c: b991bbe h: refs/heads/master v: v3
1 parent 8f54093 commit c94114a

File tree

12 files changed

+80
-346
lines changed

12 files changed

+80
-346
lines changed

[refs]

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

branches/dist-snap/src/libcollections/bitv.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,17 @@ impl Bitv {
486486
!self.none()
487487
}
488488

489+
pub fn init_to_vec(&self, i: uint) -> uint {
490+
return if self.get(i) { 1 } else { 0 };
491+
}
492+
489493
/**
490494
* Converts `self` to a vector of `uint` with the same length.
491495
*
492496
* Each `uint` in the resulting vector has either value `0u` or `1u`.
493497
*/
494498
pub fn to_vec(&self) -> Vec<uint> {
495-
Vec::from_fn(self.nbits, |i| if self.get(i) { 1 } else { 0 })
499+
Vec::from_fn(self.nbits, |x| self.init_to_vec(x))
496500
}
497501

498502
/**

branches/dist-snap/src/libcore/iter.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ pub mod order {
21842184
use super::Iterator;
21852185

21862186
/// Compare `a` and `b` for equality using `TotalEq`
2187-
pub fn equals<A: TotalEq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
2187+
pub fn equals<A: TotalEq, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
21882188
loop {
21892189
match (a.next(), b.next()) {
21902190
(None, None) => return true,
@@ -2195,7 +2195,7 @@ pub mod order {
21952195
}
21962196

21972197
/// Order `a` and `b` lexicographically using `TotalOrd`
2198-
pub fn cmp<A: TotalOrd, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> cmp::Ordering {
2198+
pub fn cmp<A: TotalOrd, T: Iterator<A>>(mut a: T, mut b: T) -> cmp::Ordering {
21992199
loop {
22002200
match (a.next(), b.next()) {
22012201
(None, None) => return cmp::Equal,
@@ -2210,7 +2210,7 @@ pub mod order {
22102210
}
22112211

22122212
/// Compare `a` and `b` for equality (Using partial equality, `Eq`)
2213-
pub fn eq<A: Eq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
2213+
pub fn eq<A: Eq, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
22142214
loop {
22152215
match (a.next(), b.next()) {
22162216
(None, None) => return true,
@@ -2221,7 +2221,7 @@ pub mod order {
22212221
}
22222222

22232223
/// Compare `a` and `b` for nonequality (Using partial equality, `Eq`)
2224-
pub fn ne<A: Eq, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
2224+
pub fn ne<A: Eq, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
22252225
loop {
22262226
match (a.next(), b.next()) {
22272227
(None, None) => return false,
@@ -2232,7 +2232,7 @@ pub mod order {
22322232
}
22332233

22342234
/// Return `a` < `b` lexicographically (Using partial order, `Ord`)
2235-
pub fn lt<A: Ord, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
2235+
pub fn lt<A: Ord, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
22362236
loop {
22372237
match (a.next(), b.next()) {
22382238
(None, None) => return false,
@@ -2244,7 +2244,7 @@ pub mod order {
22442244
}
22452245

22462246
/// Return `a` <= `b` lexicographically (Using partial order, `Ord`)
2247-
pub fn le<A: Ord, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
2247+
pub fn le<A: Ord, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
22482248
loop {
22492249
match (a.next(), b.next()) {
22502250
(None, None) => return true,
@@ -2256,7 +2256,7 @@ pub mod order {
22562256
}
22572257

22582258
/// Return `a` > `b` lexicographically (Using partial order, `Ord`)
2259-
pub fn gt<A: Ord, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
2259+
pub fn gt<A: Ord, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
22602260
loop {
22612261
match (a.next(), b.next()) {
22622262
(None, None) => return false,
@@ -2268,7 +2268,7 @@ pub mod order {
22682268
}
22692269

22702270
/// Return `a` >= `b` lexicographically (Using partial order, `Ord`)
2271-
pub fn ge<A: Ord, T: Iterator<A>, S: Iterator<A>>(mut a: T, mut b: S) -> bool {
2271+
pub fn ge<A: Ord, T: Iterator<A>>(mut a: T, mut b: T) -> bool {
22722272
loop {
22732273
match (a.next(), b.next()) {
22742274
(None, None) => return true,
@@ -2325,16 +2325,6 @@ pub mod order {
23252325
assert!(gt(c.iter(), b.iter()) == (c[0] > b[0]));
23262326
assert!(ge(c.iter(), b.iter()) == (c[0] >= b[0]));
23272327
}
2328-
2329-
#[test]
2330-
fn test_multi_iter() {
2331-
use slice::ImmutableVector;
2332-
use iter::DoubleEndedIterator;
2333-
let xs = [1i,2,3,4];
2334-
let ys = [4i,3,2,1];
2335-
assert!(eq(xs.iter(), ys.iter().rev()));
2336-
assert!(lt(xs.iter(), xs.iter().skip(2)));
2337-
}
23382328
}
23392329

23402330
#[cfg(test)]

branches/dist-snap/src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//!
1818
//! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
1919
//! often generated by LLVM. Additionally, this library can make explicit
20-
//! calls to these functions. Their signatures are the same as found in C.
20+
//! calls to these funcitons. Their signatures are the same as found in C.
2121
//! These functions are often provided by the system libc, but can also be
2222
//! provided by `librlibc` which is distributed with the standard rust
2323
//! distribution.

branches/dist-snap/src/libcore/result.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,19 +508,12 @@ impl<T, E> Result<T, E> {
508508
/// Unwraps a result, yielding the content of an `Ok`.
509509
/// If the value is an `Err` then it calls `op` with its value.
510510
#[inline]
511-
pub fn unwrap_or_else(self, op: |E| -> T) -> T {
511+
pub fn unwrap_or_handle(self, op: |E| -> T) -> T {
512512
match self {
513513
Ok(t) => t,
514514
Err(e) => op(e)
515515
}
516516
}
517-
518-
/// Deprecated name for `unwrap_or_else()`.
519-
#[deprecated = "replaced by .unwrap_or_else()"]
520-
#[inline]
521-
pub fn unwrap_or_handle(self, op: |E| -> T) -> T {
522-
self.unwrap_or_else(op)
523-
}
524517
}
525518

526519
impl<T, E: Show> Result<T, E> {
@@ -765,8 +758,8 @@ mod tests {
765758
let ok: Result<int, ~str> = Ok(100);
766759
let ok_err: Result<int, ~str> = Err("I got this.".to_owned());
767760

768-
assert_eq!(ok.unwrap_or_else(handler), 100);
769-
assert_eq!(ok_err.unwrap_or_else(handler), 50);
761+
assert_eq!(ok.unwrap_or_handle(handler), 100);
762+
assert_eq!(ok_err.unwrap_or_handle(handler), 50);
770763
}
771764

772765
#[test]
@@ -781,6 +774,6 @@ mod tests {
781774
}
782775

783776
let bad_err: Result<int, ~str> = Err("Unrecoverable mess.".to_owned());
784-
let _ : int = bad_err.unwrap_or_else(handler);
777+
let _ : int = bad_err.unwrap_or_handle(handler);
785778
}
786779
}

branches/dist-snap/src/librustc/middle/resolve.rs

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4891,25 +4891,6 @@ impl<'a> Resolver<'a> {
48914891
}
48924892

48934893
fn find_fallback_in_self_type(&mut self, name: Name) -> FallbackSuggestion {
4894-
#[deriving(Eq)]
4895-
enum FallbackChecks {
4896-
Everything,
4897-
OnlyTraitAndStatics
4898-
}
4899-
4900-
fn extract_path_and_node_id(t: &Ty, allow: FallbackChecks)
4901-
-> Option<(Path, NodeId, FallbackChecks)> {
4902-
match t.node {
4903-
TyPath(ref path, _, node_id) => Some((path.clone(), node_id, allow)),
4904-
TyPtr(mut_ty) => extract_path_and_node_id(mut_ty.ty, OnlyTraitAndStatics),
4905-
TyRptr(_, mut_ty) => extract_path_and_node_id(mut_ty.ty, allow),
4906-
// This doesn't handle the remaining `Ty` variants as they are not
4907-
// that commonly the self_type, it might be interesting to provide
4908-
// support for those in future.
4909-
_ => None,
4910-
}
4911-
}
4912-
49134894
fn get_module(this: &mut Resolver, span: Span, ident_path: &[ast::Ident])
49144895
-> Option<Rc<Module>> {
49154896
let root = this.current_module.clone();
@@ -4937,29 +4918,27 @@ impl<'a> Resolver<'a> {
49374918
}
49384919
}
49394920

4940-
let (path, node_id, allowed) = match self.current_self_type {
4941-
Some(ref ty) => match extract_path_and_node_id(ty, Everything) {
4942-
Some(x) => x,
4943-
None => return NoSuggestion,
4921+
let (path, node_id) = match self.current_self_type {
4922+
Some(ref ty) => match ty.node {
4923+
TyPath(ref path, _, node_id) => (path.clone(), node_id),
4924+
_ => unreachable!(),
49444925
},
49454926
None => return NoSuggestion,
49464927
};
49474928

4948-
if allowed == Everything {
4949-
// Look for a field with the same name in the current self_type.
4950-
match self.def_map.borrow().find(&node_id) {
4951-
Some(&DefTy(did))
4952-
| Some(&DefStruct(did))
4953-
| Some(&DefVariant(_, did, _)) => match self.structs.find(&did) {
4954-
None => {}
4955-
Some(fields) => {
4956-
if fields.iter().any(|&field_name| name == field_name) {
4957-
return Field;
4958-
}
4929+
// Look for a field with the same name in the current self_type.
4930+
match self.def_map.borrow().find(&node_id) {
4931+
Some(&DefTy(did))
4932+
| Some(&DefStruct(did))
4933+
| Some(&DefVariant(_, did, _)) => match self.structs.find(&did) {
4934+
None => {}
4935+
Some(fields) => {
4936+
if fields.iter().any(|&field_name| name == field_name) {
4937+
return Field;
49594938
}
4960-
},
4961-
_ => {} // Self type didn't resolve properly
4962-
}
4939+
}
4940+
},
4941+
_ => {} // Self type didn't resolve properly
49634942
}
49644943

49654944
let ident_path = path.segments.iter().map(|seg| seg.identifier).collect::<Vec<_>>();
@@ -4976,8 +4955,8 @@ impl<'a> Resolver<'a> {
49764955
FromTrait(_) => unreachable!()
49774956
}
49784957
}
4979-
Some(DefMethod(_, None)) if allowed == Everything => return Method,
4980-
Some(DefMethod(_, Some(_))) => return TraitMethod,
4958+
Some(DefMethod(_, None)) => return Method,
4959+
Some(DefMethod(_, _)) => return TraitMethod,
49814960
_ => ()
49824961
}
49834962
}

branches/dist-snap/src/libsyntax/diagnostic.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,27 @@ fn print_maybe_styled(w: &mut EmitterWriter,
232232
match w.dst {
233233
Terminal(ref mut t) => {
234234
try!(t.attr(color));
235-
try!(t.write_str(msg));
236-
try!(t.reset());
235+
// If `msg` ends in a newline, we need to reset the color before
236+
// the newline. We're making the assumption that we end up writing
237+
// to a `LineBufferedWriter`, which means that emitting the reset
238+
// after the newline ends up buffering the reset until we print
239+
// another line or exit. Buffering the reset is a problem if we're
240+
// sharing the terminal with any other programs (e.g. other rustc
241+
// instances via `make -jN`).
242+
//
243+
// Note that if `msg` contains any internal newlines, this will
244+
// result in the `LineBufferedWriter` flushing twice instead of
245+
// once, which still leaves the opportunity for interleaved output
246+
// to be miscolored. We assume this is rare enough that we don't
247+
// have to worry about it.
248+
if msg.ends_with("\n") {
249+
try!(t.write_str(msg.slice_to(msg.len()-1)));
250+
try!(t.reset());
251+
try!(t.write_str("\n"));
252+
} else {
253+
try!(t.write_str(msg));
254+
try!(t.reset());
255+
}
237256
Ok(())
238257
}
239258
Raw(ref mut w) => {

0 commit comments

Comments
 (0)