Rid the AST & HIR pretty printers of syntactic cruft
This commit is contained in:
parent
ef1b78eabe
commit
b09889b959
2 changed files with 4 additions and 37 deletions
|
@ -5,7 +5,6 @@ use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
|
||||||
use ast::StaticItem;
|
use ast::StaticItem;
|
||||||
use itertools::{Itertools, Position};
|
use itertools::{Itertools, Position};
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_ast::GenericBound;
|
|
||||||
use rustc_ast::ModKind;
|
use rustc_ast::ModKind;
|
||||||
use rustc_span::symbol::Ident;
|
use rustc_span::symbol::Ident;
|
||||||
|
|
||||||
|
@ -338,21 +337,9 @@ impl<'a> State<'a> {
|
||||||
self.word_nbsp("trait");
|
self.word_nbsp("trait");
|
||||||
self.print_ident(item.ident);
|
self.print_ident(item.ident);
|
||||||
self.print_generic_params(&generics.params);
|
self.print_generic_params(&generics.params);
|
||||||
let mut real_bounds = Vec::with_capacity(bounds.len());
|
if !bounds.is_empty() {
|
||||||
for bound in bounds.iter() {
|
|
||||||
if let GenericBound::Trait(ptr, modifiers) = bound
|
|
||||||
&& let ast::BoundPolarity::Maybe(_) = modifiers.polarity
|
|
||||||
{
|
|
||||||
self.space();
|
|
||||||
self.word_space("for ?");
|
|
||||||
self.print_trait_ref(&ptr.trait_ref);
|
|
||||||
} else {
|
|
||||||
real_bounds.push(bound.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !real_bounds.is_empty() {
|
|
||||||
self.word_nbsp(":");
|
self.word_nbsp(":");
|
||||||
self.print_type_bounds(&real_bounds);
|
self.print_type_bounds(bounds);
|
||||||
}
|
}
|
||||||
self.print_where_clause(&generics.where_clause);
|
self.print_where_clause(&generics.where_clause);
|
||||||
self.word(" ");
|
self.word(" ");
|
||||||
|
|
|
@ -553,17 +553,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
hir::ItemKind::OpaqueTy(opaque_ty) => {
|
hir::ItemKind::OpaqueTy(opaque_ty) => {
|
||||||
self.print_item_type(item, opaque_ty.generics, |state| {
|
self.print_item_type(item, opaque_ty.generics, |state| {
|
||||||
let mut real_bounds = Vec::with_capacity(opaque_ty.bounds.len());
|
state.print_bounds("= impl", opaque_ty.bounds)
|
||||||
for b in opaque_ty.bounds {
|
|
||||||
if let GenericBound::Trait(ptr, hir::TraitBoundModifier::Maybe) = b {
|
|
||||||
state.space();
|
|
||||||
state.word_space("for ?");
|
|
||||||
state.print_trait_ref(&ptr.trait_ref);
|
|
||||||
} else {
|
|
||||||
real_bounds.push(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state.print_bounds("= impl", real_bounds);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
hir::ItemKind::Enum(ref enum_definition, params) => {
|
hir::ItemKind::Enum(ref enum_definition, params) => {
|
||||||
|
@ -625,17 +615,7 @@ impl<'a> State<'a> {
|
||||||
self.word_nbsp("trait");
|
self.word_nbsp("trait");
|
||||||
self.print_ident(item.ident);
|
self.print_ident(item.ident);
|
||||||
self.print_generic_params(generics.params);
|
self.print_generic_params(generics.params);
|
||||||
let mut real_bounds = Vec::with_capacity(bounds.len());
|
self.print_bounds(":", bounds);
|
||||||
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.print_bounds(":", real_bounds);
|
|
||||||
self.print_where_clause(generics);
|
self.print_where_clause(generics);
|
||||||
self.word(" ");
|
self.word(" ");
|
||||||
self.bopen();
|
self.bopen();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue