Skip to content

ICE suggestion must not have overlapping parts with nested, malformed macro decl #118786

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

macro_rules! make_macro {
    ($macro_name:tt $($matcher:tt)*) => {
        #[macro_export]
        macro_rules! $macro_name [T; 0]
    }
}
make_macro! {
    (<= $($matcher)* =>) => {};
}

Meta

rustc --version --verbose:

f967532a47eb728ada44473a5c4c2eca1a45fe30

Error output

The problem seems to be this:

error: macros that expand to items must be delimited with braces or followed by a semicolon (note how the `r` is green)
 --> 92998.rs:4:22
  |
4 |         macro_rules! $macro_name [T; 0]
  |                      ^^^^^^^^^^^
  |
help: change the delimiters to curly braces
  |
4 |         macro_rules! {} [T; 0]
  |                      ~
help: add a semicolon
  |
4 |         macro_rules! $macro_name; [T; 0]
  |                                 +

But it looks like rustc already gets the span wrong:
spans

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-debug-assertionsThis issue requires a build of rustc or tooling with debug-assertions in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions