Closed
Description
When I hover over a broken derive macro in the RustPython
codebase, rust-analyzer
reports the errors Request textDocument/semanticTokens/full failed
and Request textDocument/inlayHint failed
. In the rust-analyzer
output logs, I see that the request handler panics with the message already borrowed: BorrowMutError
.
This error is triggered on this particular line.
Please let me know if I can provide any other details. I'd love to help contribute to this project.
Here are the full output logs
Panic context:
>
version: 0.3.1186-standalone (e8e598f64 2022-08-28)
request: textDocument/codeAction CodeActionParams {
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/Users/vsong/Downloads/fun/RustPython/wasm/lib/src/js_module.rs",
query: None,
fragment: None,
},
},
range: Range {
start: Position {
line: 557,
character: 13,
},
end: Position {
line: 557,
character: 22,
},
},
context: CodeActionContext {
diagnostics: [
Diagnostic {
range: Range {
start: Position {
line: 557,
character: 13,
},
end: Position {
line: 557,
character: 22,
},
},
severity: Some(
Error,
),
code: Some(
String(
"E0277",
),
),
code_description: Some(
CodeDescription {
href: Url {
scheme: "https",
cannot_be_a_base: false,
username: "",
password: None,
host: Some(
Domain(
"doc.rust-lang.org",
),
),
port: None,
path: "/error-index.html",
query: None,
fragment: Some(
"E0277",
),
},
},
),
source: Some(
"rustc",
),
message: "`std::cell::Cell<std::option::Option<rustpython_vm::PyObjectRef>>` cannot be shared between threads safely\nwithin `js_module::_js::AwaitPromise`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<std::option::Option<rustpython_vm::PyObjectRef>>`",
related_information: Some(
[
DiagnosticRelatedInformation {
location: Location {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/Users/vsong/Downloads/fun/RustPython/wasm/lib/src/js_module.rs",
query: None,
fragment: None,
},
range: Range {
start: Position {
line: 558,
character: 11,
},
end: Position {
line: 558,
character: 23,
},
},
},
message: "required because it appears within the type `js_module::_js::AwaitPromise`",
},
DiagnosticRelatedInformation {
location: Location {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/Users/vsong/Downloads/fun/RustPython/vm/src/object/payload.rs",
query: None,
fragment: None,
},
range: Range {
start: Position {
line: 17,
character: 39,
},
end: Position {
line: 17,
character: 60,
},
},
},
message: "required by a bound in `rustpython_vm::PyPayload`",
},
],
),
tags: None,
data: None,
},
],
only: Some(
[
CodeActionKind(
"quickfix",
),
],
),
},
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: PartialResultParams {
partial_result_token: None,
},
}
thread 'Worker' panicked at 'already borrowed: BorrowMutError', crates/hir-ty/src/lower.rs:369:36
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: hir_ty::lower::TyLoweringContext::lower_ty_ext
4: hir_ty::lower::TyLoweringContext::substs_from_path_segment
5: hir_ty::lower::TyLoweringContext::lower_path_inner
6: hir_ty::lower::TyLoweringContext::lower_partly_resolved_path
7: hir_ty::lower::TyLoweringContext::lower_ty_ext
8: hir_ty::lower::ty_query
9: salsa::runtime::Runtime::execute_query_implementation
10: salsa::derived::slot::Slot<Q,MP>::read_upgrade
11: salsa::derived::slot::Slot<Q,MP>::read
12: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
13: salsa::QueryTable<Q>::get
14: <DB as hir_ty::db::HirDatabase>::ty
15: hir_ty::lower::TyLoweringContext::lower_path_inner
16: hir_ty::lower::TyLoweringContext::lower_partly_resolved_path
17: hir_ty::lower::TyLoweringContext::lower_ty_ext
18: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
19: hir_ty::lower::callable_item_sig
20: salsa::runtime::Runtime::execute_query_implementation
21: salsa::derived::slot::Slot<Q,MP>::read_upgrade
22: salsa::derived::slot::Slot<Q,MP>::read
23: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
24: salsa::QueryTable<Q>::get
25: <DB as hir_ty::db::HirDatabase>::callable_item_signature
26: hir_ty::infer::unify::InferenceTable::run_in_snapshot
27: hir_ty::method_resolution::is_valid_candidate
28: hir_ty::method_resolution::iterate_inherent_methods::impls_for_self_ty
29: hir_ty::method_resolution::iterate_inherent_methods
30: hir_ty::method_resolution::iterate_method_candidates_by_receiver
31: hir_ty::method_resolution::iterate_method_candidates_dyn
32: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
33: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr
34: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
35: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
36: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
37: hir_ty::infer::infer_query
38: salsa::runtime::Runtime::execute_query_implementation
39: salsa::derived::slot::Slot<Q,MP>::read_upgrade
40: salsa::derived::slot::Slot<Q,MP>::read
41: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
42: salsa::QueryTable<Q>::get
43: <DB as hir_ty::db::HirDatabase>::infer_query
44: hir_ty::db::infer_wait
45: hir::DefWithBody::diagnostics
46: hir::ModuleDef::diagnostics
47: hir::Module::diagnostics
48: ide_diagnostics::diagnostics
49: std::panicking::try
50: ide::Analysis::assists_with_fixes
51: rust_analyzer::handlers::handle_code_action
52: std::panicking::try
53: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
rust-analyzer version: 0.3.1186-standalone (e8e598f64 2022-08-28)
rustc version: rustc 1.63.0 (4b91a6ea7 2022-08-08)
relevant settings: For VSCode, "rust-analyzer.checkOnSave.command": "clippy"
is set. The version of VSCode I'm currently using is 1.70.2
.