Skip to content

Commit 267b608

Browse files
committed
---
yaml --- r: 152928 b: refs/heads/try2 c: 05e3248 h: refs/heads/master v: v3
1 parent ad11e84 commit 267b608

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+378
-383
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: b47f2226a25654c5b781d27a91f2fa5274b3a347
8+
refs/heads/try2: 05e3248a7974f55b64f75a2483b37ff8c001a4ff
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/guide-macros.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ macro_rules! biased_match_rec (
355355
_ => { $err }
356356
}
357357
);
358-
// Produce the requested values
359358
( binds $( $bind_res:ident ),* ) => ( ($( $bind_res ),*) )
360359
)
361360
@@ -365,7 +364,7 @@ macro_rules! biased_match (
365364
( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
366365
binds $bind_res:ident
367366
) => (
368-
let $bind_res = biased_match_rec!(
367+
let ( $( $bind_res ),* ) = biased_match_rec!(
369368
$( ($e) ~ ($p) else $err ; )*
370369
binds $bind_res
371370
);

branches/try2/src/liballoc/owned.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
1616
use core::default::Default;
1717
use core::fmt;
1818
use core::intrinsics;
19+
use core::kinds::Send;
1920
use core::mem;
2021
use core::raw::TraitObject;
2122
use core::result::{Ok, Err, Result};
@@ -106,6 +107,34 @@ impl AnyOwnExt for Box<Any> {
106107
}
107108
}
108109

110+
/// Extension methods for an owning `Any+Send` trait object
111+
pub trait AnySendOwnExt {
112+
/// Returns the boxed value if it is of type `T`, or
113+
/// `Err(Self)` if it isn't.
114+
fn move_send<T: 'static>(self) -> Result<Box<T>, Self>;
115+
}
116+
117+
impl AnySendOwnExt for Box<Any+Send> {
118+
#[inline]
119+
fn move_send<T: 'static>(self) -> Result<Box<T>, Box<Any+Send>> {
120+
if self.is::<T>() {
121+
unsafe {
122+
// Get the raw representation of the trait object
123+
let to: TraitObject =
124+
*mem::transmute::<&Box<Any+Send>, &TraitObject>(&self);
125+
126+
// Prevent destructor on self being run
127+
intrinsics::forget(self);
128+
129+
// Extract the data pointer
130+
Ok(mem::transmute(to.data))
131+
}
132+
} else {
133+
Err(self)
134+
}
135+
}
136+
}
137+
109138
impl<T: fmt::Show> fmt::Show for Box<T> {
110139
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
111140
(**self).fmt(f)

branches/try2/src/libcollections/vec.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -956,17 +956,14 @@ impl<T> Vec<T> {
956956
///
957957
/// # Failure
958958
///
959-
/// Fails if `index` is not between `0` and the vector's length (both
960-
/// bounds inclusive).
959+
/// Fails if `index` is out of bounds of the vector.
961960
///
962961
/// # Example
963962
///
964963
/// ```rust
965964
/// let mut vec = vec!(1i, 2, 3);
966965
/// vec.insert(1, 4);
967966
/// assert_eq!(vec, vec!(1, 4, 2, 3));
968-
/// vec.insert(4, 5);
969-
/// assert_eq!(vec, vec!(1, 4, 2, 3, 5));
970967
/// ```
971968
pub fn insert(&mut self, index: uint, element: T) {
972969
let len = self.len();

branches/try2/src/libcore/iter.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ pub trait Iterator<A> {
135135
/// let a = [0i];
136136
/// let b = [1i];
137137
/// let mut it = a.iter().zip(b.iter());
138-
/// assert_eq!(it.next().unwrap(), (&0, &1));
138+
/// let (x0, x1) = (0i, 1i);
139+
/// assert_eq!(it.next().unwrap(), (&x0, &x1));
139140
/// assert!(it.next().is_none());
140141
/// ```
141142
#[inline]
@@ -202,8 +203,9 @@ pub trait Iterator<A> {
202203
/// ```rust
203204
/// let a = [100i, 200];
204205
/// let mut it = a.iter().enumerate();
205-
/// assert_eq!(it.next().unwrap(), (0, &100));
206-
/// assert_eq!(it.next().unwrap(), (1, &200));
206+
/// let (x100, x200) = (100i, 200i);
207+
/// assert_eq!(it.next().unwrap(), (0, &x100));
208+
/// assert_eq!(it.next().unwrap(), (1, &x200));
207209
/// assert!(it.next().is_none());
208210
/// ```
209211
#[inline]
@@ -220,11 +222,11 @@ pub trait Iterator<A> {
220222
/// ```rust
221223
/// let xs = [100i, 200, 300];
222224
/// let mut it = xs.iter().map(|x| *x).peekable();
223-
/// assert_eq!(it.peek().unwrap(), &100);
225+
/// assert_eq!(*it.peek().unwrap(), 100);
224226
/// assert_eq!(it.next().unwrap(), 100);
225227
/// assert_eq!(it.next().unwrap(), 200);
226-
/// assert_eq!(it.peek().unwrap(), &300);
227-
/// assert_eq!(it.peek().unwrap(), &300);
228+
/// assert_eq!(*it.peek().unwrap(), 300);
229+
/// assert_eq!(*it.peek().unwrap(), 300);
228230
/// assert_eq!(it.next().unwrap(), 300);
229231
/// assert!(it.peek().is_none());
230232
/// assert!(it.next().is_none());

branches/try2/src/librustc/middle/typeck/check/vtable.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,15 @@ fn search_for_vtable(vcx: &VtableContext,
352352
// the next impl.
353353
//
354354
// FIXME: document a bit more what this means
355-
//
356-
// FIXME(#5781) this should be mk_eqty not mk_subty
357355
let TypeAndSubsts {
358356
substs: substs,
359357
ty: for_ty
360358
} = impl_self_ty(vcx, span, impl_did);
361-
match infer::mk_subty(vcx.infcx,
362-
false,
363-
infer::RelateSelfType(span),
364-
ty,
365-
for_ty) {
359+
match infer::mk_eqty(vcx.infcx,
360+
false,
361+
infer::RelateSelfType(span),
362+
ty,
363+
for_ty) {
366364
Err(_) => continue,
367365
Ok(()) => ()
368366
}

branches/try2/src/librustc/middle/typeck/infer/combine.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -84,41 +84,25 @@ pub trait Combine {
8484
fn tys(&self, a: ty::t, b: ty::t) -> cres<ty::t>;
8585

8686
fn tps(&self,
87-
space: subst::ParamSpace,
87+
_: subst::ParamSpace,
8888
as_: &[ty::t],
8989
bs: &[ty::t])
90-
-> cres<Vec<ty::t>>
91-
{
92-
// FIXME(#5781) -- In general, we treat variance a bit wrong
93-
// here. For historical reasons, we treat Self as
94-
// contravariant and other tps as invariant. Both are wrong:
95-
// Self may or may not be contravariant, and other tps do not
96-
// need to be invariant.
90+
-> cres<Vec<ty::t>> {
91+
// FIXME -- In general, we treat variance a bit wrong
92+
// here. For historical reasons, we treat tps and Self
93+
// as invariant. This is overly conservative.
9794

9895
if as_.len() != bs.len() {
9996
return Err(ty::terr_ty_param_size(expected_found(self,
10097
as_.len(),
10198
bs.len())));
10299
}
103100

104-
match space {
105-
subst::SelfSpace => {
106-
result::fold(as_
107-
.iter()
108-
.zip(bs.iter())
109-
.map(|(a, b)| self.contratys(*a, *b)),
110-
Vec::new(),
111-
|mut v, a| { v.push(a); v })
112-
}
113-
114-
subst::TypeSpace | subst::FnSpace => {
115-
try!(result::fold_(as_
116-
.iter()
117-
.zip(bs.iter())
118-
.map(|(a, b)| eq_tys(self, *a, *b))));
119-
Ok(Vec::from_slice(as_))
120-
}
121-
}
101+
try!(result::fold_(as_
102+
.iter()
103+
.zip(bs.iter())
104+
.map(|(a, b)| eq_tys(self, *a, *b))));
105+
Ok(Vec::from_slice(as_))
122106
}
123107

124108
fn substs(&self,

branches/try2/src/librustc/middle/typeck/variance.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ receiver position from being called via an object.)
7878
#### Trait variance and vtable resolution
7979
8080
But traits aren't only used with objects. They're also used when
81-
deciding whether a given impl satisfies a given trait bound (or should
82-
be -- FIXME #5781). To set the scene here, imagine I had a function:
81+
deciding whether a given impl satisfies a given trait bound. To set the
82+
scene here, imagine I had a function:
8383
8484
fn convertAll<A,T:ConvertTo<A>>(v: &[T]) {
8585
...

branches/try2/src/librustdoc/test.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,14 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool,
140140
let old = io::stdio::set_stderr(box w1);
141141
spawn(proc() {
142142
let mut p = io::ChanReader::new(rx);
143-
let mut err = old.unwrap_or(box io::stderr() as Box<Writer + Send>);
143+
let mut err = match old {
144+
Some(old) => {
145+
// Chop off the `Send` bound.
146+
let old: Box<Writer> = old;
147+
old
148+
}
149+
None => box io::stderr() as Box<Writer>,
150+
};
144151
io::util::copy(&mut p, &mut err).unwrap();
145152
});
146153
let emitter = diagnostic::EmitterWriter::new(box w2);

branches/try2/src/libstd/io/comm_adapters.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ mod test {
183183
writer.write_be_u32(42).unwrap();
184184

185185
let wanted = vec![0u8, 0u8, 0u8, 42u8];
186-
let got = task::try(proc() { rx.recv() }).unwrap();
186+
let got = match task::try(proc() { rx.recv() }) {
187+
Ok(got) => got,
188+
Err(_) => fail!(),
189+
};
187190
assert_eq!(wanted, got);
188191

189192
match writer.write_u8(1) {

branches/try2/src/libstd/task.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,11 @@ mod test {
630630
let mut reader = ChanReader::new(rx);
631631
let stdout = ChanWriter::new(tx);
632632

633-
TaskBuilder::new().stdout(box stdout as Box<Writer + Send>).try(proc() {
634-
print!("Hello, world!");
635-
}).unwrap();
633+
let r = TaskBuilder::new().stdout(box stdout as Box<Writer + Send>)
634+
.try(proc() {
635+
print!("Hello, world!");
636+
});
637+
assert!(r.is_ok());
636638

637639
let output = reader.read_to_str().unwrap();
638640
assert_eq!(output, "Hello, world!".to_string());

branches/try2/src/libsyntax/ast.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ pub enum Decl_ {
401401
DeclItem(Gc<Item>),
402402
}
403403

404-
/// represents one arm of a 'match'
405404
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]
406405
pub struct Arm {
407406
pub attrs: Vec<Attribute>,

branches/try2/src/libsyntax/diagnostic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use std::fmt;
1818
use std::io;
1919
use std::iter::range;
2020
use std::string::String;
21+
use term::WriterWrapper;
2122
use term;
2223

2324
// maximum number of lines we will print for each error; arbitrary.
@@ -281,7 +282,7 @@ pub struct EmitterWriter {
281282
}
282283

283284
enum Destination {
284-
Terminal(Box<term::Terminal<Box<Writer + Send>> + Send>),
285+
Terminal(Box<term::Terminal<WriterWrapper> + Send>),
285286
Raw(Box<Writer + Send>),
286287
}
287288

0 commit comments

Comments
 (0)