@@ -8,12 +8,12 @@ use rustc_errors::codes::*;
88use rustc_errors:: { Applicability , Diag , MultiSpan , pluralize, struct_span_code_err} ;
99use rustc_hir as hir;
1010use rustc_hir:: def:: { DefKind , Res } ;
11+ use rustc_middle:: bug;
1112use rustc_middle:: queries:: { QueryVTables , TaggedQueryKey } ;
1213use rustc_middle:: query:: CycleError ;
1314use rustc_middle:: query:: erase:: erase_val;
1415use rustc_middle:: ty:: layout:: LayoutError ;
1516use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
16- use rustc_middle:: { bug, span_bug} ;
1717use rustc_span:: def_id:: { DefId , LocalDefId } ;
1818use rustc_span:: { ErrorGuaranteed , Span } ;
1919
@@ -31,9 +31,9 @@ pub(crate) fn specialize_query_vtables<'tcx>(vtables: &mut QueryVTables<'tcx>) {
3131 vtables. check_representability_adt_ty . value_from_cycle_error =
3232 |tcx, _, cycle, _err| check_representability ( tcx, cycle) ;
3333
34- vtables. variances_of . value_from_cycle_error = |tcx, _ , cycle , err| {
34+ vtables. variances_of . value_from_cycle_error = |tcx, key , _ , err| {
3535 let _guar = err. delay_as_bug ( ) ;
36- erase_val ( variances_of ( tcx, cycle ) )
36+ erase_val ( variances_of ( tcx, key ) )
3737 } ;
3838
3939 vtables. layout_of . value_from_cycle_error = |tcx, _, cycle, err| {
@@ -103,26 +103,9 @@ fn check_representability<'tcx>(tcx: TyCtxt<'tcx>, cycle_error: CycleError<'tcx>
103103 guar. raise_fatal ( )
104104}
105105
106- fn variances_of < ' tcx > ( tcx : TyCtxt < ' tcx > , cycle_error : CycleError < ' tcx > ) -> & ' tcx [ ty:: Variance ] {
107- search_for_cycle_permutation (
108- & cycle_error. cycle ,
109- |cycle| {
110- if let Some ( frame) = cycle. get ( 0 )
111- && let TaggedQueryKey :: variances_of( def_id) = frame. node . tagged_key
112- {
113- let n = tcx. generics_of ( def_id) . own_params . len ( ) ;
114- ControlFlow :: Break ( tcx. arena . alloc_from_iter ( iter:: repeat_n ( ty:: Bivariant , n) ) )
115- } else {
116- ControlFlow :: Continue ( ( ) )
117- }
118- } ,
119- || {
120- span_bug ! (
121- cycle_error. usage. as_ref( ) . unwrap( ) . span,
122- "only `variances_of` returns `&[ty::Variance]`"
123- )
124- } ,
125- )
106+ fn variances_of < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> & ' tcx [ ty:: Variance ] {
107+ let n = tcx. generics_of ( def_id) . own_params . len ( ) ;
108+ tcx. arena . alloc_from_iter ( iter:: repeat_n ( ty:: Bivariant , n) )
126109}
127110
128111// Take a cycle of `Q` and try `try_cycle` on every permutation, falling back to `otherwise`.
0 commit comments