mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #140358 - Zoxc:variance-cycle, r=oli-obk
Use `search_for_cycle_permutation` to look for `variances_of` This uses `search_for_cycle_permutation` to look for `variances_of` in case `variances_of` is not the first query in the cycle. This may fix https://github.com/rust-lang/rust/issues/124423 and https://github.com/rust-lang/rust/issues/127971. r? `@oli-obk`
This commit is contained in:
@@ -138,18 +138,26 @@ fn from_cycle_error(
|
||||
cycle_error: &CycleError,
|
||||
_guar: ErrorGuaranteed,
|
||||
) -> Self {
|
||||
if let Some(frame) = cycle_error.cycle.get(0)
|
||||
&& frame.query.dep_kind == dep_kinds::variances_of
|
||||
&& let Some(def_id) = frame.query.def_id
|
||||
{
|
||||
let n = tcx.generics_of(def_id).own_params.len();
|
||||
vec![ty::Bivariant; n].leak()
|
||||
} else {
|
||||
span_bug!(
|
||||
cycle_error.usage.as_ref().unwrap().0,
|
||||
"only `variances_of` returns `&[ty::Variance]`"
|
||||
);
|
||||
}
|
||||
search_for_cycle_permutation(
|
||||
&cycle_error.cycle,
|
||||
|cycle| {
|
||||
if let Some(frame) = cycle.get(0)
|
||||
&& frame.query.dep_kind == dep_kinds::variances_of
|
||||
&& let Some(def_id) = frame.query.def_id
|
||||
{
|
||||
let n = tcx.generics_of(def_id).own_params.len();
|
||||
ControlFlow::Break(vec![ty::Bivariant; n].leak())
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
},
|
||||
|| {
|
||||
span_bug!(
|
||||
cycle_error.usage.as_ref().unwrap().0,
|
||||
"only `variances_of` returns `&[ty::Variance]`"
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user