1
Fork 0

add hir printing

This commit is contained in:
Mikhail Babenko 2020-02-07 18:27:12 +03:00
parent ab6ea2bba7
commit bf82582d6f

View file

@ -454,14 +454,17 @@ impl<'a> State<'a> {
fn print_associated_type( fn print_associated_type(
&mut self, &mut self,
ident: ast::Ident, ident: ast::Ident,
generics: &hir::Generics<'_>,
bounds: Option<hir::GenericBounds<'_>>, bounds: Option<hir::GenericBounds<'_>>,
ty: Option<&hir::Ty<'_>>, ty: Option<&hir::Ty<'_>>,
) { ) {
self.word_space("type"); self.word_space("type");
self.print_ident(ident); self.print_ident(ident);
self.print_generic_params(&generics.params);
if let Some(bounds) = bounds { if let Some(bounds) = bounds {
self.print_bounds(":", bounds); self.print_bounds(":", bounds);
} }
self.print_where_clause(&generics.where_clause);
if let Some(ty) = ty { if let Some(ty) = ty {
self.s.space(); self.s.space();
self.word_space("="); self.word_space("=");
@ -902,6 +905,7 @@ impl<'a> State<'a> {
hir::TraitItemKind::Type(ref bounds, ref default) => { hir::TraitItemKind::Type(ref bounds, ref default) => {
self.print_associated_type( self.print_associated_type(
ti.ident, ti.ident,
&ti.generics,
Some(bounds), Some(bounds),
default.as_ref().map(|ty| &**ty), default.as_ref().map(|ty| &**ty),
); );
@ -930,7 +934,7 @@ impl<'a> State<'a> {
self.ann.nested(self, Nested::Body(body)); self.ann.nested(self, Nested::Body(body));
} }
hir::ImplItemKind::TyAlias(ref ty) => { hir::ImplItemKind::TyAlias(ref ty) => {
self.print_associated_type(ii.ident, None, Some(ty)); self.print_associated_type(ii.ident, &ii.generics, None, Some(ty));
} }
hir::ImplItemKind::OpaqueTy(bounds) => { hir::ImplItemKind::OpaqueTy(bounds) => {
self.word_space("type"); self.word_space("type");