Description
rust-analyzer version: v0.3.1958 and others before (and also prelease)
rustc version: rustc 1.78.0 (9b00956e5 2024-04-29) and any other versions.
code snippet to reproduce:
use std::fmt::Display;
fn prints_it_impl_trait(input: impl Display) {
println!("You can print many things, including {input}");
}
fn prints_it_regular_generic<T: Display>(input: T) {
println!("You can print many things, including {input}");
}
fn main() {
prints_it_regular_generic::<u8>(100);
prints_it_impl_trait(100);
prints_it_impl_trait(100u8);
// prints_it_impl_trait::<u8>(100);
gives_higher(8, 10);
}
fn gives_higher(one: impl PartialOrd + Display, two: impl PartialOrd + Display) {
let higher = if one > two { one } else { two };
println!("{higher} is higher.");
}
When the above code is included in my project, Rust Analyzer crashes with a stack overflow error. Removing the gives_higher function resolves the issue.
Also commenting out the gives_higher function prevents the crash, suggesting the issue lies within the handling of impl Trait with PartialOrd + Display in this context. Within the 3 minutes it consistently restarts the server for all dependencies.
Logs:
thread 'Worker' has overflowed its stack
thread 'Worker' has overflowed its stack
thread 'Worker' has overflowed its stack
[Info - 11:12:05 AM] Connection to server got closed. Server will restart.
true
thread 'Worker' has overflowed its stack
[Info - 11:12:30 AM] Connection to server got closed. Server will restart.
true
.... and so on and then:
thread 'Worker' has overflowed its stack
[Error - 11:15:30 AM] The Rust Analyzer Language Server server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.