Skip to content

Commit c0218fb

Browse files
committed
auto merge of #5069 : pcwalton/rust/plussing-2, r=pcwalton
2 parents 41a4151 + c0defda commit c0218fb

File tree

10 files changed

+52
-53
lines changed

10 files changed

+52
-53
lines changed

doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,12 +2072,12 @@ on values of type `T` inside the function. It will also cause a
20722072
compile-time error when anyone tries to call `print_all` on an array
20732073
whose element type does not have a `Printable` implementation.
20742074

2075-
Type parameters can have multiple bounds by separating them with spaces,
2075+
Type parameters can have multiple bounds by separating them with `+`,
20762076
as in this version of `print_all` that copies elements.
20772077

20782078
~~~
20792079
# trait Printable { fn print(&self); }
2080-
fn print_all<T: Printable Copy>(printable_things: ~[T]) {
2080+
fn print_all<T: Printable + Copy>(printable_things: ~[T]) {
20812081
let mut i = 0;
20822082
while i < printable_things.len() {
20832083
let copy_of_thing = printable_things[i];

src/libcore/pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,8 @@ pub trait Select2<T:Owned,U:Owned> {
12031203
12041204
impl<T: Owned,
12051205
U: Owned,
1206-
Left: Selectable GenericPort<T>,
1207-
Right: Selectable GenericPort<U>>
1206+
Left: Selectable + GenericPort<T>,
1207+
Right: Selectable + GenericPort<U>>
12081208
Select2<T,U> for (Left, Right) {
12091209
fn select() -> Either<T, U> {
12101210
match self {

src/librustc/middle/typeck/infer/lattice.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub impl LatticeValue for ty::t {
7272
}
7373

7474
pub impl CombineFields {
75-
fn var_sub_var<T:Copy InferStr LatticeValue,
76-
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
75+
fn var_sub_var<T:Copy + InferStr + LatticeValue,
76+
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
7777
&self,
7878
+a_id: V,
7979
+b_id: V) -> ures
@@ -125,8 +125,8 @@ pub impl CombineFields {
125125
}
126126

127127
/// make variable a subtype of T
128-
fn var_sub_t<T:Copy InferStr LatticeValue,
129-
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
128+
fn var_sub_t<T:Copy + InferStr + LatticeValue,
129+
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
130130
&self,
131131
+a_id: V,
132132
+b: T) -> ures
@@ -149,8 +149,8 @@ pub impl CombineFields {
149149
a_id, a_bounds, b_bounds, node_a.rank)
150150
}
151151

152-
fn t_sub_var<T:Copy InferStr LatticeValue,
153-
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
152+
fn t_sub_var<T:Copy + InferStr + LatticeValue,
153+
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
154154
&self,
155155
+a: T,
156156
+b_id: V) -> ures
@@ -201,8 +201,8 @@ pub impl CombineFields {
201201
}
202202
}
203203

204-
fn set_var_to_merged_bounds<T:Copy InferStr LatticeValue,
205-
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
204+
fn set_var_to_merged_bounds<T:Copy + InferStr + LatticeValue,
205+
V:Copy+Eq+ToStr+Vid+UnifyVid<Bounds<T>>>(
206206
&self,
207207
+v_id: V,
208208
a: &Bounds<T>,
@@ -395,9 +395,9 @@ pub enum LatticeVarResult<V,T> {
395395
* the variables and return the unified variable, in which case the
396396
* result is a variable. This is indicated with a `VarResult`
397397
* return. */
398-
pub fn lattice_vars<L:LatticeDir Combine,
399-
T:Copy InferStr LatticeValue,
400-
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
398+
pub fn lattice_vars<L:LatticeDir + Combine,
399+
T:Copy + InferStr + LatticeValue,
400+
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
401401
self: &L, // defines whether we want LUB or GLB
402402
+a_vid: V, // first variable
403403
+b_vid: V, // second variable
@@ -441,9 +441,9 @@ pub fn lattice_vars<L:LatticeDir Combine,
441441
}
442442
}
443443

444-
pub fn lattice_var_and_t<L:LatticeDir Combine,
445-
T:Copy InferStr LatticeValue,
446-
V:Copy Eq ToStr Vid UnifyVid<Bounds<T>>>(
444+
pub fn lattice_var_and_t<L:LatticeDir + Combine,
445+
T:Copy + InferStr + LatticeValue,
446+
V:Copy + Eq + ToStr + Vid + UnifyVid<Bounds<T>>>(
447447
self: &L,
448448
+a_id: V,
449449
b: &T,

src/librustc/middle/typeck/infer/unify.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ pub fn mk_err<T:SimplyUnifiable>(+a_is_expected: bool,
163163
}
164164

165165
pub impl InferCtxt {
166-
fn simple_vars<T:Copy Eq InferStr SimplyUnifiable,
167-
V:Copy Eq Vid ToStr UnifyVid<Option<T>>>(
166+
fn simple_vars<T:Copy + Eq + InferStr + SimplyUnifiable,
167+
V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
168168
&mut self,
169169
+a_is_expected: bool,
170170
+a_id: V,
@@ -201,8 +201,8 @@ pub impl InferCtxt {
201201
return uok();
202202
}
203203

204-
fn simple_var_t<T:Copy Eq InferStr SimplyUnifiable,
205-
V:Copy Eq Vid ToStr UnifyVid<Option<T>>>(
204+
fn simple_var_t<T:Copy + Eq + InferStr + SimplyUnifiable,
205+
V:Copy + Eq + Vid + ToStr + UnifyVid<Option<T>>>(
206206
&mut self,
207207
+a_is_expected: bool,
208208
+a_id: V,

src/libstd/flatpipes.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub mod serial {
151151
}
152152

153153
/// Create a pair of `FlatChan` and `FlatPort`, backed by pipes
154-
pub fn pipe_stream<T: Encodable<DefaultEncoder>
154+
pub fn pipe_stream<T: Encodable<DefaultEncoder> +
155155
Decodable<DefaultDecoder>>(
156156
) -> (PipePort<T>, PipeChan<T>) {
157157
let (port, chan) = pipes::stream();
@@ -443,17 +443,17 @@ pub mod flatteners {
443443
SerializingFlattener
444444
*/
445445
446-
pub fn deserialize_buffer<D: Decoder FromReader,
447-
T: Decodable<D>>(buf: &[u8]) -> T {
446+
pub fn deserialize_buffer<D: Decoder + FromReader,
447+
T: Decodable<D>>(buf: &[u8]) -> T {
448448
let buf = vec::from_slice(buf);
449449
let buf_reader = @BufReader::new(buf);
450450
let reader = buf_reader as @Reader;
451451
let deser: D = FromReader::from_reader(reader);
452452
Decodable::decode(&deser)
453453
}
454454
455-
pub fn serialize_value<D: Encoder FromWriter,
456-
T: Encodable<D>>(val: &T) -> ~[u8] {
455+
pub fn serialize_value<D: Encoder + FromWriter,
456+
T: Encodable<D>>(val: &T) -> ~[u8] {
457457
let bytes_writer = @BytesWriter();
458458
let writer = bytes_writer as @Writer;
459459
let ser = FromWriter::from_writer(writer);

src/libstd/workcache.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ impl Context {
260260
Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()}
261261
}
262262
263-
fn prep<T:Owned
264-
Encodable<json::Encoder>
265-
Decodable<json::Decoder>>(
263+
fn prep<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
266264
@self,
267265
fn_name:&str,
268266
blk: fn(@Mut<Prep>)->Work<T>) -> Work<T> {
@@ -278,9 +276,8 @@ trait TPrep {
278276
fn declare_input(&self, kind:&str, name:&str, val:&str);
279277
fn is_fresh(&self, cat:&str, kind:&str, name:&str, val:&str) -> bool;
280278
fn all_fresh(&self, cat:&str, map:&WorkMap) -> bool;
281-
fn exec<T:Owned
282-
Encodable<json::Encoder>
283-
Decodable<json::Decoder>>(&self, blk: ~fn(&Exec) -> T) -> Work<T>;
279+
fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
280+
&self, blk: ~fn(&Exec) -> T) -> Work<T>;
284281
}
285282
286283
impl TPrep for @Mut<Prep> {
@@ -318,11 +315,8 @@ impl TPrep for @Mut<Prep> {
318315
return true;
319316
}
320317

321-
fn exec<T:Owned
322-
Encodable<json::Encoder>
323-
Decodable<json::Decoder>>(&self,
324-
blk: ~fn(&Exec) -> T) -> Work<T> {
325-
318+
fn exec<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
319+
&self, blk: ~fn(&Exec) -> T) -> Work<T> {
326320
let mut bo = Some(blk);
327321

328322
do self.borrow_imm |p| {
@@ -360,20 +354,15 @@ impl TPrep for @Mut<Prep> {
360354
}
361355
}
362356

363-
impl<T:Owned
364-
Encodable<json::Encoder>
365-
Decodable<json::Decoder>>
366-
Work<T> {
357+
impl<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>> Work<T> {
367358
static fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
368359
Work { prep: p, res: Some(e) }
369360
}
370361
}
371362

372363
// FIXME (#3724): movable self. This should be in impl Work.
373-
fn unwrap<T:Owned
374-
Encodable<json::Encoder>
375-
Decodable<json::Decoder>>(w: Work<T>) -> T {
376-
364+
fn unwrap<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
365+
w: Work<T>) -> T {
377366
let mut ww = w;
378367
let mut s = None;
379368

@@ -383,7 +372,6 @@ fn unwrap<T:Owned
383372
None => fail!(),
384373
Some(Left(v)) => v,
385374
Some(Right(port)) => {
386-
387375
let (exe, v) = match recv(port) {
388376
oneshot::send(data) => data
389377
};

src/libsyntax/parse/obsolete.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ pub enum ObsoleteSyntax {
4646
ObsoleteBinaryMove,
4747
ObsoleteUnsafeBlock,
4848
ObsoleteUnenforcedBound,
49-
ObsoleteImplSyntax
49+
ObsoleteImplSyntax,
50+
ObsoleteTraitBoundSeparator,
5051
}
5152

5253
pub impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -120,7 +121,11 @@ pub impl Parser {
120121
ObsoleteImplSyntax => (
121122
"colon-separated impl syntax",
122123
"write `impl Trait for Type`"
123-
)
124+
),
125+
ObsoleteTraitBoundSeparator => (
126+
"space-separated trait bounds",
127+
"write `+` between trait bounds"
128+
),
124129
};
125130

126131
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove};
7575
use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith};
7676
use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
7777
use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
78+
use parse::obsolete::{ObsoleteTraitBoundSeparator};
7879
use parse::prec::{as_prec, token_to_binop};
7980
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
8081
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
@@ -2676,7 +2677,12 @@ pub impl Parser {
26762677
}
26772678

26782679
if self.eat(token::BINOP(token::PLUS)) {
2679-
// Should be `break;` but that isn't backwards compatible.
2680+
loop;
2681+
}
2682+
2683+
if is_ident_or_path(self.token) {
2684+
self.obsolete(copy self.span,
2685+
ObsoleteTraitBoundSeparator);
26802686
}
26812687
}
26822688
}

src/test/run-pass/auto-encode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ fn test_prettyprint<A:Encodable<prettyprint::Serializer>>(
3838
}
3939

4040
fn test_ebml<A:
41-
Eq
42-
Encodable<EBWriter::Encoder>
41+
Eq +
42+
Encodable<EBWriter::Encoder> +
4343
Decodable<EBReader::Decoder>
4444
>(a1: &A) {
4545
let bytes = do io::with_bytes_writer |wr| {

src/test/run-pass/issue-2904.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn square_from_char(c: char) -> square {
5959
}
6060
}
6161

62-
fn read_board_grid<rdr: &static io::Reader>(+in: rdr) -> ~[~[square]] {
62+
fn read_board_grid<rdr: &static + io::Reader>(+in: rdr) -> ~[~[square]] {
6363
let in = (in) as io::Reader;
6464
let mut grid = ~[];
6565
for in.each_line |line| {

0 commit comments

Comments
 (0)