Skip to content
/ rust Public
forked from rust-lang/rust

Commit c997ea4

Browse files
authored
Rollup merge of rust-lang#158163 - xmakro:fix-variances-cycle-recovery-count, r=petrochenkov
Fix too-short variance slice in `variances_of` cycle recovery This changes the cycle-error fallback in `variances_of` to size the slice the same way the provider does in [`variance/solve.rs:117`](https://github.com/rust-lang/rust/blob/32ea3615cc027bcb8fd720c7511ffb484f6223a3/compiler/rustc_hir_analysis/src/variance/solve.rs#L117). This can otherwise ICE under the parallel frontend in `relate_args_with_variances` for items that inherit their generics from a parent (like a tuple struct constructor). See rust-lang#154560 (comment)
2 parents f117ef7 + c2c6cb4 commit c997ea4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

compiler/rustc_query_impl/src/handle_cycle_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub(crate) fn variances_of<'tcx>(
105105
err: Diag<'_>,
106106
) -> &'tcx [ty::Variance] {
107107
let _guar = err.delay_as_bug();
108-
let n = tcx.generics_of(def_id).own_params.len();
108+
let n = tcx.generics_of(def_id).count();
109109
tcx.arena.alloc_from_iter(iter::repeat_n(ty::Bivariant, n))
110110
}
111111

0 commit comments

Comments
 (0)