Skip to content

macro ident matcher + field notation = "missing match arm" #12107

Closed
@digama0

Description

@digama0
pub struct Foo {
    field: (),
}
pub fn test(x: (Foo,)) {
    macro_rules! mac {
        ($field:ident) => {
            match x.0.$field {
                () => {}
            }
        };
    }
    mac!(field); // missing match arm
}
fn main() {}

Some observations:

  • Using x.0 .$field instead of x.0.$field makes the error go away, which suggests that 0. is getting parsed as a float literal (I have seen this issue before enough times to know not to write x.0.0, but some cursory rustc testing suggests that this isn't actually a problem anymore? Or maybe it was an RA problem all along...)
  • Using x.0.field works fine

rust-analyzer version: 241b9f9ae 2022-04-28 nightly

rustc version: rustc 1.62.0-nightly (69a5d2481 2022-04-27)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions