1- use std:: ops:: ControlFlow ;
2-
31use rustc_data_structures:: intern:: Interned ;
42
53use crate :: infer:: canonical:: { CanonicalVarValues , QueryRegionConstraints } ;
64use crate :: traits:: query:: NoSolution ;
75use crate :: traits:: { Canonical , DefiningAnchor } ;
86use crate :: ty:: {
9- self , FallibleTypeFolder , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeFolder , TypeVisitable ,
10- TypeVisitor ,
7+ self , FallibleTypeFolder , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeVisitable , TypeVisitor ,
118} ;
129use rustc_span:: def_id:: DefId ;
1310
@@ -110,7 +107,7 @@ pub struct QueryInput<'tcx, T> {
110107}
111108
112109/// 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 ) ]
114111pub struct PredefinedOpaquesData < ' tcx > {
115112 pub opaque_types : Vec < ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) > ,
116113}
@@ -167,21 +164,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
167164 self ,
168165 folder : & mut F ,
169166 ) -> 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) ?) )
185168 }
186169}
187170
@@ -190,9 +173,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
190173 & self ,
191174 visitor : & mut V ,
192175 ) -> 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)
196177 }
197178}
198179
@@ -206,21 +187,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for PredefinedOpaques<'tcx> {
206187 self ,
207188 folder : & mut F ,
208189 ) -> 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) ?) )
224191 }
225192}
226193
@@ -229,7 +196,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for PredefinedOpaques<'tcx> {
229196 & self ,
230197 visitor : & mut V ,
231198 ) -> std:: ops:: ControlFlow < V :: BreakTy > {
232- self . opaque_types . visit_with ( visitor)
199+ ( * * self ) . visit_with ( visitor)
233200 }
234201}
235202
0 commit comments