diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2020-02-09 13:19:06 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2020-02-09 13:19:06 +0000 |
| commit | fa5a3c35dcda3c82d0c10837cdcbf747e833eabd (patch) | |
| tree | 15770b9480c8ec601784f6ac3c54b4b9673228e9 /src/librustc_parse | |
| parent | 64ea639c12df0594dd891b1ba0b439c8c5eacd83 (diff) | |
| download | rust-fa5a3c35dcda3c82d0c10837cdcbf747e833eabd.tar.gz rust-fa5a3c35dcda3c82d0c10837cdcbf747e833eabd.zip | |
Don't parse `mut a @ b` as `mut a @ mut b`
Diffstat (limited to 'src/librustc_parse')
| -rw-r--r-- | src/librustc_parse/parser/pat.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/librustc_parse/parser/pat.rs b/src/librustc_parse/parser/pat.rs index e07b0733739..985185230f2 100644 --- a/src/librustc_parse/parser/pat.rs +++ b/src/librustc_parse/parser/pat.rs @@ -542,11 +542,14 @@ impl<'a> Parser<'a> { } fn visit_pat(&mut self, pat: &mut P<Pat>) { - if let PatKind::Ident(BindingMode::ByValue(ref mut m @ Mutability::Not), ..) = - pat.kind - { - *m = Mutability::Mut; + if let PatKind::Ident(ref mut bm, ..) = pat.kind { + if let BindingMode::ByValue(ref mut m @ Mutability::Not) = bm { + *m = Mutability::Mut; + } self.0 = true; + // Don't recurse into the subpattern, mut on the outer + // binding doesn't affect the inner bindings. + return; } noop_visit_pat(pat, self); } |
