Skip to content

Commit b8d3496

Browse files
committed
auto merge of #9264 : ben0x539/rust/pp-work, r=alexcrichton
Since 3b6314c the pretty printer seems to only print trait bounds for `ast::ty_path(...)`s that have a generics arguments list. That seems wrong, so let's always print them. Closes #9253, un-xfails test for #7673.
2 parents adb638f + 823ebb1 commit b8d3496

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

src/libsyntax/print/pp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub fn mk_printer(out: @io::Writer, linewidth: uint) -> @mut Printer {
243243
* the entire buffered window, but can't output anything until the size is >=
244244
* 0 (sizes are set to negative while they're pending calculation).
245245
*
246-
* So SCAN takeks input and buffers tokens and pending calculations, while
246+
* So SCAN takes input and buffers tokens and pending calculations, while
247247
* PRINT gobbles up completed calculations and tokens from the buffer. The
248248
* theory is that the two can never get more than 3N tokens apart, because
249249
* once there's "obviously" too much data to fit on a line, in a size

src/libsyntax/print/pprust.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -1535,15 +1535,15 @@ fn print_path_(s: @ps,
15351535

15361536
print_ident(s, segment.identifier);
15371537

1538-
if segment.lifetime.is_some() || !segment.types.is_empty() {
1539-
// If this is the last segment, print the bounds.
1540-
if i == path.segments.len() - 1 {
1541-
match *opt_bounds {
1542-
None => {}
1543-
Some(ref bounds) => print_bounds(s, bounds, true),
1544-
}
1538+
// If this is the last segment, print the bounds.
1539+
if i == path.segments.len() - 1 {
1540+
match *opt_bounds {
1541+
None => {}
1542+
Some(ref bounds) => print_bounds(s, bounds, true),
15451543
}
1544+
}
15461545

1546+
if segment.lifetime.is_some() || !segment.types.is_empty() {
15471547
if colons_before_params {
15481548
word(s.s, "::")
15491549
}

src/test/pretty/path-type-bounds.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// pp-exact
2+
3+
trait Tr { }
4+
impl Tr for int;
5+
6+
fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x }
7+
8+
fn main() {
9+
let x: ~Tr: Freeze;
10+
11+
~1 as ~Tr: Freeze;
12+
}
13+

src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// xfail-pretty #9253 pretty printer doesn't preserve the bounds on trait objects
12-
1311
/*
1412
1513
#7673 Polymorphically creating traits barely works

0 commit comments

Comments
 (0)