Skip to content

Incorrect handling of parameter names that are also macros in trait member generation #21070

@fennewald

Description

@fennewald

Using rust-analyzer 1.92.0-nightly (be0ade2 2025-10-11), and the following snippet:

trait Foo {
    fn foo(&self, vec: usize);
}

struct Bar;

impl Foo for Bar {}

Select Foo in the impl Foo for Bar, and choose "Implement missing members". rust-analyzer will produce this snippet:

impl Foo for Bar {
    fn foo(&self, std::vec: usize) {
        todo!()
    }
}

The argument named vec for foo was incorrectly inserted as std::vec.

Notably, this behavior does not occur for other, similar std::... names. I tested:

  • alloc
  • any
  • arch
  • array
  • box

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions