@@ -8,20 +8,28 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
88use rustc_query_system:: query:: QueryInfo ;
99use rustc_query_system:: Value ;
1010use rustc_span:: def_id:: LocalDefId ;
11- use rustc_span:: Span ;
11+ use rustc_span:: { ErrorGuaranteed , Span } ;
1212
1313use std:: fmt:: Write ;
1414
1515impl < ' tcx > Value < TyCtxt < ' tcx > , DepKind > for Ty < ' _ > {
16- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , _: & [ QueryInfo < DepKind > ] ) -> Self {
16+ fn from_cycle_error (
17+ tcx : TyCtxt < ' tcx > ,
18+ _: & [ QueryInfo < DepKind > ] ,
19+ guar : ErrorGuaranteed ,
20+ ) -> Self {
1721 // SAFETY: This is never called when `Self` is not `Ty<'tcx>`.
1822 // FIXME: Represent the above fact in the trait system somehow.
19- unsafe { std:: mem:: transmute :: < Ty < ' tcx > , Ty < ' _ > > ( Ty :: new_misc_error ( tcx) ) }
23+ unsafe { std:: mem:: transmute :: < Ty < ' tcx > , Ty < ' _ > > ( Ty :: new_error ( tcx, guar ) ) }
2024 }
2125}
2226
2327impl < ' tcx > Value < TyCtxt < ' tcx > , DepKind > for ty:: SymbolName < ' _ > {
24- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , _: & [ QueryInfo < DepKind > ] ) -> Self {
28+ fn from_cycle_error (
29+ tcx : TyCtxt < ' tcx > ,
30+ _: & [ QueryInfo < DepKind > ] ,
31+ _guar : ErrorGuaranteed ,
32+ ) -> Self {
2533 // SAFETY: This is never called when `Self` is not `SymbolName<'tcx>`.
2634 // FIXME: Represent the above fact in the trait system somehow.
2735 unsafe {
@@ -33,8 +41,12 @@ impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for ty::SymbolName<'_> {
3341}
3442
3543impl < ' tcx > Value < TyCtxt < ' tcx > , DepKind > for ty:: Binder < ' _ , ty:: FnSig < ' _ > > {
36- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , stack : & [ QueryInfo < DepKind > ] ) -> Self {
37- let err = Ty :: new_misc_error ( tcx) ;
44+ fn from_cycle_error (
45+ tcx : TyCtxt < ' tcx > ,
46+ stack : & [ QueryInfo < DepKind > ] ,
47+ guar : ErrorGuaranteed ,
48+ ) -> Self {
49+ let err = Ty :: new_error ( tcx, guar) ;
3850
3951 let arity = if let Some ( frame) = stack. get ( 0 )
4052 && frame. query . dep_kind == DepKind :: fn_sig
@@ -63,7 +75,11 @@ impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for ty::Binder<'_, ty::FnSig<'_>> {
6375}
6476
6577impl < ' tcx > Value < TyCtxt < ' tcx > , DepKind > for Representability {
66- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , cycle : & [ QueryInfo < DepKind > ] ) -> Self {
78+ fn from_cycle_error (
79+ tcx : TyCtxt < ' tcx > ,
80+ cycle : & [ QueryInfo < DepKind > ] ,
81+ _guar : ErrorGuaranteed ,
82+ ) -> Self {
6783 let mut item_and_field_ids = Vec :: new ( ) ;
6884 let mut representable_ids = FxHashSet :: default ( ) ;
6985 for info in cycle {
@@ -95,22 +111,35 @@ impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for Representability {
95111}
96112
97113impl < ' tcx > Value < TyCtxt < ' tcx > , DepKind > for ty:: EarlyBinder < Ty < ' _ > > {
98- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , cycle : & [ QueryInfo < DepKind > ] ) -> Self {
99- ty:: EarlyBinder :: bind ( Ty :: from_cycle_error ( tcx, cycle) )
114+ fn from_cycle_error (
115+ tcx : TyCtxt < ' tcx > ,
116+ cycle : & [ QueryInfo < DepKind > ] ,
117+ guar : ErrorGuaranteed ,
118+ ) -> Self {
119+ ty:: EarlyBinder :: bind ( Ty :: from_cycle_error ( tcx, cycle, guar) )
100120 }
101121}
102122
103123impl < ' tcx > Value < TyCtxt < ' tcx > , DepKind > for ty:: EarlyBinder < ty:: Binder < ' _ , ty:: FnSig < ' _ > > > {
104- fn from_cycle_error ( tcx : TyCtxt < ' tcx > , cycle : & [ QueryInfo < DepKind > ] ) -> Self {
105- ty:: EarlyBinder :: bind ( ty:: Binder :: from_cycle_error ( tcx, cycle) )
124+ fn from_cycle_error (
125+ tcx : TyCtxt < ' tcx > ,
126+ cycle : & [ QueryInfo < DepKind > ] ,
127+ guar : ErrorGuaranteed ,
128+ ) -> Self {
129+ ty:: EarlyBinder :: bind ( ty:: Binder :: from_cycle_error ( tcx, cycle, guar) )
106130 }
107131}
108132
109133impl < ' tcx , T > Value < TyCtxt < ' tcx > , DepKind > for Result < T , & ' _ ty:: layout:: LayoutError < ' _ > > {
110- fn from_cycle_error ( _tcx : TyCtxt < ' tcx > , _cycle : & [ QueryInfo < DepKind > ] ) -> Self {
134+ fn from_cycle_error (
135+ _tcx : TyCtxt < ' tcx > ,
136+ _cycle : & [ QueryInfo < DepKind > ] ,
137+ _guar : ErrorGuaranteed ,
138+ ) -> Self {
111139 // tcx.arena.alloc cannot be used because we are not allowed to use &'tcx LayoutError under
112140 // min_specialization. Since this is an error path anyways, leaking doesn't matter (and really,
113141 // tcx.arena.alloc is pretty much equal to leaking).
142+ // FIXME: `Cycle` should carry the ErrorGuaranteed
114143 Err ( Box :: leak ( Box :: new ( ty:: layout:: LayoutError :: Cycle ) ) )
115144 }
116145}
0 commit comments