diff --git a/Cargo.lock b/Cargo.lock index 1999f6c811a..621659c737f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ dependencies = [ "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "strings 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "syntex_syntax 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "syntex_syntax 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "syntex_syntax" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index b0964c03704..756fcc600e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ regex = "0.1" term = "0.4" strings = "0.0.1" diff = "0.1" -syntex_syntax = "0.32" +syntex_syntax = "0.33" log = "0.3" env_logger = "0.3" getopts = "0.2" diff --git a/src/expr.rs b/src/expr.rs index ebe34400014..73b76534f75 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -581,7 +581,7 @@ impl Rewrite for ast::Stmt { struct Loop<'a> { cond: Option<&'a ast::Expr>, block: &'a ast::Block, - label: Option, + label: Option, pat: Option<&'a ast::Pat>, keyword: &'a str, matcher: &'a str, @@ -589,7 +589,7 @@ struct Loop<'a> { } impl<'a> Loop<'a> { - fn new_loop(block: &'a ast::Block, label: Option) -> Loop<'a> { + fn new_loop(block: &'a ast::Block, label: Option) -> Loop<'a> { Loop { cond: None, block: block, @@ -604,7 +604,7 @@ impl<'a> Loop<'a> { fn new_while(pat: Option<&'a ast::Pat>, cond: &'a ast::Expr, block: &'a ast::Block, - label: Option) + label: Option) -> Loop<'a> { Loop { cond: Some(cond), @@ -623,7 +623,7 @@ impl<'a> Loop<'a> { fn new_for(pat: &'a ast::Pat, cond: &'a ast::Expr, block: &'a ast::Block, - label: Option) + label: Option) -> Loop<'a> { Loop { cond: Some(cond), @@ -676,9 +676,9 @@ impl<'a> Rewrite for Loop<'a> { } } -fn rewrite_label(label: Option) -> String { +fn rewrite_label(label: Option) -> String { match label { - Some(ident) => format!("{}: ", ident), + Some(ident) => format!("{}: ", ident.node), None => "".to_owned(), } } diff --git a/src/items.rs b/src/items.rs index b55ecd5c0ef..6bbf0dd5044 100644 --- a/src/items.rs +++ b/src/items.rs @@ -116,7 +116,6 @@ impl<'a> FmtVisitor<'a> { indent, item.ident, fn_decl, - None, generics, ast::Unsafety::Normal, ast::Constness::NotConst, @@ -169,7 +168,6 @@ impl<'a> FmtVisitor<'a> { indent: Indent, ident: ast::Ident, fd: &ast::FnDecl, - explicit_self: Option<&ast::ExplicitSelf>, generics: &ast::Generics, unsafety: ast::Unsafety, constness: ast::Constness, @@ -189,7 +187,6 @@ impl<'a> FmtVisitor<'a> { indent, ident, fd, - explicit_self, generics, unsafety, constness, @@ -234,7 +231,6 @@ impl<'a> FmtVisitor<'a> { indent, ident, &sig.decl, - Some(&sig.explicit_self), &sig.generics, sig.unsafety, sig.constness, @@ -1129,7 +1125,7 @@ fn rewrite_explicit_self(explicit_self: &ast::ExplicitSelf, context: &RewriteContext) -> Option { match explicit_self.node { - ast::SelfKind::Region(lt, m, _) => { + ast::SelfKind::Region(lt, m) => { let mut_str = format_mutability(m); match lt { Some(ref l) => { @@ -1155,7 +1151,6 @@ fn rewrite_explicit_self(explicit_self: &ast::ExplicitSelf, Some(format!("{}self", format_mutability(mutability))) } - _ => None, } } @@ -1229,7 +1224,6 @@ fn rewrite_fn_base(context: &RewriteContext, indent: Indent, ident: ast::Ident, fd: &ast::FnDecl, - explicit_self: Option<&ast::ExplicitSelf>, generics: &ast::Generics, unsafety: ast::Unsafety, constness: ast::Constness, @@ -1328,7 +1322,7 @@ fn rewrite_fn_base(context: &RewriteContext, span_for_return(&fd.output).lo); let arg_str = try_opt!(rewrite_args(context, &fd.inputs, - explicit_self, + fd.get_self().as_ref(), one_line_budget, multi_line_budget, indent, diff --git a/src/patterns.rs b/src/patterns.rs index 837fecd83ce..1c147a3e74b 100644 --- a/src/patterns.rs +++ b/src/patterns.rs @@ -59,7 +59,11 @@ impl Rewrite for Pat { let prefix = format!("&{}", format_mutability(mutability)); rewrite_unary_prefix(context, &prefix, &**pat, width, offset) } - PatKind::Tup(ref items) => { + // FIXME(#1021): Handle `..` in tuple / tuple struct patterns (RFC 1492) + PatKind::Tuple(ref items, dotdot_pos) => { + if dotdot_pos.is_some() { + return None; + } rewrite_tuple(context, items.iter().map(|x| &**x), self.span, @@ -67,11 +71,13 @@ impl Rewrite for Pat { offset) } PatKind::Path(ref path) => rewrite_path(context, true, None, path, width, offset), - PatKind::TupleStruct(ref path, ref pat_vec) => { + PatKind::TupleStruct(ref path, ref pat_vec, dotdot_pos) => { let path_str = try_opt!(rewrite_path(context, true, None, path, width, offset)); - match *pat_vec { - Some(ref pat_vec) => { + // FIXME(#1021): Handle `..` in tuple / tuple struct patterns (RFC 1492) + match dotdot_pos { + Some(_) => Some(format!("{}(..)", path_str)), + None => { if pat_vec.is_empty() { Some(path_str) } else { @@ -95,7 +101,6 @@ impl Rewrite for Pat { context.config)))) } } - None => Some(format!("{}(..)", path_str)), } } PatKind::Lit(ref expr) => expr.rewrite(context, width, offset), diff --git a/src/types.rs b/src/types.rs index 8dd8c09959b..8b5be1b4191 100644 --- a/src/types.rs +++ b/src/types.rs @@ -588,6 +588,7 @@ impl Rewrite for ast::Ty { } ast::TyKind::Mac(..) | ast::TyKind::Typeof(..) => unreachable!(), + ast::TyKind::ImplicitSelf => Some(String::from("")), } } } diff --git a/src/visitor.rs b/src/visitor.rs index 8473d1685da..b70ae8bb240 100644 --- a/src/visitor.rs +++ b/src/visitor.rs @@ -142,7 +142,6 @@ impl<'a> FmtVisitor<'a> { self.rewrite_fn(indent, ident, fd, - None, generics, unsafety, constness, @@ -155,7 +154,6 @@ impl<'a> FmtVisitor<'a> { self.rewrite_fn(indent, ident, fd, - Some(&sig.explicit_self), &sig.generics, sig.unsafety, sig.constness,