diff --git a/src/closures.rs b/src/closures.rs index 257b8729f45..5f1102a36fc 100644 --- a/src/closures.rs +++ b/src/closures.rs @@ -31,6 +31,7 @@ // statement without needing a semi-colon), then adding or removing braces // can change whether it is treated as an expression or statement. +// FIXME(topecongiro) Format async closures (#2813). pub fn rewrite_closure( capture: ast::CaptureBy, movability: ast::Movability, @@ -288,7 +289,7 @@ pub fn rewrite_last_closure( expr: &ast::Expr, shape: Shape, ) -> Option { - 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 { ast::ExprKind::Block(ref block, _) if !is_unsafe_block(block) diff --git a/src/expr.rs b/src/expr.rs index b8a323f73a2..ca31b0b82ef 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -183,7 +183,7 @@ pub fn format_expr( } else { 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( capture, movability, fn_decl, body, expr.span, context, shape, ) @@ -344,6 +344,8 @@ fn needs_space_after_range(rhs: &ast::Expr) -> bool { } // FIXME(#2743) ast::ExprKind::ObsoleteInPlace(..) => unimplemented!(), + // FIXME(topecongiro) Format async block. + ast::ExprKind::Async(..) => None, }; expr_rw diff --git a/src/items.rs b/src/items.rs index bef8fd79599..fe638a17069 100644 --- a/src/items.rs +++ b/src/items.rs @@ -192,10 +192,10 @@ pub fn from_method_sig( generics: &'a ast::Generics, ) -> FnSig<'a> { FnSig { - unsafety: method_sig.unsafety, - constness: method_sig.constness.node, + unsafety: method_sig.header.unsafety, + constness: method_sig.header.constness.node, defaultness: ast::Defaultness::Final, - abi: method_sig.abi, + abi: method_sig.header.abi, decl: &*method_sig.decl, generics, visibility: DEFAULT_VISIBILITY, @@ -209,13 +209,13 @@ pub fn from_fn_kind( defaultness: ast::Defaultness, ) -> FnSig<'a> { match *fn_kind { - visit::FnKind::ItemFn(_, unsafety, constness, abi, visibility, _) => FnSig { + visit::FnKind::ItemFn(_, fn_header, visibility, _) => FnSig { decl, generics, - abi, - constness: constness.node, + abi: fn_header.abi, + constness: fn_header.constness.node, defaultness, - unsafety, + unsafety: fn_header.unsafety, visibility: visibility.clone(), }, visit::FnKind::Method(_, method_sig, vis, _) => { diff --git a/src/visitor.rs b/src/visitor.rs index 76fd3395ba9..2b0f08dd0c7 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -252,6 +252,7 @@ fn close_block(&mut self, unindent_comment: bool) { // Note that this only gets called for function definitions. Required methods // on traits do not get handled here. + // FIXME(topecongiro) Format async fn (#2812). fn visit_fn( &mut self, fk: visit::FnKind, @@ -264,7 +265,7 @@ fn visit_fn( let indent = self.block_indent; let block; 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; self.rewrite_fn( indent, @@ -392,10 +393,10 @@ pub fn visit_item(&mut self, item: &ast::Item) { ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => { 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); 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, decl, item.span,