Fix compile errors from breaking changes

This commit is contained in:
Seiichi Uchida 2018-06-28 16:26:10 +09:00
parent dd3e1d751f
commit cc2afeca9e
4 changed files with 16 additions and 12 deletions

View File

@ -31,6 +31,7 @@
// statement without needing a semi-colon), then adding or removing braces // statement without needing a semi-colon), then adding or removing braces
// can change whether it is treated as an expression or statement. // can change whether it is treated as an expression or statement.
// FIXME(topecongiro) Format async closures (#2813).
pub fn rewrite_closure( pub fn rewrite_closure(
capture: ast::CaptureBy, capture: ast::CaptureBy,
movability: ast::Movability, movability: ast::Movability,
@ -288,7 +289,7 @@ pub fn rewrite_last_closure(
expr: &ast::Expr, expr: &ast::Expr,
shape: Shape, shape: Shape,
) -> Option<String> { ) -> Option<String> {
if let ast::ExprKind::Closure(capture, movability, ref fn_decl, ref body, _) = expr.node { if let ast::ExprKind::Closure(capture, _, movability, ref fn_decl, ref body, _) = expr.node {
let body = match body.node { let body = match body.node {
ast::ExprKind::Block(ref block, _) ast::ExprKind::Block(ref block, _)
if !is_unsafe_block(block) if !is_unsafe_block(block)

View File

@ -183,7 +183,7 @@ pub fn format_expr(
} else { } else {
Some("yield".to_string()) Some("yield".to_string())
}, },
ast::ExprKind::Closure(capture, movability, ref fn_decl, ref body, _) => { ast::ExprKind::Closure(capture, _, movability, ref fn_decl, ref body, _) => {
closures::rewrite_closure( closures::rewrite_closure(
capture, movability, fn_decl, body, expr.span, context, shape, capture, movability, fn_decl, body, expr.span, context, shape,
) )
@ -344,6 +344,8 @@ fn needs_space_after_range(rhs: &ast::Expr) -> bool {
} }
// FIXME(#2743) // FIXME(#2743)
ast::ExprKind::ObsoleteInPlace(..) => unimplemented!(), ast::ExprKind::ObsoleteInPlace(..) => unimplemented!(),
// FIXME(topecongiro) Format async block.
ast::ExprKind::Async(..) => None,
}; };
expr_rw expr_rw

View File

@ -192,10 +192,10 @@ pub fn from_method_sig(
generics: &'a ast::Generics, generics: &'a ast::Generics,
) -> FnSig<'a> { ) -> FnSig<'a> {
FnSig { FnSig {
unsafety: method_sig.unsafety, unsafety: method_sig.header.unsafety,
constness: method_sig.constness.node, constness: method_sig.header.constness.node,
defaultness: ast::Defaultness::Final, defaultness: ast::Defaultness::Final,
abi: method_sig.abi, abi: method_sig.header.abi,
decl: &*method_sig.decl, decl: &*method_sig.decl,
generics, generics,
visibility: DEFAULT_VISIBILITY, visibility: DEFAULT_VISIBILITY,
@ -209,13 +209,13 @@ pub fn from_fn_kind(
defaultness: ast::Defaultness, defaultness: ast::Defaultness,
) -> FnSig<'a> { ) -> FnSig<'a> {
match *fn_kind { match *fn_kind {
visit::FnKind::ItemFn(_, unsafety, constness, abi, visibility, _) => FnSig { visit::FnKind::ItemFn(_, fn_header, visibility, _) => FnSig {
decl, decl,
generics, generics,
abi, abi: fn_header.abi,
constness: constness.node, constness: fn_header.constness.node,
defaultness, defaultness,
unsafety, unsafety: fn_header.unsafety,
visibility: visibility.clone(), visibility: visibility.clone(),
}, },
visit::FnKind::Method(_, method_sig, vis, _) => { visit::FnKind::Method(_, method_sig, vis, _) => {

View File

@ -252,6 +252,7 @@ fn close_block(&mut self, unindent_comment: bool) {
// Note that this only gets called for function definitions. Required methods // Note that this only gets called for function definitions. Required methods
// on traits do not get handled here. // on traits do not get handled here.
// FIXME(topecongiro) Format async fn (#2812).
fn visit_fn( fn visit_fn(
&mut self, &mut self,
fk: visit::FnKind, fk: visit::FnKind,
@ -264,7 +265,7 @@ fn visit_fn(
let indent = self.block_indent; let indent = self.block_indent;
let block; let block;
let rewrite = match fk { let rewrite = match fk {
visit::FnKind::ItemFn(ident, _, _, _, _, b) | visit::FnKind::Method(ident, _, _, b) => { visit::FnKind::ItemFn(ident, _, _, b) | visit::FnKind::Method(ident, _, _, b) => {
block = b; block = b;
self.rewrite_fn( self.rewrite_fn(
indent, indent,
@ -392,10 +393,10 @@ pub fn visit_item(&mut self, item: &ast::Item) {
ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => { ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => {
self.visit_static(&StaticParts::from_item(item)); self.visit_static(&StaticParts::from_item(item));
} }
ast::ItemKind::Fn(ref decl, unsafety, constness, abi, ref generics, ref body) => { ast::ItemKind::Fn(ref decl, fn_header, ref generics, ref body) => {
let inner_attrs = inner_attributes(&item.attrs); let inner_attrs = inner_attributes(&item.attrs);
self.visit_fn( self.visit_fn(
visit::FnKind::ItemFn(item.ident, unsafety, constness, abi, &item.vis, body), visit::FnKind::ItemFn(item.ident, fn_header, &item.vis, body),
generics, generics,
decl, decl,
item.span, item.span,