Skip to content

$($v: vis)? should get suggestion to become $v: vis #139480

Closed
@cyrgani

Description

@cyrgani

Code

macro_rules! make_static {
    ($($v: vis)? $name: ident) => {
        $($v)? static $name: u32 = 0;
    };
}

Current output

error: repetition matches empty token tree
 --> src/lib.rs:2:7
  |
2 |     ($($v: vis)? $name: ident) => {
  |       ^^^^^^^^^

Desired output

error: repetition matches empty token tree
 --> src/lib.rs:2:7
  |
2 |     ($($v: vis)? $name: ident) => {
  |       ^^^^^^^^^
note: a `vis` fragment can already be empty
help: remove the `$(` and `)?`

Rationale and extra context

The current error is not very helpful and had be confused for quite some time.
@rustbot label D-terse

Other cases

Rust Version

1.88.0-nightly

(2025-04-06 2fa8b11f0933dae9b4e5)

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions