rust-lang / rust-lang/rust-analyzer
Add return type very slow
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer 0.4.2655-standalone
rustc version: rustc 1.91.0-nightly (040a98af7 2025-08-20)
editor or extension: Vim9.1 coc-rust-analyzer
code snippet to reproduce:
file rust-analyzer/crates/ide-assists/src/handlers/foo.rs:
use syntax::{
AstToken
};
use crate::assist_context::{AssistContext, Assists};
pub(crate) fn foo(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
let x = split_curly("", 2)?;
Some(())
}
fn split_curly(text: &str, offset: usize) -> $0 {
Some("")
}
and add mod foo; to mod handlers rust-analyzer/crates/ide-assists/src/lib.rs
and add foo::foo to fn all() from rust-analyzer/crates/ide-assists/src/lib.rs
file coc-settings.json:
{
"rust-analyzer.updates.checkOnStartup": false,
"rust-analyzer.check.workspace": false,
"rust-analyzer.cachePriming.enable": false
}
Change work dir to rust-analyzer/crates/ide-assists
Run vim src/handlers/foo.rs
Click code-action at $0 very slow (used 100% CPU and experiencing memory growth)
And the memory used during startup is more than twice as much as before
It seems that there is no such issue on version 2025-08-25
@rustbot label +A-perf
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report from rust-analyzer/crates/ide-assists/src/handlers/foo.rs and the mod handlers/all() entries in rust-analyzer/crates/ide-assists/src/lib.rs, using the stated coc-rust-analyzer settings and Vim code action. Compare behavior with the reported 2025-08-25 version, then trace the add-return-type action. Done means the reproduction no longer causes excessive CPU or memory growth.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100