-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Closed
Copy link
Labels
A-chalkchalk related issuechalk related issueA-perfperformance issuesperformance issuesC-bugCategory: bugCategory: bug
Description
In my code base I've noticed significant performance regressions of r-a in certain methods after adding a generic associated type (GAT) to a trait. I've reduced the issue to the following. We need:
- A trait with
Derefas a super-trait - A GAT which needs to implement the trait itself
- A method generic over this trait
If any of these is not present, autocomplete works fine, but if all three are present, autocomplete is unusably slow in the generic method, even for other parameters.
rust-analyzer version: rust-analyzer version: 0.3.2362-standalone
rustc version: rustc 1.85.1 (4eb161250 2025-03-15)
editor or extension: VSCode on NixOs-unstable
relevant settings: None
code snippet to reproduce:
use std::{marker::PhantomData, ops::Deref};
trait Foo<T>: Deref<Target = u8> {
type FooKind<E>: Foo<E>;
fn foo(&mut self) {
todo!()
}
}
fn slow_autocomplete(f: &mut impl Foo<u8>, a: u8) {
a. // <-- Cursor here
}
fn fast_autocomplete(a: u8) {
a. // <-- Cursor here
}
struct Frob<T>(PhantomData<T>);
impl<T> Deref for Frob<T> {
type Target = u8;
fn deref(&self) -> &Self::Target {
todo!()
}
}
impl<T> Foo<T> for Frob<T> {
type FooKind<E> = Frob<E>;
}
fn autocomplete_concrete_foo(f: Frob<u8>) {
f. // <-- Cursor here
}Here is a GIF of the slow autocomplete.
Metadata
Metadata
Assignees
Labels
A-chalkchalk related issuechalk related issueA-perfperformance issuesperformance issuesC-bugCategory: bugCategory: bug
