parent
b2f6dd53c9
commit
55776f2822
1 changed files with 20 additions and 7 deletions
|
@ -2911,15 +2911,28 @@ impl<'a> Parser<'a> {
|
||||||
pat = PatRange(start, end);
|
pat = PatRange(start, end);
|
||||||
} else if is_plain_ident(&self.token) && !can_be_enum_or_struct {
|
} else if is_plain_ident(&self.token) && !can_be_enum_or_struct {
|
||||||
let name = self.parse_path(NoTypesAllowed).path;
|
let name = self.parse_path(NoTypesAllowed).path;
|
||||||
let sub;
|
if self.eat(&token::NOT) {
|
||||||
if self.eat(&token::AT) {
|
// macro invocation
|
||||||
// parse foo @ pat
|
let ket = token::close_delimiter_for(&self.token)
|
||||||
sub = Some(self.parse_pat());
|
.unwrap_or_else(|| self.fatal("expected open delimiter"));
|
||||||
|
self.bump();
|
||||||
|
|
||||||
|
let tts = self.parse_seq_to_end(&ket,
|
||||||
|
seq_sep_none(),
|
||||||
|
|p| p.parse_token_tree());
|
||||||
|
|
||||||
|
let mac = MacInvocTT(name, tts, EMPTY_CTXT);
|
||||||
|
pat = ast::PatMac(codemap::Spanned {node: mac, span: self.span});
|
||||||
} else {
|
} else {
|
||||||
// or just foo
|
let sub = if self.eat(&token::AT) {
|
||||||
sub = None;
|
// parse foo @ pat
|
||||||
|
Some(self.parse_pat())
|
||||||
|
} else {
|
||||||
|
// or just foo
|
||||||
|
None
|
||||||
|
};
|
||||||
|
pat = PatIdent(BindByValue(MutImmutable), name, sub);
|
||||||
}
|
}
|
||||||
pat = PatIdent(BindByValue(MutImmutable), name, sub);
|
|
||||||
} else {
|
} else {
|
||||||
// parse an enum pat
|
// parse an enum pat
|
||||||
let enum_path = self.parse_path(LifetimeAndTypesWithColons)
|
let enum_path = self.parse_path(LifetimeAndTypesWithColons)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue