suggest: remove redundant $()?around vis fragments

This commit is contained in:
Makai 2025-04-11 15:30:00 +08:00
parent 95ad6dfeab
commit f97da855b1
3 changed files with 110 additions and 6 deletions

View file

@ -0,0 +1,28 @@
macro_rules! ciallo {
($($v: vis)? $name: ident) => {
//~^ error: repetition matches empty token tree
};
}
macro_rules! meow {
($name: ident $($v: vis)?) => {
//~^ error: repetition matches empty token tree
};
}
macro_rules! gbc {
($name: ident $/*
this comment gets removed by the suggestion
*/
($v: vis)?) => {
//~^ error: repetition matches empty token tree
};
}
ciallo!(hello);
meow!(miaow, pub);
gbc!(mygo,);
fn main() {}

View file

@ -0,0 +1,44 @@
error: repetition matches empty token tree
--> $DIR/remove-repetition-issue-139480.rs:2:7
|
LL | ($($v: vis)? $name: ident) => {
| ^^^^^^^^^
|
= note: a `vis` fragment can already be empty
help: remove the `$(` and `)?`
|
LL - ($($v: vis)? $name: ident) => {
LL + ($v: vis $name: ident) => {
|
error: repetition matches empty token tree
--> $DIR/remove-repetition-issue-139480.rs:8:20
|
LL | ($name: ident $($v: vis)?) => {
| ^^^^^^^^^
|
= note: a `vis` fragment can already be empty
help: remove the `$(` and `)?`
|
LL - ($name: ident $($v: vis)?) => {
LL + ($name: ident $v: vis) => {
|
error: repetition matches empty token tree
--> $DIR/remove-repetition-issue-139480.rs:17:9
|
LL | ($v: vis)?) => {
| ^^^^^^^^^
|
= note: a `vis` fragment can already be empty
help: remove the `$(` and `)?`
|
LL - ($name: ident $/*
LL - this comment gets removed by the suggestion
LL - */
LL - ($v: vis)?) => {
LL + ($name: ident $v: vis) => {
|
error: aborting due to 3 previous errors