Skip to content

"< is interpreted as a start of generic arguments for '_', not a comparison" #44406

Closed
@ghost

Description

Playground link: https://play.rust-lang.org/?gist=e93b00dd6c33bf6bbcc035a7be501592&version=stable

macro_rules! foo {
    (
        $(
            bar: {
                $($rest:tt)+
            }
        )+
    ) => {
        $(
            bar($($rest)+);
        )+
    };
}

macro_rules! bar {
    (baz: $baz:expr,) => {};
}

fn main() {
    foo!{
        bar: {
            baz: true,
        }
    }
}
Compiling playground v0.0.1 (file:///playground)
error: expected identifier, found keyword `true`
  --> src/main.rs:24:18
   |
24 |             baz: true,
   |                  ^^^^

error: `<` is interpreted as a start of generic arguments for `true`, not a comparison
  --> src/main.rs:24:22
   |
24 |             baz: true,
   |                      -
   |                      |
   |                      not interpreted as comparison
   |                      interpreted as generic arguments
   |
help: if you want to compare the casted value then write:
   |
24 |             (baz: true),
   |             ^^^^^^^^^^^

error: aborting due to 2 previous errors

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Metadata

Assignees

Labels

A-parserArea: The parsing of Rust source code to an ASTC-bugCategory: This is a bug.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