Skip to content

Commit b172932

Browse files
committed
Construct FnSig from a CycleError a bit differently for multiple threads
Fixes #142053
1 parent 81a964c commit b172932

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compiler/rustc_middle/src/values.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::fmt::Write;
33
use std::ops::ControlFlow;
44

55
use rustc_data_structures::fx::FxHashSet;
6+
use rustc_data_structures::sync;
67
use rustc_errors::codes::*;
78
use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err};
89
use rustc_hir as hir;
@@ -50,9 +51,14 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
5051
) -> Self {
5152
let err = Ty::new_error(tcx, guar);
5253

53-
let arity = if let Some(frame) = cycle_error.cycle.get(0)
54-
&& frame.query.dep_kind == dep_kinds::fn_sig
55-
&& let Some(def_id) = frame.query.def_id
54+
let frame = if sync::is_dyn_thread_safe() {
55+
cycle_error.usage.as_ref().map(|(_, query)| query)
56+
} else {
57+
cycle_error.cycle.first().map(|info| &info.query)
58+
};
59+
let arity = if let Some(frame) = frame
60+
&& frame.dep_kind == dep_kinds::fn_sig
61+
&& let Some(def_id) = frame.def_id
5662
&& let Some(node) = tcx.hir_get_if_local(def_id)
5763
&& let Some(sig) = node.fn_sig()
5864
{

0 commit comments

Comments
 (0)