forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#111908 - c410-f3r:yetegdfqwer, r=petrochenkov
[RFC-3086] Restrict the parsing of `count` Fix rust-lang#111904 The original RFC didn't mention the possibility of using `${count(t,)}` and such thing isn't very semantically accurate which can lead to confusion.
- Loading branch information
Showing
3 changed files
with
44 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
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,14 @@ | ||
#![feature(macro_metavar_expr)] | ||
|
||
macro_rules! foo { | ||
( $( $($t:ident),* );* ) => { ${count(t,)} } | ||
//~^ ERROR `count` followed by a comma must have an associated | ||
//~| ERROR expected expression, found `$` | ||
} | ||
|
||
fn test() { | ||
foo!(a, a; b, b); | ||
} | ||
|
||
fn main() { | ||
} |
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,19 @@ | ||
error: `count` followed by a comma must have an associated index indicating its depth | ||
--> $DIR/issue-111904.rs:4:37 | ||
| | ||
LL | ( $( $($t:ident),* );* ) => { ${count(t,)} } | ||
| ^^^^^ | ||
|
||
error: expected expression, found `$` | ||
--> $DIR/issue-111904.rs:4:35 | ||
| | ||
LL | ( $( $($t:ident),* );* ) => { ${count(t,)} } | ||
| ^ expected expression | ||
... | ||
LL | foo!(a, a; b, b); | ||
| ---------------- in this macro invocation | ||
| | ||
= note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 2 previous errors | ||
|