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 @@ use utils::{last_line_width, left_most_sub_expr, stmt_expr};
// 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<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 {
ast::ExprKind::Block(ref block, _)
if !is_unsafe_block(block)

View File

@ -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 @@ pub fn format_expr(
}
// FIXME(#2743)
ast::ExprKind::ObsoleteInPlace(..) => unimplemented!(),
// FIXME(topecongiro) Format async block.
ast::ExprKind::Async(..) => None,
};
expr_rw

View File

@ -192,10 +192,10 @@ impl<'a> FnSig<'a> {
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 @@ impl<'a> FnSig<'a> {
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, _) => {

View File

@ -252,6 +252,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
// 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 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
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 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
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,