Skip to content

Commit 97008a2

Browse files
authored
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 #45047 (comment))
2 parents 4f527a5 + 12ce0c2 commit 97008a2

File tree

2 files changed

+3
-25
lines changed
  • compiler
    • rustc_ast_pretty/src/pprust/state
    • rustc_hir_pretty/src

2 files changed

+3
-25
lines changed

compiler/rustc_ast_pretty/src/pprust/state/item.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -348,21 +348,10 @@ impl<'a> State<'a> {
348348
self.head(visibility_qualified(&item.vis, "trait"));
349349
self.print_ident(item.ident);
350350
self.print_generic_params(&generics.params);
351-
let mut real_bounds = Vec::with_capacity(bounds.len());
352-
// FIXME(durka) this seems to be some quite outdated syntax
353-
for b in bounds.iter() {
354-
if let GenericBound::Trait(ptr, ast::TraitBoundModifier::Maybe) = b {
355-
self.space();
356-
self.word_space("for ?");
357-
self.print_trait_ref(&ptr.trait_ref);
358-
} else {
359-
real_bounds.push(b.clone());
360-
}
361-
}
362351
self.nbsp();
363-
if !real_bounds.is_empty() {
352+
if !bounds.is_empty() {
364353
self.word_nbsp("=");
365-
self.print_type_bounds(&real_bounds);
354+
self.print_type_bounds(&bounds);
366355
}
367356
self.print_where_clause(&generics.where_clause);
368357
self.word(";");

compiler/rustc_hir_pretty/src/lib.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -695,19 +695,8 @@ impl<'a> State<'a> {
695695
self.head("trait");
696696
self.print_ident(item.ident);
697697
self.print_generic_params(generics.params);
698-
let mut real_bounds = Vec::with_capacity(bounds.len());
699-
// FIXME(durka) this seems to be some quite outdated syntax
700-
for b in bounds {
701-
if let GenericBound::Trait(ptr, hir::TraitBoundModifier::Maybe) = b {
702-
self.space();
703-
self.word_space("for ?");
704-
self.print_trait_ref(&ptr.trait_ref);
705-
} else {
706-
real_bounds.push(b);
707-
}
708-
}
709698
self.nbsp();
710-
self.print_bounds("=", real_bounds);
699+
self.print_bounds("=", bounds);
711700
self.print_where_clause(generics);
712701
self.word(";");
713702
self.end(); // end inner head-block

0 commit comments

Comments
 (0)