1
- use std:: ops:: ControlFlow ;
2
-
3
1
use rustc_data_structures:: intern:: Interned ;
4
2
5
3
use crate :: infer:: canonical:: { CanonicalVarValues , QueryRegionConstraints } ;
6
4
use crate :: traits:: query:: NoSolution ;
7
5
use crate :: traits:: { Canonical , DefiningAnchor } ;
8
6
use crate :: ty:: {
9
- self , FallibleTypeFolder , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeFolder , TypeVisitable ,
10
- TypeVisitor ,
7
+ self , FallibleTypeFolder , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeVisitable , TypeVisitor ,
11
8
} ;
12
9
use rustc_span:: def_id:: DefId ;
13
10
@@ -110,7 +107,7 @@ pub struct QueryInput<'tcx, T> {
110
107
}
111
108
112
109
/// Additional constraints returned on success.
113
- #[ derive( Debug , PartialEq , Eq , Clone , Hash , HashStable , Default ) ]
110
+ #[ derive( Debug , PartialEq , Eq , Clone , Hash , HashStable , Default , TypeVisitable , TypeFoldable ) ]
114
111
pub struct PredefinedOpaquesData < ' tcx > {
115
112
pub opaque_types : Vec < ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) > ,
116
113
}
@@ -167,21 +164,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
167
164
self ,
168
165
folder : & mut F ,
169
166
) -> Result < Self , F :: Error > {
170
- Ok ( FallibleTypeFolder :: interner ( folder) . mk_external_constraints ( ExternalConstraintsData {
171
- region_constraints : self . region_constraints . clone ( ) . try_fold_with ( folder) ?,
172
- opaque_types : self
173
- . opaque_types
174
- . iter ( )
175
- . map ( |opaque| opaque. try_fold_with ( folder) )
176
- . collect :: < Result < _ , F :: Error > > ( ) ?,
177
- } ) )
178
- }
179
-
180
- fn fold_with < F : TypeFolder < TyCtxt < ' tcx > > > ( self , folder : & mut F ) -> Self {
181
- TypeFolder :: interner ( folder) . mk_external_constraints ( ExternalConstraintsData {
182
- region_constraints : self . region_constraints . clone ( ) . fold_with ( folder) ,
183
- opaque_types : self . opaque_types . iter ( ) . map ( |opaque| opaque. fold_with ( folder) ) . collect ( ) ,
184
- } )
167
+ Ok ( folder. interner ( ) . mk_external_constraints ( ( * self ) . clone ( ) . try_fold_with ( folder) ?) )
185
168
}
186
169
}
187
170
@@ -190,9 +173,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
190
173
& self ,
191
174
visitor : & mut V ,
192
175
) -> std:: ops:: ControlFlow < V :: BreakTy > {
193
- self . region_constraints . visit_with ( visitor) ?;
194
- self . opaque_types . visit_with ( visitor) ?;
195
- ControlFlow :: Continue ( ( ) )
176
+ ( * * self ) . visit_with ( visitor)
196
177
}
197
178
}
198
179
@@ -206,21 +187,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for PredefinedOpaques<'tcx> {
206
187
self ,
207
188
folder : & mut F ,
208
189
) -> Result < Self , F :: Error > {
209
- Ok ( FallibleTypeFolder :: interner ( folder) . mk_predefined_opaques_in_body (
210
- PredefinedOpaquesData {
211
- opaque_types : self
212
- . opaque_types
213
- . iter ( )
214
- . map ( |opaque| opaque. try_fold_with ( folder) )
215
- . collect :: < Result < _ , F :: Error > > ( ) ?,
216
- } ,
217
- ) )
218
- }
219
-
220
- fn fold_with < F : TypeFolder < TyCtxt < ' tcx > > > ( self , folder : & mut F ) -> Self {
221
- TypeFolder :: interner ( folder) . mk_predefined_opaques_in_body ( PredefinedOpaquesData {
222
- opaque_types : self . opaque_types . iter ( ) . map ( |opaque| opaque. fold_with ( folder) ) . collect ( ) ,
223
- } )
190
+ Ok ( folder. interner ( ) . mk_predefined_opaques_in_body ( ( * self ) . clone ( ) . try_fold_with ( folder) ?) )
224
191
}
225
192
}
226
193
@@ -229,7 +196,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for PredefinedOpaques<'tcx> {
229
196
& self ,
230
197
visitor : & mut V ,
231
198
) -> std:: ops:: ControlFlow < V :: BreakTy > {
232
- self . opaque_types . visit_with ( visitor)
199
+ ( * * self ) . visit_with ( visitor)
233
200
}
234
201
}
235
202
0 commit comments