From 823ebb14ba6ed99df1198c6d1b47c5d2964196da Mon Sep 17 00:00:00 2001 From: Benjamin Herr Date: Tue, 17 Sep 2013 22:13:47 +0200 Subject: [PATCH] pp: also print bounds in paths with no generic params Since 3b6314c3 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. --- src/libsyntax/print/pprust.rs | 14 +++++++------- src/test/pretty/path-type-bounds.rs | 13 +++++++++++++ ...ssue-7673-cast-generically-implemented-trait.rs | 2 -- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 src/test/pretty/path-type-bounds.rs diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ec84cbda9736..b5868cbc63db 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1535,15 +1535,15 @@ fn print_path_(s: @ps, print_ident(s, segment.identifier); - if segment.lifetime.is_some() || !segment.types.is_empty() { - // If this is the last segment, print the bounds. - if i == path.segments.len() - 1 { - match *opt_bounds { - None => {} - Some(ref bounds) => print_bounds(s, bounds, true), - } + // If this is the last segment, print the bounds. + if i == path.segments.len() - 1 { + match *opt_bounds { + None => {} + Some(ref bounds) => print_bounds(s, bounds, true), } + } + if segment.lifetime.is_some() || !segment.types.is_empty() { if colons_before_params { word(s.s, "::") } diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs new file mode 100644 index 000000000000..a62fbdeeb185 --- /dev/null +++ b/src/test/pretty/path-type-bounds.rs @@ -0,0 +1,13 @@ +// pp-exact + +trait Tr { } +impl Tr for int; + +fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x } + +fn main() { + let x: ~Tr: Freeze; + + ~1 as ~Tr: Freeze; +} + diff --git a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs index 1492b5895bae..2f2b736294a5 100644 --- a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-pretty #9253 pretty printer doesn't preserve the bounds on trait objects - /* #7673 Polymorphically creating traits barely works