Hi everyone,
I'm encountering an issue where rust-analyzer consistently crashes on a valid .rs file. The code compiles without any errors, but rust-analyzer panics with the following crash report:
2026-07-27T19:16:10.905415502+01:00 WARN overly long loop turn took 146.327192ms:
(event handling took 112.931722ms): PrimeCaches(End { cancelled: false })
(cancellation took None)
(garbage collection took Some(33.370289ms))
thread 'Worker7' (13760) panicked at crates/hir-ty/src/next_solver/predicate.rs:606:9:
`&'^0 [u8]: Copy` has escaping bound vars, so it cannot be wrapped in a dummy binder.
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <hir_ty::next_solver::infer::InferCtxt>::type_is_copy_modulo_regions
3: <hir_ty::mir::lower::MirLowerCtx>::pop_drop_scope_internal
4: <hir_ty::mir::lower::MirLowerCtx>::pop_drop_scope_assert_finished
5: <hir_ty::mir::lower::_::mir_body_for_closure_query_Configuration_ as salsa::function::Configuration>::execute
6: <salsa::function::IngredientImpl<hir_ty::mir::lower::_::mir_body_for_closure_query_Configuration_>>::execute
7: hir_ty::mir::lower::mir_body_for_closure_query
8: <ide_db::RootDatabase as hir_ty::db::HirDatabase>::mir_body_for_closure
9: hir_ty::mir::borrowck::all_mir_bodies::for_closure::<<<hir_ty::InferBodyId>::borrowck::_::borrowck_query_Configuration_ as salsa::function::Configuration>::execute::inner_::{closure#0}, <<hir_ty::InferBodyId>::borrowck::_::borrowck_query_Configuration_ as salsa::function::Configuration>::execute::inner_::{closure#1}>
10: <<hir_ty::InferBodyId>::borrowck::_::borrowck_query_Configuration_ as salsa::function::Configuration>::execute
11: <salsa::function::IngredientImpl<<hir_ty::InferBodyId>::borrowck::_::borrowck_query_Configuration_>>::execute
12: <hir_ty::InferBodyId>::borrowck
13: <hir::DefWithBody>::diagnostics
14: <hir::Module>::diagnostics
15: ide_diagnostics::semantic_diagnostics
16: ide_diagnostics::full_diagnostics
17: <ide::Analysis>::full_diagnostics
18: rust_analyzer::handlers::request::handle_document_diagnostics
19: <<stdx::thread::pool::Pool>::spawn<<rust_analyzer::task_pool::TaskPool<rust_analyzer::main_loop::Task>>::spawn<<rust_analyzer::handlers::dispatch::RequestDispatcher>::on_with_thread_intent<false, false, gen_lsp_types::generated::requests::DocumentDiagnosticRequest>::{closure#0}>::{closure#0}>::{closure#0} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stacktrace:
0: mir_body_for_closure_query(Id(12e80c)) -> (R25450, Durability::LOW)
at crates/hir-ty/src/mir/lower.rs:2111
1: borrowck_query(Id(1282c4)) -> (R25450, Durability::LOW)
at crates/hir-ty/src/mir/borrowck.rs:153
additional context:
0:
version: 0.3.2989-standalone
request: textDocument/diagnostic DocumentDiagnosticParams {
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/xxxx/projects/xxxxx/code.rs",
query: None,
fragment: None,
},
},
identifier: Some(
"rust-analyzer",
),
previous_result_id: Some(
"rust-analyzer",
),
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: PartialResultParams {
partial_result_token: None,
},
}
[Error - 7:16:11 PM] Request textDocument/diagnostic failed.
Message: request handler panicked: `&'^0 [u8]: Copy` has escaping bound vars, so it cannot be wrapped in a dummy binder.
Code: -32603
[Error - 7:16:11 PM] Document pull failed for text document file:///home/xxxx/projects/xxxxx/code.rs
Message: request handler panicked: `&'^0 [u8]: Copy` has escaping bound vars, so it cannot be wrapped in a dummy binder.
Code: -32603
2026-07-27T19:16:11.974286958+01:00 WARN Propagating panic for cycle head that panicked in an earlier execution in that revision
By systematically isolating the code, I located the source of the issue. It appears that this version of rust-analyzer fails to process this particular code snippet :
acceptor_builder.set_alpn_select_callback(|_, client_protos| {
match pingora::tls::ssl::select_next_proto(
b"\x02h2\x08http/1.1",
client_protos,
) {
Some(proto) => Ok(proto),
None => Err(pingora::tls::ssl::AlpnError::NOACK),
}
});
I wrote this code to replicate the behavior causing the bug :
#[derive(Debug)]
pub struct CoreError;
impl CoreError {
pub fn err_certificate_error(_msg: String) -> Self {
CoreError
}
}
pub enum AlpnError {
NOACK,
}
pub struct SslMethod;
impl SslMethod {
pub fn tls() -> Self {
SslMethod
}
}
pub struct SslError;
impl std::fmt::Display for SslError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ssl error")
}
}
pub struct SslAcceptor;
impl SslAcceptor {
pub fn mozilla_intermediate(_method: SslMethod) -> Result<Self, SslError> {
Ok(SslAcceptor)
}
pub fn set_alpn_select_callback<F>(&mut self, _callback: F)
where
F: for<'a> Fn(&mut (), &'a [u8]) -> Result<&'a [u8], AlpnError> + Send + Sync + 'static,
{
}
}
pub fn select_next_proto<'a>(_server: &[u8], client: &'a [u8]) -> Option<&'a [u8]> {
Some(client)
}
// Simulation
pub fn main() {
let mut acceptor_builder = SslAcceptor::mozilla_intermediate(SslMethod::tls())
.map_err(|e| CoreError::err_certificate_error(e.to_string()))
.unwrap();
acceptor_builder.set_alpn_select_callback(|_, client_protos| {
match select_next_proto(b"\x02h2\x08http/1.1", client_protos) {
Some(proto) => Ok(proto),
None => Err(AlpnError::NOACK),
}
});
}
Rust version :
rustc : 1.97.1
cargo : 1.97.1
(IDE VSCODE) :
rust-analyzer : 0.3.2989
Does anyone have any insight into what might be causing this?
Thanks in advance for your help.