Skip to content

Commit 823ebb1

Browse files
committed
pp: also print bounds in paths with no generic params
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.
1 parent aa406c1 commit 823ebb1

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

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)