Skip to content

Commit

Permalink
deps: Update syntex_syntax to 0.33
Browse files Browse the repository at this point in the history
This bump brings syntex_syntax support for `..` in tuple and tuple
struct patterns, which come from RFC 1492:
  https://github.com/rust-lang/rfcs/blob/master/text/1492-dotdot-in-patterns.md

These new patterns are not properly handled in this PR; instead rust-lang#1021
tracks supporting them.

Refs rust-lang#1021
  • Loading branch information
kamalmarhubi committed May 30, 2016
1 parent 66cac1f commit 120e1a0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,15 @@ impl Rewrite for ast::Stmt {
struct Loop<'a> {
cond: Option<&'a ast::Expr>,
block: &'a ast::Block,
label: Option<ast::Ident>,
label: Option<ast::SpannedIdent>,
pat: Option<&'a ast::Pat>,
keyword: &'a str,
matcher: &'a str,
connector: &'a str,
}

impl<'a> Loop<'a> {
fn new_loop(block: &'a ast::Block, label: Option<ast::Ident>) -> Loop<'a> {
fn new_loop(block: &'a ast::Block, label: Option<ast::SpannedIdent>) -> Loop<'a> {
Loop {
cond: None,
block: block,
Expand All @@ -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<ast::Ident>)
label: Option<ast::SpannedIdent>)
-> Loop<'a> {
Loop {
cond: Some(cond),
Expand All @@ -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<ast::Ident>)
label: Option<ast::SpannedIdent>)
-> Loop<'a> {
Loop {
cond: Some(cond),
Expand Down Expand Up @@ -676,9 +676,9 @@ impl<'a> Rewrite for Loop<'a> {
}
}

fn rewrite_label(label: Option<ast::Ident>) -> String {
fn rewrite_label(label: Option<ast::SpannedIdent>) -> String {
match label {
Some(ident) => format!("{}: ", ident),
Some(ident) => format!("{}: ", ident.node),
None => "".to_owned(),
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ impl<'a> FmtVisitor<'a> {
indent,
item.ident,
fn_decl,
None,
generics,
ast::Unsafety::Normal,
ast::Constness::NotConst,
Expand Down Expand Up @@ -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,
Expand All @@ -189,7 +187,6 @@ impl<'a> FmtVisitor<'a> {
indent,
ident,
fd,
explicit_self,
generics,
unsafety,
constness,
Expand Down Expand Up @@ -234,7 +231,6 @@ impl<'a> FmtVisitor<'a> {
indent,
ident,
&sig.decl,
Some(&sig.explicit_self),
&sig.generics,
sig.unsafety,
sig.constness,
Expand Down Expand Up @@ -1129,7 +1125,7 @@ fn rewrite_explicit_self(explicit_self: &ast::ExplicitSelf,
context: &RewriteContext)
-> Option<String> {
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) => {
Expand All @@ -1155,7 +1151,6 @@ fn rewrite_explicit_self(explicit_self: &ast::ExplicitSelf,

Some(format!("{}self", format_mutability(mutability)))
}
_ => None,
}
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,25 @@ 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,
width,
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 {
Expand All @@ -95,7 +101,6 @@ impl Rewrite for Pat {
context.config))))
}
}
None => Some(format!("{}(..)", path_str)),
}
}
PatKind::Lit(ref expr) => expr.rewrite(context, width, offset),
Expand Down
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ impl Rewrite for ast::Ty {
}
ast::TyKind::Mac(..) |
ast::TyKind::Typeof(..) => unreachable!(),
ast::TyKind::ImplicitSelf => Some(String::from("")),
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ impl<'a> FmtVisitor<'a> {
self.rewrite_fn(indent,
ident,
fd,
None,
generics,
unsafety,
constness,
Expand All @@ -155,7 +154,6 @@ impl<'a> FmtVisitor<'a> {
self.rewrite_fn(indent,
ident,
fd,
Some(&sig.explicit_self),
&sig.generics,
sig.unsafety,
sig.constness,
Expand Down

0 comments on commit 120e1a0

Please sign in to comment.