1
Fork 0

Extract fn rewrite methods from RewriteVisitor

This commit is contained in:
Marcus Klaas 2015-11-22 13:45:51 +01:00
parent a871405f45
commit 1b0ae00488
3 changed files with 824 additions and 811 deletions

File diff suppressed because it is too large Load diff

View file

@ -492,13 +492,14 @@ impl Rewrite for ast::Ty {
None None
} }
} }
ast::TyBareFn(..) => { ast::TyBareFn(ref bare_fn) => bare_fn.rewrite(context, width, offset),
wrap_str(pprust::ty_to_string(self),
context.config.max_width,
width,
offset)
}
ast::TyMac(..) | ast::TyTypeof(..) => unreachable!(), ast::TyMac(..) | ast::TyTypeof(..) => unreachable!(),
} }
} }
} }
impl Rewrite for ast::BareFnTy {
fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Option<String> {
None
}
}

View file

@ -220,8 +220,11 @@ impl<'a> FmtVisitor<'a> {
self.last_pos = item.span.hi; self.last_pos = item.span.hi;
} }
ast::Item_::ItemStruct(ref def, ref generics) => { ast::Item_::ItemStruct(ref def, ref generics) => {
let rewrite = {
let indent = self.block_indent; let indent = self.block_indent;
let rewrite = self.format_struct("struct ", let context = self.get_context();
::items::format_struct(&context,
"struct ",
item.ident, item.ident,
item.vis, item.vis,
def, def,
@ -233,7 +236,8 @@ impl<'a> FmtVisitor<'a> {
ast::VariantData::Tuple(..) => s + ";", ast::VariantData::Tuple(..) => s + ";",
_ => s, _ => s,
} }
}); })
};
self.push_rewrite(item.span, rewrite); self.push_rewrite(item.span, rewrite);
} }
ast::Item_::ItemEnum(ref def, ref generics) => { ast::Item_::ItemEnum(ref def, ref generics) => {