Skip to content

alert expected Expr for expression whose path contains gen in assert_eq! #20153

Open
@eareimu

Description

@eareimu

rust-analyzer version: rust-analyzer version: 0.3.2519-standalone (6df1213 2025-06-29)

rustc version: rustc 1.90.0-nightly (667787527 2025-07-02)

editor or extension: VSCode

relevant settings: none

repository link (if public, optional): none

code snippet to reproduce:

  1. Change the package.edtion in Cargo.toml to "2021"

keyword gen is reserved beginning in the 2024 edition: https://doc.rust-lang.org/reference/keywords.html#r-lex.keywords.reserved.edition2024

  1. Try the follow code
fn gen() -> usize {
    0
}

assert_eq!(gen(), 0);

ra:

expected Expr rust-analyzer [macro-error](https://rust-analyzer.github.io/book/diagnostics.html#macro-error)

Any expression whose path contains gen will trigger this bug.

struct Foo;

impl Foo {
    fn gen() -> usize {
        1
    }
}
assert_eq!(Foo::gen(), 1);
mod gen {
    fn foo() -> usize {
        1
    }
}
assert_eq!(gen::foo(), 1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macromacro expansionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions