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(printable_things: ~[T]) { +fn print_all(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 b3e32fc6b6c..29a947e5890 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -1213,8 +1213,8 @@ pub trait Select2 { impl, - Right: Selectable GenericPort> + Left: Selectable + GenericPort, + Right: Selectable + GenericPort> Select2 for (Left, Right) { fn select() -> Either { 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>>( + fn var_sub_var>>( &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>>( + fn var_sub_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>>( + fn t_sub_var>>( &self, +a: T, +b_id: V) -> ures @@ -201,8 +201,8 @@ pub impl CombineFields { } } - fn set_var_to_merged_bounds>>( + fn set_var_to_merged_bounds>>( &self, +v_id: V, a: &Bounds, @@ -395,9 +395,9 @@ pub enum LatticeVarResult { * 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>>( +pub fn lattice_vars>>( 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>>( +pub fn lattice_var_and_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(+a_is_expected: bool, } pub impl InferCtxt { - fn simple_vars>>( + fn simple_vars>>( &mut self, +a_is_expected: bool, +a_id: V, @@ -201,8 +201,8 @@ pub impl InferCtxt { return uok(); } - fn simple_var_t>>( + fn simple_var_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 + pub fn pipe_stream + Decodable>( ) -> (PipePort, PipeChan) { let (port, chan) = pipes::stream(); @@ -443,8 +443,8 @@ pub mod flatteners { SerializingFlattener */ - pub fn deserialize_buffer>(buf: &[u8]) -> T { + pub fn deserialize_buffer>(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>(val: &T) -> ~[u8] { + pub fn serialize_value>(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 - Decodable>( + fn prep + Decodable>( @self, fn_name:&str, blk: fn(@Mut)->Work) -> Work { @@ -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 - Decodable>(&self, blk: ~fn(&Exec) -> T) -> Work; + fn exec + Decodable>( + &self, blk: ~fn(&Exec) -> T) -> Work; } impl TPrep for @Mut { @@ -318,11 +315,8 @@ impl TPrep for @Mut { return true; } - fn exec - Decodable>(&self, - blk: ~fn(&Exec) -> T) -> Work { - + fn exec + Decodable>( + &self, blk: ~fn(&Exec) -> T) -> Work { let mut bo = Some(blk); do self.borrow_imm |p| { @@ -360,20 +354,15 @@ impl TPrep for @Mut { } } -impl - Decodable> - Work { +impl + Decodable> Work { static fn new(p: @Mut, e: Either>) -> Work { Work { prep: p, res: Some(e) } } } // FIXME (#3724): movable self. This should be in impl Work. -fn unwrap - Decodable>(w: Work) -> T { - +fn unwrap + Decodable>( + w: Work) -> T { let mut ww = w; let mut s = None; @@ -383,7 +372,6 @@ fn unwrap 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>( } fn test_ebml + Eq + + Encodable + Decodable >(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(+in: rdr) -> ~[~[square]] { +fn read_board_grid(+in: rdr) -> ~[~[square]] { let in = (in) as io::Reader; let mut grid = ~[]; for in.each_line |line| {