Skip to content

Commit

Permalink
Rollup merge of rust-lang#105370 - WaffleLapkin:pp, r=oli-obk
Browse files Browse the repository at this point in the history
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 rust-lang#45047, see rust-lang#45047 (comment))
  • Loading branch information
matthiaskrgr authored Dec 6, 2022
2 parents 4f527a5 + 12ce0c2 commit 97008a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
15 changes: 2 additions & 13 deletions compiler/rustc_ast_pretty/src/pprust/state/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(";");
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 97008a2

Please sign in to comment.