Fix pretty printing an AST representing &(mut ident)
`PatKind::Ref(PatKind::Ident(BindingMode::ByValue(Mutability::Mut), ..), ..)` is an AST representing `&(mut ident)`. It was errorneously printed as `&mut ident` which reparsed into a syntactically different AST. This affected help diagnostics in the parser.
This commit is contained in:
parent
b1964e60b7
commit
b05ab18aec
3 changed files with 28 additions and 1 deletions
|
|
@ -2420,7 +2420,15 @@ impl<'a> State<'a> {
|
|||
if mutbl == ast::Mutability::Mut {
|
||||
self.s.word("mut ");
|
||||
}
|
||||
self.print_pat(inner);
|
||||
if let PatKind::Ident(ast::BindingMode::ByValue(ast::Mutability::Mut), ..) =
|
||||
inner.kind
|
||||
{
|
||||
self.popen();
|
||||
self.print_pat(inner);
|
||||
self.pclose();
|
||||
} else {
|
||||
self.print_pat(inner);
|
||||
}
|
||||
}
|
||||
PatKind::Lit(ref e) => self.print_expr(&**e),
|
||||
PatKind::Range(ref begin, ref end, Spanned { node: ref end_kind, .. }) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue