@@ -6,29 +6,29 @@ use rustc_hir as hir;
6
6
use rustc_hir:: def:: { DefKind , Res } ;
7
7
use rustc_middle:: ty:: Representability ;
8
8
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
9
- use rustc_query_system:: query:: QueryInfo ;
9
+ use rustc_query_system:: query:: CycleError ;
10
10
use rustc_query_system:: Value ;
11
11
use rustc_span:: def_id:: LocalDefId ;
12
12
use rustc_span:: { ErrorGuaranteed , Span } ;
13
13
14
14
use std:: fmt:: Write ;
15
15
16
16
impl < ' 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 {
18
18
// SAFETY: This is never called when `Self` is not `Ty<'tcx>`.
19
19
// FIXME: Represent the above fact in the trait system somehow.
20
20
unsafe { std:: mem:: transmute :: < Ty < ' tcx > , Ty < ' _ > > ( Ty :: new_error ( tcx, guar) ) }
21
21
}
22
22
}
23
23
24
24
impl < ' 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 {
26
26
Err ( CyclePlaceholder ( guar) )
27
27
}
28
28
}
29
29
30
30
impl < ' 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 {
32
32
// SAFETY: This is never called when `Self` is not `SymbolName<'tcx>`.
33
33
// FIXME: Represent the above fact in the trait system somehow.
34
34
unsafe {
@@ -40,10 +40,14 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::SymbolName<'_> {
40
40
}
41
41
42
42
impl < ' 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 {
44
48
let err = Ty :: new_error ( tcx, guar) ;
45
49
46
- let arity = if let Some ( frame) = stack . get ( 0 )
50
+ let arity = if let Some ( frame) = cycle_error . cycle . get ( 0 )
47
51
&& frame. query . dep_kind == dep_kinds:: fn_sig
48
52
&& let Some ( def_id) = frame. query . def_id
49
53
&& let Some ( node) = tcx. hir ( ) . get_if_local ( def_id)
@@ -70,10 +74,14 @@ impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
70
74
}
71
75
72
76
impl < ' 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 {
74
82
let mut item_and_field_ids = Vec :: new ( ) ;
75
83
let mut representable_ids = FxHashSet :: default ( ) ;
76
- for info in cycle {
84
+ for info in & cycle_error . cycle {
77
85
if info. query . dep_kind == dep_kinds:: representability
78
86
&& let Some ( field_id) = info. query . def_id
79
87
&& let Some ( field_id) = field_id. as_local ( )
@@ -87,7 +95,7 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
87
95
item_and_field_ids. push ( ( item_id. expect_local ( ) , field_id) ) ;
88
96
}
89
97
}
90
- for info in cycle {
98
+ for info in & cycle_error . cycle {
91
99
if info. query . dep_kind == dep_kinds:: representability_adt_ty
92
100
&& let Some ( def_id) = info. query . ty_adt_id
93
101
&& let Some ( def_id) = def_id. as_local ( )
@@ -102,19 +110,31 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
102
110
}
103
111
104
112
impl < ' 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) )
107
119
}
108
120
}
109
121
110
122
impl < ' 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) )
113
129
}
114
130
}
115
131
116
132
impl < ' 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 {
118
138
// tcx.arena.alloc cannot be used because we are not allowed to use &'tcx LayoutError under
119
139
// min_specialization. Since this is an error path anyways, leaking doesn't matter (and really,
120
140
// tcx.arena.alloc is pretty much equal to leaking).
0 commit comments