@@ -6,29 +6,29 @@ use rustc_hir as hir;
66use rustc_hir:: def:: { DefKind , Res } ;
77use rustc_middle:: ty:: Representability ;
88use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
9- use rustc_query_system:: query:: QueryInfo ;
9+ use rustc_query_system:: query:: CycleError ;
1010use rustc_query_system:: Value ;
1111use rustc_span:: def_id:: LocalDefId ;
1212use rustc_span:: { ErrorGuaranteed , Span } ;
1313
1414use std:: fmt:: Write ;
1515
1616impl < ' tcx > Value < TyCtxt < ' tcx > > for Ty < ' _ > {
17- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , _: & [ QueryInfo ] , guar : ErrorGuaranteed ) -> Self {
17+ fn from_cycle_error ( tcx : TyCtxt < ' tcx > , _: & CycleError , guar : ErrorGuaranteed ) -> Self {
1818 // SAFETY: This is never called when `Self` is not `Ty<'tcx>`.
1919 // FIXME: Represent the above fact in the trait system somehow.
2020 unsafe { std:: mem:: transmute :: < Ty < ' tcx > , Ty < ' _ > > ( Ty :: new_error ( tcx, guar) ) }
2121 }
2222}
2323
2424impl < ' tcx > Value < TyCtxt < ' tcx > > for Result < ty:: EarlyBinder < Ty < ' _ > > , CyclePlaceholder > {
25- fn from_cycle_error ( _tcx : TyCtxt < ' tcx > , _: & [ QueryInfo ] , guar : ErrorGuaranteed ) -> Self {
25+ fn from_cycle_error ( _tcx : TyCtxt < ' tcx > , _: & CycleError , guar : ErrorGuaranteed ) -> Self {
2626 Err ( CyclePlaceholder ( guar) )
2727 }
2828}
2929
3030impl < ' tcx > Value < TyCtxt < ' tcx > > for ty:: SymbolName < ' _ > {
31- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , _: & [ QueryInfo ] , _guar : ErrorGuaranteed ) -> Self {
31+ fn from_cycle_error ( tcx : TyCtxt < ' tcx > , _: & CycleError , _guar : ErrorGuaranteed ) -> Self {
3232 // SAFETY: This is never called when `Self` is not `SymbolName<'tcx>`.
3333 // FIXME: Represent the above fact in the trait system somehow.
3434 unsafe {
@@ -40,10 +40,14 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::SymbolName<'_> {
4040}
4141
4242impl < ' tcx > Value < TyCtxt < ' tcx > > for ty:: Binder < ' _ , ty:: FnSig < ' _ > > {
43- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , stack : & [ QueryInfo ] , guar : ErrorGuaranteed ) -> Self {
43+ fn from_cycle_error (
44+ tcx : TyCtxt < ' tcx > ,
45+ cycle_error : & CycleError ,
46+ guar : ErrorGuaranteed ,
47+ ) -> Self {
4448 let err = Ty :: new_error ( tcx, guar) ;
4549
46- let arity = if let Some ( frame) = stack . get ( 0 )
50+ let arity = if let Some ( frame) = cycle_error . cycle . get ( 0 )
4751 && frame. query . dep_kind == dep_kinds:: fn_sig
4852 && let Some ( def_id) = frame. query . def_id
4953 && let Some ( node) = tcx. hir ( ) . get_if_local ( def_id)
@@ -70,10 +74,14 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
7074}
7175
7276impl < ' tcx > Value < TyCtxt < ' tcx > > for Representability {
73- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , cycle : & [ QueryInfo ] , _guar : ErrorGuaranteed ) -> Self {
77+ fn from_cycle_error (
78+ tcx : TyCtxt < ' tcx > ,
79+ cycle_error : & CycleError ,
80+ _guar : ErrorGuaranteed ,
81+ ) -> Self {
7482 let mut item_and_field_ids = Vec :: new ( ) ;
7583 let mut representable_ids = FxHashSet :: default ( ) ;
76- for info in cycle {
84+ for info in & cycle_error . cycle {
7785 if info. query . dep_kind == dep_kinds:: representability
7886 && let Some ( field_id) = info. query . def_id
7987 && let Some ( field_id) = field_id. as_local ( )
@@ -87,7 +95,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
8795 item_and_field_ids. push ( ( item_id. expect_local ( ) , field_id) ) ;
8896 }
8997 }
90- for info in cycle {
98+ for info in & cycle_error . cycle {
9199 if info. query . dep_kind == dep_kinds:: representability_adt_ty
92100 && let Some ( def_id) = info. query . ty_adt_id
93101 && let Some ( def_id) = def_id. as_local ( )
@@ -102,19 +110,31 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
102110}
103111
104112impl < ' tcx > Value < TyCtxt < ' tcx > > for ty:: EarlyBinder < Ty < ' _ > > {
105- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , cycle : & [ QueryInfo ] , guar : ErrorGuaranteed ) -> Self {
106- ty:: EarlyBinder :: bind ( Ty :: from_cycle_error ( tcx, cycle, guar) )
113+ fn from_cycle_error (
114+ tcx : TyCtxt < ' tcx > ,
115+ cycle_error : & CycleError ,
116+ guar : ErrorGuaranteed ,
117+ ) -> Self {
118+ ty:: EarlyBinder :: bind ( Ty :: from_cycle_error ( tcx, cycle_error, guar) )
107119 }
108120}
109121
110122impl < ' tcx > Value < TyCtxt < ' tcx > > for ty:: EarlyBinder < ty:: Binder < ' _ , ty:: FnSig < ' _ > > > {
111- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , cycle : & [ QueryInfo ] , guar : ErrorGuaranteed ) -> Self {
112- ty:: EarlyBinder :: bind ( ty:: Binder :: from_cycle_error ( tcx, cycle, guar) )
123+ fn from_cycle_error (
124+ tcx : TyCtxt < ' tcx > ,
125+ cycle_error : & CycleError ,
126+ guar : ErrorGuaranteed ,
127+ ) -> Self {
128+ ty:: EarlyBinder :: bind ( ty:: Binder :: from_cycle_error ( tcx, cycle_error, guar) )
113129 }
114130}
115131
116132impl < ' tcx , T > Value < TyCtxt < ' tcx > > for Result < T , & ' _ ty:: layout:: LayoutError < ' _ > > {
117- fn from_cycle_error ( _tcx : TyCtxt < ' tcx > , _cycle : & [ QueryInfo ] , guar : ErrorGuaranteed ) -> Self {
133+ fn from_cycle_error (
134+ _tcx : TyCtxt < ' tcx > ,
135+ _cycle_error : & CycleError ,
136+ guar : ErrorGuaranteed ,
137+ ) -> Self {
118138 // tcx.arena.alloc cannot be used because we are not allowed to use &'tcx LayoutError under
119139 // min_specialization. Since this is an error path anyways, leaking doesn't matter (and really,
120140 // tcx.arena.alloc is pretty much equal to leaking).
0 commit comments