diff options
| author | bors <bors@rust-lang.org> | 2013-02-21 08:35:12 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-02-21 08:35:12 -0800 |
| commit | c0218fb10667a198b41e4d140f8d0760e27ca5e7 (patch) | |
| tree | 79b8645af15e6fddbf895be80f8892329b9f62d7 | |
| parent | 41a4151173df5cd93089e40238205c6356835807 (diff) | |
| parent | c0defda4994b2cf292901c24bef88b37a088861e (diff) | |
| download | rust-c0218fb10667a198b41e4d140f8d0760e27ca5e7.tar.gz rust-c0218fb10667a198b41e4d140f8d0760e27ca5e7.zip | |
auto merge of #5069 : pcwalton/rust/plussing-2, r=pcwalton
| -rw-r--r-- | doc/tutorial.md | 4 | ||||
| -rw-r--r-- | src/libcore/pipes.rs | 4 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/infer/lattice.rs | 28 | ||||
| -rw-r--r-- | src/librustc/middle/typeck/infer/unify.rs | 8 | ||||
| -rw-r--r-- | src/libstd/flatpipes.rs | 10 | ||||
| -rw-r--r-- | src/libstd/workcache.rs | 28 | ||||
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 8 | ||||
| -rw-r--r-- | src/test/run-pass/auto-encode.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/issue-2904.rs | 2 |
10 files changed, 52 insertions, 53 deletions
diff --git a/doc/tutorial.md b/doc/tutorial.md index 648aa24a08f..41895ebed7c 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2072,12 +2072,12 @@ on values of type `T` inside the function. It will also cause a compile-time error when anyone tries to call `print_all` on an array whose element type does not have a `Printable` implementation. -Type parameters can have multiple bounds by separating them with spaces, +Type parameters can have multiple bounds by separating them with `+`, as in this version of `print_all` that copies elements. ~~~ # trait Printable { fn print(&self); } -fn print_all<T: Printable Copy>(printable_things: ~[T]) { +fn print_all<T: Printable + Copy>(printable_things: ~[T]) { let mut i = 0; while i < printable_things.len() { let copy_of_thing = printable_things[i]; diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 5728ac5fe78..9d4cadff08a 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -1203,8 +1203,8 @@ pub trait Select2<T:Owned,U:Owned> { impl<T: Owned, U: Owned, - Left: Selectable GenericPort<T>, - Right: Selectable GenericPort<U>> + Left: Selectable + GenericPort<T>, + Right: Selectable + GenericPort<U>> Select2<T,U> for (Left, Right) { fn select() -> Either<T, U> { match self { diff --git a/src/librustc/middle/typeck/infer/lattice.rs b/src/librustc/middle/typeck/infer/lattice.rs index 3998967dc98..c7ee1b871a8 100644 --- a/src/librustc/middle/typeck/infer/lattice.rs +++ b/src/librustc/middle/typeck/infer/lattice.rs @@ -72,8 +72,8 @@ pub impl LatticeValue for ty::t { } pub impl CombineFields { - fn var_sub_var<T:Copy InferStr LatticeValue, - V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>( + fn var_sub_var<T:Copy + InferStr + LatticeValue, + V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>( &self, +a_id: V, +b_id: V) -> ures @@ -125,8 +125,8 @@ pub impl CombineFields { } /// make variable a subtype of T - fn var_sub_t<T:Copy InferStr LatticeValue, - V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>( + fn var_sub_t<T:Copy + InferStr + LatticeValue, + V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>( &self, +a_id: V, +b: T) -> ures @@ -149,8 +149,8 @@ pub impl CombineFields { a_id, a_bounds, b_bounds, node_a.rank) } - fn t_sub_var<T:Copy InferStr LatticeValue, - V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>( + fn t_sub_var<T:Copy + InferStr + LatticeValue, + V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>( &self, +a: T, +b_id: V) -> ures @@ -201,8 +201,8 @@ pub impl CombineFields { } } - fn set_var_to_merged_bounds<T:Copy InferStr LatticeValue, - V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>( + fn set_var_to_merged_bounds<T:Copy + InferStr + LatticeValue, + V:Copy+Eq+ToStr+Vid+UnifyVid<Bounds<T>>>( &self, +v_id: V, a: &Bounds<T>, @@ -395,9 +395,9 @@ pub enum LatticeVarResult<V,T> { * the variables and return the unified variable, in which case the * result is a variable. This is indicated with a `VarResult` * return. */ -pub fn lattice_vars<L:LatticeDir Combine, - T:Copy InferStr LatticeValue, - V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>( +pub fn lattice_vars<L:LatticeDir + Combine, + T:Copy + InferStr + LatticeValue, + V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>( self: &L, // defines whether we want LUB or GLB +a_vid: V, // first variable +b_vid: V, // second variable @@ -441,9 +441,9 @@ pub fn lattice_vars<L:LatticeDir Combine, } } -pub fn lattice_var_and_t<L:LatticeDir Combine, - T:Copy InferStr LatticeValue, - V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>( +pub fn lattice_var_and_t<L:LatticeDir + Combine, + T:Copy + InferStr + LatticeValue, + V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>( self: &L, +a_id: V, b: &T, diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 6abf2e5709b..4f85718ad1e 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -163,8 +163,8 @@ pub fn mk_err<T:SimplyUnifiable>(+a_is_expected: bool, } pub impl InferCtxt { - fn simple_vars<T:Copy Eq InferStr SimplyUnifiable, - V:Copy Eq Vid ToStr UnifyVid<Option<T>>>( + fn simple_vars<T:Copy + Eq + InferStr + SimplyUnifiable, + V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>( &mut self, +a_is_expected: bool, +a_id: V, @@ -201,8 +201,8 @@ pub impl InferCtxt { return uok(); } - fn simple_var_t<T:Copy Eq InferStr SimplyUnifiable, - V:Copy Eq Vid ToStr UnifyVid<Option<T>>>( + fn simple_var_t<T:Copy + Eq + InferStr + SimplyUnifiable, + V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>( &mut self, +a_is_expected: bool, +a_id: V, diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index f97e5ee6800..80f93323a8e 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -151,7 +151,7 @@ pub mod serial { } /// Create a pair of `FlatChan` and `FlatPort`, backed by pipes - pub fn pipe_stream<T: Encodable<DefaultEncoder> + pub fn pipe_stream<T: Encodable<DefaultEncoder> + Decodable<DefaultDecoder>>( ) -> (PipePort<T>, PipeChan<T>) { let (port, chan) = pipes::stream(); @@ -443,8 +443,8 @@ pub mod flatteners { SerializingFlattener */ - pub fn deserialize_buffer<D: Decoder FromReader, - T: Decodable<D>>(buf: &[u8]) -> T { + pub fn deserialize_buffer<D: Decoder + FromReader, + T: Decodable<D>>(buf: &[u8]) -> T { let buf = vec::from_slice(buf); let buf_reader = @BufReader::new(buf); let reader = buf_reader as @Reader; @@ -452,8 +452,8 @@ pub mod flatteners { Decodable::decode(&deser) } - pub fn serialize_value<D: Encoder FromWriter, - T: Encodable<D>>(val: &T) -> ~[u8] { + pub fn serialize_value<D: Encoder + FromWriter, + T: Encodable<D>>(val: &T) -> ~[u8] { let bytes_writer = @BytesWriter(); let writer = bytes_writer as @Writer; let ser = FromWriter::from_writer(writer); diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 4de7c1b9925..a06dee723c8 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -260,9 +260,7 @@ impl Context { Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()} } - fn prep<T:Owned - Encodable<json::Encoder> - Decodable<json::Decoder>>( + fn prep<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>( @self, fn_name:&str, blk: fn(@Mut<Prep>)->Work<T>) -> Work<T> { @@ -278,9 +276,8 @@ trait TPrep { fn declare_input(&self, kind:&str, name:&str, val:&str); fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool; fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool; - fn exec<T:Owned - Encodable<json::Encoder> - Decodable<json::Decoder>>(&self, blk: ~fn(&Exec) -> T) -> Work<T>; + fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>( + &self, blk: ~fn(&Exec) -> T) -> Work<T>; } impl TPrep for @Mut<Prep> { @@ -318,11 +315,8 @@ impl TPrep for @Mut<Prep> { return true; } - fn exec<T:Owned - Encodable<json::Encoder> - Decodable<json::Decoder>>(&self, - blk: ~fn(&Exec) -> T) -> Work<T> { - + fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>( + &self, blk: ~fn(&Exec) -> T) -> Work<T> { let mut bo = Some(blk); do self.borrow_imm |p| { @@ -360,20 +354,15 @@ impl TPrep for @Mut<Prep> { } } -impl<T:Owned - Encodable<json::Encoder> - Decodable<json::Decoder>> - Work<T> { +impl<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>> Work<T> { static fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> { Work { prep: p, res: Some(e) } } } // FIXME (#3724): movable self. This should be in impl Work. -fn unwrap<T:Owned - Encodable<json::Encoder> - Decodable<json::Decoder>>(w: Work<T>) -> T { - +fn unwrap<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>( + w: Work<T>) -> T { let mut ww = w; let mut s = None; @@ -383,7 +372,6 @@ fn unwrap<T:Owned None => fail!(), Some(Left(v)) => v, Some(Right(port)) => { - let (exe, v) = match recv(port) { oneshot::send(data) => data }; diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index bf04996838c..f5ee5bd8029 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -46,7 +46,8 @@ pub enum ObsoleteSyntax { ObsoleteBinaryMove, ObsoleteUnsafeBlock, ObsoleteUnenforcedBound, - ObsoleteImplSyntax + ObsoleteImplSyntax, + ObsoleteTraitBoundSeparator, } pub impl to_bytes::IterBytes for ObsoleteSyntax { @@ -120,7 +121,11 @@ pub impl Parser { ObsoleteImplSyntax => ( "colon-separated impl syntax", "write `impl Trait for Type`" - ) + ), + ObsoleteTraitBoundSeparator => ( + "space-separated trait bounds", + "write `+` between trait bounds" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 644d6ed5189..85b4eae25d3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -75,6 +75,7 @@ use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove}; use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith}; use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds}; use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax}; +use parse::obsolete::{ObsoleteTraitBoundSeparator}; use parse::prec::{as_prec, token_to_binop}; use parse::token::{can_begin_expr, is_ident, is_ident_or_path}; use parse::token::{is_plain_ident, INTERPOLATED, special_idents}; @@ -2676,7 +2677,12 @@ pub impl Parser { } if self.eat(token::BINOP(token::PLUS)) { - // Should be `break;` but that isn't backwards compatible. + loop; + } + + if is_ident_or_path(self.token) { + self.obsolete(copy self.span, + ObsoleteTraitBoundSeparator); } } } diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 6bf5293913f..e4004c6dc22 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -38,8 +38,8 @@ fn test_prettyprint<A:Encodable<prettyprint::Serializer>>( } fn test_ebml<A: - Eq - Encodable<EBWriter::Encoder> + Eq + + Encodable<EBWriter::Encoder> + Decodable<EBReader::Decoder> >(a1: &A) { let bytes = do io::with_bytes_writer |wr| { diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 9a726bedbc3..9106d39c592 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -59,7 +59,7 @@ fn square_from_char(c: char) -> square { } } -fn read_board_grid<rdr: &static io::Reader>(+in: rdr) -> ~[~[square]] { +fn read_board_grid<rdr: &static + io::Reader>(+in: rdr) -> ~[~[square]] { let in = (in) as io::Reader; let mut grid = ~[]; for in.each_line |line| { |
