Skip to content

expected _, found () in format_args macro #15309

@y21

Description

@y21

This code:

fn main() {
  format_args!(
      "{}",
      match "" {
          "" => 1,
          _ => panic!(""),
      },
  );
}

has r-a report the error "expected i32, found ()" (the i32 is the type in the match arm, changing the arm to e.g. "" changes the error to "expected &str, found ()"):

image

But it compiles just fine.

Possibly a duplicate of #15082? I don't know what that issue implies

rust-analyzer version: rust-analyzer version: 0.3.1591-standalone

rustc version: rustc 1.73.0-nightly (da6b55cc5 2023-07-17)

relevant settings: nothing particularly worthy of mention I think

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionA-nameresname, path and module resolutionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions