Extract fn rewrite methods from RewriteVisitor
This commit is contained in:
parent
a871405f45
commit
1b0ae00488
3 changed files with 824 additions and 811 deletions
1590
src/items.rs
1590
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
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -220,20 +220,24 @@ 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 indent = self.block_indent;
|
let rewrite = {
|
||||||
let rewrite = self.format_struct("struct ",
|
let indent = self.block_indent;
|
||||||
item.ident,
|
let context = self.get_context();
|
||||||
item.vis,
|
::items::format_struct(&context,
|
||||||
def,
|
"struct ",
|
||||||
Some(generics),
|
item.ident,
|
||||||
item.span,
|
item.vis,
|
||||||
indent)
|
def,
|
||||||
.map(|s| {
|
Some(generics),
|
||||||
match *def {
|
item.span,
|
||||||
ast::VariantData::Tuple(..) => s + ";",
|
indent)
|
||||||
_ => s,
|
.map(|s| {
|
||||||
}
|
match *def {
|
||||||
});
|
ast::VariantData::Tuple(..) => 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) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue