Extract fn rewrite methods from RewriteVisitor
This commit is contained in:
parent
a871405f45
commit
1b0ae00488
3 changed files with 824 additions and 811 deletions
1224
src/items.rs
1224
src/items.rs
File diff suppressed because it is too large
Load diff
13
src/types.rs
13
src/types.rs
|
@ -492,13 +492,14 @@ impl Rewrite for ast::Ty {
|
|||
None
|
||||
}
|
||||
}
|
||||
ast::TyBareFn(..) => {
|
||||
wrap_str(pprust::ty_to_string(self),
|
||||
context.config.max_width,
|
||||
width,
|
||||
offset)
|
||||
}
|
||||
ast::TyBareFn(ref bare_fn) => bare_fn.rewrite(context, width, offset),
|
||||
ast::TyMac(..) | ast::TyTypeof(..) => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Rewrite for ast::BareFnTy {
|
||||
fn rewrite(&self, context: &RewriteContext, width: usize, offset: Indent) -> Option<String> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,8 +220,11 @@ impl<'a> FmtVisitor<'a> {
|
|||
self.last_pos = item.span.hi;
|
||||
}
|
||||
ast::Item_::ItemStruct(ref def, ref generics) => {
|
||||
let rewrite = {
|
||||
let indent = self.block_indent;
|
||||
let rewrite = self.format_struct("struct ",
|
||||
let context = self.get_context();
|
||||
::items::format_struct(&context,
|
||||
"struct ",
|
||||
item.ident,
|
||||
item.vis,
|
||||
def,
|
||||
|
@ -233,7 +236,8 @@ impl<'a> FmtVisitor<'a> {
|
|||
ast::VariantData::Tuple(..) => s + ";",
|
||||
_ => s,
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
self.push_rewrite(item.span, rewrite);
|
||||
}
|
||||
ast::Item_::ItemEnum(ref def, ref generics) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue