Fix spans for enum-struct match arms
Correct spans for fields in enum struct arms where the field and variable are unified
This commit is contained in:
parent
4ca51aeea7
commit
aa5c8ea600
1 changed files with 8 additions and 10 deletions
|
@ -2781,7 +2781,6 @@ impl<'a> Parser<'a> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let lo1 = self.last_span.lo;
|
|
||||||
let bind_type = if self.eat_keyword(keywords::Mut) {
|
let bind_type = if self.eat_keyword(keywords::Mut) {
|
||||||
BindByValue(MutMutable)
|
BindByValue(MutMutable)
|
||||||
} else if self.eat_keyword(keywords::Ref) {
|
} else if self.eat_keyword(keywords::Ref) {
|
||||||
|
@ -2791,11 +2790,8 @@ impl<'a> Parser<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let fieldname = self.parse_ident();
|
let fieldname = self.parse_ident();
|
||||||
let hi1 = self.last_span.lo;
|
|
||||||
let fieldpath = ast_util::ident_to_path(mk_sp(lo1, hi1),
|
let subpat = if self.token == token::COLON {
|
||||||
fieldname);
|
|
||||||
let subpat;
|
|
||||||
if self.token == token::COLON {
|
|
||||||
match bind_type {
|
match bind_type {
|
||||||
BindByRef(..) | BindByValue(MutMutable) => {
|
BindByRef(..) | BindByValue(MutMutable) => {
|
||||||
let token_str = self.this_token_to_str();
|
let token_str = self.this_token_to_str();
|
||||||
|
@ -2805,14 +2801,16 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.bump();
|
self.bump();
|
||||||
subpat = self.parse_pat();
|
self.parse_pat()
|
||||||
} else {
|
} else {
|
||||||
subpat = @ast::Pat {
|
let fieldpath = ast_util::ident_to_path(self.last_span,
|
||||||
|
fieldname);
|
||||||
|
@ast::Pat {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: PatIdent(bind_type, fieldpath, None),
|
node: PatIdent(bind_type, fieldpath, None),
|
||||||
span: self.last_span
|
span: self.last_span
|
||||||
};
|
}
|
||||||
}
|
};
|
||||||
fields.push(ast::FieldPat { ident: fieldname, pat: subpat });
|
fields.push(ast::FieldPat { ident: fieldname, pat: subpat });
|
||||||
}
|
}
|
||||||
return (fields, etc);
|
return (fields, etc);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue