summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-06 16:54:57 +0100
committerGitHub <noreply@github.com>2022-12-06 16:54:57 +0100
commit97008a23fc20f66e3dc5b292ad79d97198788ac3 (patch)
tree4104ff9b2bb0ef76af0997aff8cf4c587c9708e2
parent4f527a55dea64aeb420357154884b6ca6d350986 (diff)
parent12ce0c2a891d872c8fb32eb17b6258ea99a971ad (diff)
downloadrust-97008a23fc20f66e3dc5b292ad79d97198788ac3.tar.gz
Rollup merge of #105370 - WaffleLapkin:pp, r=oli-obk
Remove outdated syntax from trait alias pretty printing Given the following program: ```rust #![feature(trait_alias)] trait A = ?Sized; fn main() {} ``` Old output of `rustc +nightly ./t.rs -Zunpretty=normal`: ```rust #![feature(trait_alias)] trait A for ? Sized ; fn main() {} ``` New output of `rustc +a ./t.rs -Zunpretty=normal`: ```rust #![feature(trait_alias)] trait A = ?Sized; fn main() {} ``` cc `@durka` (you've written the `FIXME` in #45047, see https://github.com/rust-lang/rust/pull/45047#discussion_r144960751)
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/item.rs15
-rw-r--r--compiler/rustc_hir_pretty/src/lib.rs13
2 files changed, 3 insertions, 25 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
index e68a7b3f202..5b6a07721e2 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
@@ -348,21 +348,10 @@ impl<'a> State<'a> {
self.head(visibility_qualified(&item.vis, "trait"));
self.print_ident(item.ident);
self.print_generic_params(&generics.params);
- let mut real_bounds = Vec::with_capacity(bounds.len());
- // FIXME(durka) this seems to be some quite outdated syntax
- for b in bounds.iter() {
- if let GenericBound::Trait(ptr, ast::TraitBoundModifier::Maybe) = b {
- self.space();
- self.word_space("for ?");
- self.print_trait_ref(&ptr.trait_ref);
- } else {
- real_bounds.push(b.clone());
- }
- }
self.nbsp();
- if !real_bounds.is_empty() {
+ if !bounds.is_empty() {
self.word_nbsp("=");
- self.print_type_bounds(&real_bounds);
+ self.print_type_bounds(&bounds);
}
self.print_where_clause(&generics.where_clause);
self.word(";");
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs
index 3791b2c8661..94bab9f339d 100644
--- a/compiler/rustc_hir_pretty/src/lib.rs
+++ b/compiler/rustc_hir_pretty/src/lib.rs
@@ -695,19 +695,8 @@ impl<'a> State<'a> {
self.head("trait");
self.print_ident(item.ident);
self.print_generic_params(generics.params);
- let mut real_bounds = Vec::with_capacity(bounds.len());
- // FIXME(durka) this seems to be some quite outdated syntax
- for b in bounds {
- if let GenericBound::Trait(ptr, hir::TraitBoundModifier::Maybe) = b {
- self.space();
- self.word_space("for ?");
- self.print_trait_ref(&ptr.trait_ref);
- } else {
- real_bounds.push(b);
- }
- }
self.nbsp();
- self.print_bounds("=", real_bounds);
+ self.print_bounds("=", bounds);
self.print_where_clause(generics);
self.word(";");
self.end(); // end inner head-block