1
Fork 0

Fix indents.

This commit is contained in:
Jeffrey Seyfried 2016-09-22 22:44:59 +00:00
parent 1e1804db18
commit 2c85733521

View file

@ -1231,7 +1231,7 @@ impl<'a> Parser<'a> {
self.parse_token_tree()?; self.parse_token_tree()?;
break; break;
} }
_ => self.bump() _ => self.bump(),
} }
} }
@ -1266,20 +1266,18 @@ impl<'a> Parser<'a> {
} }
token::OpenDelim(token::Brace) => { token::OpenDelim(token::Brace) => {
debug!("parse_trait_methods(): parsing provided method"); debug!("parse_trait_methods(): parsing provided method");
let (inner_attrs, body) = let (inner_attrs, body) = self.parse_inner_attrs_and_block()?;
self.parse_inner_attrs_and_block()?;
attrs.extend(inner_attrs.iter().cloned()); attrs.extend(inner_attrs.iter().cloned());
Some(body) Some(body)
} }
_ => { _ => {
let token_str = self.this_token_to_string(); let token_str = self.this_token_to_string();
return Err(self.fatal(&format!("expected `;` or `{{`, found `{}`", return Err(self.fatal(&format!("expected `;` or `{{`, found `{}`", token_str)));
token_str)[..]))
} }
}; };
(ident, ast::TraitItemKind::Method(sig, body)) (ident, ast::TraitItemKind::Method(sig, body))
}; };
Ok(TraitItem { Ok(TraitItem {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
ident: name, ident: name,
@ -3574,7 +3572,6 @@ impl<'a> Parser<'a> {
if let token::Lifetime(ident) = self.token { if let token::Lifetime(ident) = self.token {
return Err(self.fatal(&format!("unexpected lifetime `{}` in pattern", ident))); return Err(self.fatal(&format!("unexpected lifetime `{}` in pattern", ident)));
} }
let subpat = self.parse_pat()?; let subpat = self.parse_pat()?;
pat = PatKind::Ref(subpat, mutbl); pat = PatKind::Ref(subpat, mutbl);
} }
@ -3592,9 +3589,8 @@ impl<'a> Parser<'a> {
self.expect(&token::CloseDelim(token::Bracket))?; self.expect(&token::CloseDelim(token::Bracket))?;
pat = PatKind::Vec(before, slice, after); pat = PatKind::Vec(before, slice, after);
} }
_ => {
// At this point, token != _, &, &&, (, [ // At this point, token != _, &, &&, (, [
if self.eat_keyword(keywords::Mut) { _ => if self.eat_keyword(keywords::Mut) {
// Parse mut ident @ pat // Parse mut ident @ pat
pat = self.parse_pat_ident(BindingMode::ByValue(Mutability::Mutable))?; pat = self.parse_pat_ident(BindingMode::ByValue(Mutability::Mutable))?;
} else if self.eat_keyword(keywords::Ref) { } else if self.eat_keyword(keywords::Ref) {
@ -3605,9 +3601,8 @@ impl<'a> Parser<'a> {
// Parse box pat // Parse box pat
let subpat = self.parse_pat()?; let subpat = self.parse_pat()?;
pat = PatKind::Box(subpat); pat = PatKind::Box(subpat);
} else if self.token.is_path_start() { } else if self.token.is_ident() && self.token.is_path_start() &&
// Parse pattern starting with a path self.look_ahead(1, |t| match *t {
if self.token.is_ident() && self.look_ahead(1, |t| match *t {
token::OpenDelim(token::Paren) | token::OpenDelim(token::Brace) | token::OpenDelim(token::Paren) | token::OpenDelim(token::Brace) |
token::DotDotDot | token::ModSep | token::Not => false, token::DotDotDot | token::ModSep | token::Not => false,
_ => true, _ => true,
@ -3617,11 +3612,11 @@ impl<'a> Parser<'a> {
// they are dealt with later in resolve // they are dealt with later in resolve
let binding_mode = BindingMode::ByValue(Mutability::Immutable); let binding_mode = BindingMode::ByValue(Mutability::Immutable);
pat = self.parse_pat_ident(binding_mode)?; pat = self.parse_pat_ident(binding_mode)?;
} else { } else if self.token.is_path_start() {
// Parse pattern starting with a path
let (qself, path) = if self.eat_lt() { let (qself, path) = if self.eat_lt() {
// Parse a qualified path // Parse a qualified path
let (qself, path) = let (qself, path) = self.parse_qualified_path(PathStyle::Expr)?;
self.parse_qualified_path(PathStyle::Expr)?;
(Some(qself), path) (Some(qself), path)
} else { } else {
// Parse an unqualified path // Parse an unqualified path
@ -3632,12 +3627,11 @@ impl<'a> Parser<'a> {
// Parse macro invocation // Parse macro invocation
self.bump(); self.bump();
let delim = self.expect_open_delim()?; let delim = self.expect_open_delim()?;
let tts = self.parse_seq_to_end( let tts = self.parse_seq_to_end(&token::CloseDelim(delim),
&token::CloseDelim(delim), SeqSep::none(),
SeqSep::none(), |p| p.parse_token_tree())?; |p| p.parse_token_tree())?;
let mac = Mac_ { path: path, tts: tts }; let mac = spanned(lo, self.last_span.hi, Mac_ { path: path, tts: tts });
pat = PatKind::Mac(codemap::Spanned {node: mac, pat = PatKind::Mac(mac);
span: mk_sp(lo, self.last_span.hi)});
} }
token::DotDotDot => { token::DotDotDot => {
// Parse range // Parse range
@ -3672,10 +3666,7 @@ impl<'a> Parser<'a> {
self.expect(&token::CloseDelim(token::Paren))?; self.expect(&token::CloseDelim(token::Paren))?;
pat = PatKind::TupleStruct(path, fields, ddpos) pat = PatKind::TupleStruct(path, fields, ddpos)
} }
_ => { _ => pat = PatKind::Path(qself, path),
pat = PatKind::Path(qself, path);
}
}
} }
} else { } else {
// Try to parse everything else as literal with optional minus // Try to parse everything else as literal with optional minus
@ -3696,7 +3687,6 @@ impl<'a> Parser<'a> {
} }
} }
} }
}
let hi = self.last_span.hi; let hi = self.last_span.hi;
Ok(P(ast::Pat { Ok(P(ast::Pat {