Skip to content

Commit 778aec9

Browse files
committed
libsyntax: Implement the + syntax for multiple trait bounds. r=tjc
1 parent 1871f3a commit 778aec9

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,6 +2531,10 @@ impl Parser {
25312531
} else {
25322532
break;
25332533
}
2534+
2535+
if self.eat(token::BINOP(token::PLUS)) {
2536+
// Should be `break;` but that isn't backwards compatible.
2537+
}
25342538
}
25352539
}
25362540
return @move bounds;

src/libsyntax/print/pprust.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,8 +1791,15 @@ fn print_arg_mode(s: ps, m: ast::mode) {
17911791
fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) {
17921792
if bounds.is_not_empty() {
17931793
word(s.s, ~":");
1794+
let mut first = true;
17941795
for vec::each(*bounds) |&bound| {
17951796
nbsp(s);
1797+
if first {
1798+
first = false;
1799+
} else {
1800+
word_space(s, ~"+");
1801+
}
1802+
17961803
match bound {
17971804
TraitTyParamBound(ty) => print_type(s, ty),
17981805
RegionTyParamBound => word(s.s, ~"&static"),
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn f<T:Eq + Ord>(_: T) {
2+
}
3+
4+
fn main() {
5+
f(3);
6+
}
7+

0 commit comments

Comments
 (0)