-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed as duplicate of#20975
Labels
C-bugCategory: bugCategory: bug
Description
Rust analyzer panics when renaming a method that is called inside tokio select! macro. The method in question is called run.
rust-analyzer version: 0.3.2683-standalone
rustc version: rustc 1.91.0 (f8297e351 2025-10-28)
editor or extension: Zed editor
relevant settings: pretty stock setup
repository link (if public, optional): not public yet, but may become at some point
code snippet to reproduce:
This code snippet is not isolated yet. I tried to create analogical snipped without dependencies, but there renaming worked fine.
Click to reveal
pub async fn run(&mut self) -> Option<Out> {
let now = Instant::now();
let closest = self
.tasks
.iter()
.filter(|task| task.enabled()) // this logic is a tiny bit problematic, because some task may become enabled while we are waiting for another one
.min_by(|t1, t2| t1.next_run(now).cmp(&t2.next_run(now)));
let Some(task) = closest else { return None };
let id = task.id();
// careful, here we are taking mut access to the set entry. we must not change it's Eq and Hash identity (currently it's the function id)
if let Some((_ix, task)) = self.tasks.get_full_mut2(&id) {
let target_time = task.next_run(now);
tokio::time::sleep_until(target_time.into()).await;
if task.enabled() {
let out = task.run(&self.registry).await;
return Some(out);
}
}
None
}
pub async fn start(mut self, mut message_rx: SchedulerRx) {
tokio::task::spawn(async move {
select! {
Some(msg) = message_rx.recv() => {
}
out = self.run() => {
}
}
});
}Calls to that run method also appeared in tests under #[tokio::test], but commenting them out there didn't change anything. Commenting out the call to run inside select! on the other hand, made renaming work.
Rust Analyzer Logs
2025-11-20T13:49:10.00565091+02:00 WARN overly long loop turn took 139.758266ms (event handling took 139.740666ms): PrimeCaches(End { cancelled: false })
thread 'Worker5' (19039) panicked at crates/hir-ty/src/next_solver/normalize.rs:48:5:
assertion `left == right` failed
left: [Goal { param_env: ParamEnv { clauses: [] }, predicate: Binder { value: AliasRelate(Alias(Projection, AliasTy { args: [CoroutineClosure(InternedCoroutineId(InternedCoroutineId { loc: InternedCoroutine(FunctionId(FunctionId(364b0)), Idx::<Expr>(2)) }), [i8, Binder { value: fn((), ()) -> ((), ()), bound_vars: [] }, (), Binder { value: fn(), bound_vars: [Region(BrEnv)] }]), (), ()], def_id: TypeAliasId("System"), .. }), Equate, ?24t), bound_vars: [] } }]
right: []
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
4: hir_ty::infer::unify::InferenceTable::normalize_associated_types_in
5: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
6: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
7: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
8: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
9: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
10: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
11: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
12: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
13: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
14: hir_ty::infer::infer_query
15: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
16: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold_with_retry
17: std::thread::local::LocalKey<T>::with
18: <DB as hir_ty::db::HirDatabase>::infer::infer_shim
19: hir::semantics::SemanticsImpl::analyze_impl
20: hir::semantics::SemanticsImpl::resolve_method_call_fallback
21: ide_db::defs::NameRefClass::classify
22: ide_db::search::FindUsages::found_name_ref
23: ide_db::search::FindUsages::search
24: ide_db::search::FindUsages::at_least_one
25: ide_assists::handlers::inline_call::inline_into_callers
26: ide_assists::assists
27: salsa::cancelled::Cancelled::catch
28: std::thread::local::LocalKey<T>::with
29: ide::Analysis::assists_with_fixes
30: rust_analyzer::handlers::request::handle_code_action
31: core::ops::function::FnOnce::call_once{{vtable.shim}}
32: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stacktrace:
0: infer_shim(Id(364b0)) -> (R22, Durability::LOW)
at crates/hir-ty/src/db.rs:28
additional context:
0:
version: 0.3.2683-standalone
request: textDocument/codeAction CodeActionParams {
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/t97/rust/mine/act/src/scheduler.rs",
query: None,
fragment: None,
},
},
range: Range {
start: Position {
line: 63,
character: 17,
},
end: Position {
line: 63,
character: 20,
},
},
context: CodeActionContext {
diagnostics: [],
only: Some(
[
CodeActionKind(
"",
),
CodeActionKind(
"quickfix",
),
CodeActionKind(
"refactor",
),
CodeActionKind(
"refactor.extract",
),
CodeActionKind(
"refactor.inline",
),
CodeActionKind(
"refactor.rewrite",
),
],
),
trigger_kind: None,
},
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: PartialResultParams {
partial_result_token: None,
},
}
thread 'Worker7' (19041) panicked at crates/hir-ty/src/next_solver/normalize.rs:48:5:
assertion `left == right` failed
left: [Goal { param_env: ParamEnv { clauses: [] }, predicate: Binder { value: AliasRelate(Alias(Projection, AliasTy { args: [CoroutineClosure(InternedCoroutineId(InternedCoroutineId { loc: InternedCoroutine(FunctionId(FunctionId(364b0)), Idx::<Expr>(2)) }), [i8, Binder { value: fn((), ()) -> ((), ()), bound_vars: [] }, (), Binder { value: fn(), bound_vars: [Region(BrEnv)] }]), (), ()], def_id: TypeAliasId("System"), .. }), Equate, ?24t), bound_vars: [] } }]
right: []
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
4: hir_ty::infer::unify::InferenceTable::normalize_associated_types_in
5: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
6: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
7: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
8: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
9: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
10: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
11: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
12: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
13: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
14: hir_ty::infer::infer_query
15: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
16: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold_with_retry
17: std::thread::local::LocalKey<T>::with
18: <DB as hir_ty::db::HirDatabase>::infer::infer_shim
19: hir::semantics::SemanticsImpl::analyze_impl
20: hir::semantics::SemanticsImpl::resolve_method_call_fallback
21: ide_db::defs::NameRefClass::classify
22: ide_db::search::FindUsages::found_name_ref
23: ide_db::search::FindUsages::search
24: ide_db::search::FindUsages::at_least_one
25: ide_assists::handlers::inline_call::inline_into_callers
26: ide_assists::assists
27: salsa::cancelled::Cancelled::catch
28: std::thread::local::LocalKey<T>::with
29: ide::Analysis::assists_with_fixes
30: rust_analyzer::handlers::request::handle_code_action
31: core::ops::function::FnOnce::call_once{{vtable.shim}}
32: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stacktrace:
0: infer_shim(Id(364b0)) -> (R55, Durability::LOW)
at crates/hir-ty/src/db.rs:28
additional context:
0:
version: 0.3.2683-standalone
request: textDocument/codeAction CodeActionParams {
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/t97/rust/mine/act/src/scheduler.rs",
query: None,
fragment: None,
},
},
range: Range {
start: Position {
line: 63,
character: 17,
},
end: Position {
line: 63,
character: 20,
},
},
context: CodeActionContext {
diagnostics: [],
only: Some(
[
CodeActionKind(
"",
),
CodeActionKind(
"quickfix",
),
CodeActionKind(
"refactor",
),
CodeActionKind(
"refactor.extract",
),
CodeActionKind(
"refactor.inline",
),
CodeActionKind(
"refactor.rewrite",
),
],
),
trigger_kind: None,
},
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: PartialResultParams {
partial_result_token: None,
},
}
thread 'Worker7' (19041) panicked at crates/hir-ty/src/next_solver/normalize.rs:48:5:
assertion `left == right` failed
left: [Goal { param_env: ParamEnv { clauses: [] }, predicate: Binder { value: AliasRelate(Alias(Projection, AliasTy { args: [CoroutineClosure(InternedCoroutineId(InternedCoroutineId { loc: InternedCoroutine(FunctionId(FunctionId(364b0)), Idx::<Expr>(2)) }), [i8, Binder { value: fn((), ()) -> ((), ()), bound_vars: [] }, (), Binder { value: fn(), bound_vars: [Region(BrEnv)] }]), (), ()], def_id: TypeAliasId("System"), .. }), Equate, ?24t), bound_vars: [] } }]
right: []
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::assert_failed_inner
3: core::panicking::assert_failed
4: hir_ty::infer::unify::InferenceTable::normalize_associated_types_in
5: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
6: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
7: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
8: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
9: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
10: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
11: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
12: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
13: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
14: hir_ty::infer::infer_query
15: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
16: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold_with_retry
17: std::thread::local::LocalKey<T>::with
18: hir::semantics::SemanticsImpl::analyze_impl
19: hir::semantics::SemanticsImpl::resolve_method_call_fallback
20: ide_db::defs::NameRefClass::classify
21: ide_db::search::FindUsages::found_name_ref
22: ide_db::search::FindUsages::search
23: ide_db::search::FindUsages::all
24: ide_db::rename::rename_reference
25: ide_db::rename::<impl ide_db::defs::Definition>::rename
26: <alloc::vec::into_iter::IntoIter<T,A> as core::iter::traits::iterator::Iterator>::try_fold
27: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
28: ide::rename::rename
29: salsa::cancelled::Cancelled::catch
30: std::thread::local::LocalKey<T>::with
31: ide::Analysis::rename
32: rust_analyzer::handlers::request::handle_rename
33: core::ops::function::FnOnce::call_once{{vtable.shim}}
34: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stacktrace:
0: infer_shim(Id(364b0)) -> (R55, Durability::LOW)
at crates/hir-ty/src/db.rs:28
additional context:
0:
version: 0.3.2683-standalone
request: textDocument/rename RenameParams {
text_document_position: TextDocumentPositionParams {
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/home/t97/rust/mine/act/src/scheduler.rs",
query: None,
fragment: None,
},
},
position: Position {
line: 63,
character: 17,
},
},
new_name: "next_task",
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
}

Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug