-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
Description
rustc version: rustc 1.91.0 (f8297e351 2025-10-28)
editor or extension: neovim (with latest r-a from Mason), helix (with r-a from rustup 1.91.0)
code snippet to reproduce:
#[derive(Debug, Clone)]
pub struct S(pub Vec<String>);
trait T {
fn id(&self) -> usize;
}
trait T2<U> {
fn foo(&self) -> usize;
}
impl T for S {
fn id(&self) -> usize {
self.0.len()
}
}
impl<U> T2<U> for S {
fn foo(&self) -> usize {
self.0.len()
}
}Invoking "Convert to named struct" results in:
#[derive(Debug, Clone)]
pub struct S { pub field1: Vec<String> }
trait T {
fn id(&self) -> usize;
}
trait T2<U> {
fn foo(&self) -> usize;
}
impl T for S {
fn id(&self) -> usize {
self..len()
}
}
impl<U> T2<U> for S {
fn foo(&self) -> usize {
self.field1.len()
}
}Note the self..len() in fn id().
The T2 is required to trigger this. In my real file it seems that only the very last use is correctly converted to self.field1 and all other uses in the file get the empty name like self..something().