-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Closed
Copy link
Labels
Description
rust-analyzer version: 0.3.1377-standalone (daa0138 2023-01-21)
rustc version: rustc 1.66.1 (90743e729 2023-01-10)
If you use the rename functionality on the trait method, and one of the implementations of the trait has the field with the same name, the field name would also be renamed. Moreover, field is renamed only in the structure itself, but not in places where the field is accessed.
Minimal reproducible example
Use the following code and use the rename functionality (F2 in VS code) to change the method
name to something_else
.
trait Foo {
fn method(&self) -> u8;
}
struct Bar {
method: u8,
}
impl Foo for Bar {
fn method(&self) -> u8 {
self.method
}
}
Observed result
trait Foo {
fn something_else(&self) -> u8;
}
struct Bar {
something_else: u8, // <- Changed from `method` to `something_else.`
}
impl Foo for Bar {
fn something_else(&self) -> u8 {
self.method // <- Still attempts to access `method` field.
}
}
Expected result
trait Foo {
fn something_else(&self) -> u8;
}
struct Bar {
method: u8, // <- not renamed
}
impl Foo for Bar {
fn something_else(&self) -> u8 {
self.method
}
}