forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#65123 - Centril:mac-invoc-in-mut-pat, r=est…
…ebank Account for macro invocation in `let mut $pat` diagnostic. Fixes rust-lang#65122. r? @estebank
- Loading branch information
Showing
3 changed files
with
76 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
26 changes: 26 additions & 0 deletions
26
src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.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,26 @@ | ||
// Regression test; used to ICE with 'visit_mac disabled by default' due to a | ||
// `MutVisitor` in `fn make_all_value_bindings_mutable` (`parse/parser/pat.rs`). | ||
|
||
macro_rules! mac1 { | ||
($eval:expr) => { | ||
let mut $eval = (); | ||
//~^ ERROR `mut` must be followed by a named binding | ||
}; | ||
} | ||
|
||
macro_rules! mac2 { | ||
($eval:pat) => { | ||
let mut $eval = (); | ||
//~^ ERROR `mut` must be followed by a named binding | ||
//~| ERROR expected identifier, found `does_not_exist!()` | ||
}; | ||
} | ||
|
||
fn foo() { | ||
mac1! { does_not_exist!() } | ||
//~^ ERROR cannot find macro `does_not_exist` in this scope | ||
mac2! { does_not_exist!() } | ||
//~^ ERROR cannot find macro `does_not_exist` in this scope | ||
} | ||
|
||
fn main() {} |
45 changes: 45 additions & 0 deletions
45
src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.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,45 @@ | ||
error: `mut` must be followed by a named binding | ||
--> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:6:13 | ||
| | ||
LL | let mut $eval = (); | ||
| ^^^^^^^^^ help: remove the `mut` prefix: `does_not_exist!()` | ||
... | ||
LL | mac1! { does_not_exist!() } | ||
| --------------------------- in this macro invocation | ||
| | ||
= note: `mut` may be followed by `variable` and `variable @ pattern` | ||
|
||
error: expected identifier, found `does_not_exist!()` | ||
--> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:17 | ||
| | ||
LL | let mut $eval = (); | ||
| ^^^^^ expected identifier | ||
... | ||
LL | mac2! { does_not_exist!() } | ||
| --------------------------- in this macro invocation | ||
|
||
error: `mut` must be followed by a named binding | ||
--> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:13 | ||
| | ||
LL | let mut $eval = (); | ||
| ^^^ help: remove the `mut` prefix: `does_not_exist!()` | ||
... | ||
LL | mac2! { does_not_exist!() } | ||
| --------------------------- in this macro invocation | ||
| | ||
= note: `mut` may be followed by `variable` and `variable @ pattern` | ||
|
||
error: cannot find macro `does_not_exist` in this scope | ||
--> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:20:13 | ||
| | ||
LL | mac1! { does_not_exist!() } | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: cannot find macro `does_not_exist` in this scope | ||
--> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:22:13 | ||
| | ||
LL | mac2! { does_not_exist!() } | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|