-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Thomas Bahn
committed
Dec 20, 2020
1 parent
b1964e6
commit b05ab18
Showing
3 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/test/ui/pattern/issue-80186-mut-binding-help-suggestion.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Regression test for correct pretty-printing of an AST representing `&(mut x)` in help | ||
// suggestion diagnostic. | ||
|
||
fn main() { | ||
let mut &x = &0; | ||
//~^ ERROR `mut` must be attached to each individual binding | ||
//~| HELP add `mut` to each binding | ||
//~| SUGGESTION &(mut x) | ||
} |
10 changes: 10 additions & 0 deletions
10
src/test/ui/pattern/issue-80186-mut-binding-help-suggestion.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
error: `mut` must be attached to each individual binding | ||
--> $DIR/issue-80186-mut-binding-help-suggestion.rs:5:9 | ||
| | ||
LL | let mut &x = &0; | ||
| ^^^^^^ help: add `mut` to each binding: `&(mut x)` | ||
| | ||
= note: `mut` may be followed by `variable` and `variable @ pattern` | ||
|
||
error: aborting due to previous error | ||
|