Skip to content

failed to parse if_chain macro invocation #7845

@digama0

Description

@digama0

Here's a simple version of the problem using the if_chain macro:

#[macro_use] extern crate if_chain;

fn main() {
  if_chain! {
    then { let _ = drop(()); }
  }
}

In rustc this works fine, but rust-analyzer marks the (()) as failed to parse macro invocation. Note that if_chain! is a macro_rules macro, so this is an issue in macro expansion. The contents of the then { ... } branch is matched using the matcher then { $($then:tt)* } so even though this portion of the code is mostly untouched by the macro (it's supposed to expand to just let _ = drop(());) it is matched as a list of token trees, of which (()) is one of them. The let _ = is also part of the error, so it may be getting confused with the other matches in the macro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionE-has-instructionsIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions