@@ -3,9 +3,7 @@ use rustc_data_structures::intern::Interned;
33use crate :: infer:: canonical:: { CanonicalVarValues , QueryRegionConstraints } ;
44use crate :: traits:: query:: NoSolution ;
55use crate :: traits:: { Canonical , DefiningAnchor } ;
6- use crate :: ty:: {
7- self , FallibleTypeFolder , ToPredicate , Ty , TyCtxt , TypeFoldable , TypeVisitable , TypeVisitor ,
8- } ;
6+ use crate :: ty:: { self , ToPredicate , Ty , TyCtxt } ;
97use rustc_span:: def_id:: DefId ;
108
119use super :: BuiltinImplSource ;
@@ -112,7 +110,7 @@ pub struct PredefinedOpaquesData<'tcx> {
112110 pub opaque_types : Vec < ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) > ,
113111}
114112
115- #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable ) ]
113+ #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable , TypeVisitable , TypeFoldable ) ]
116114pub struct PredefinedOpaques < ' tcx > ( pub ( crate ) Interned < ' tcx , PredefinedOpaquesData < ' tcx > > ) ;
117115
118116impl < ' tcx > std:: ops:: Deref for PredefinedOpaques < ' tcx > {
@@ -135,7 +133,7 @@ pub type CanonicalResponse<'tcx> = Canonical<'tcx, Response<'tcx>>;
135133/// solver, merge the two responses again.
136134pub type QueryResult < ' tcx > = Result < CanonicalResponse < ' tcx > , NoSolution > ;
137135
138- #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable ) ]
136+ #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable , TypeFoldable , TypeVisitable ) ]
139137pub struct ExternalConstraints < ' tcx > ( pub ( crate ) Interned < ' tcx , ExternalConstraintsData < ' tcx > > ) ;
140138
141139impl < ' tcx > std:: ops:: Deref for ExternalConstraints < ' tcx > {
@@ -154,52 +152,6 @@ pub struct ExternalConstraintsData<'tcx> {
154152 pub opaque_types : Vec < ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) > ,
155153}
156154
157- // FIXME: Having to clone `region_constraints` for folding feels bad and
158- // probably isn't great wrt performance.
159- //
160- // Not sure how to fix this, maybe we should also intern `opaque_types` and
161- // `region_constraints` here or something.
162- impl < ' tcx > TypeFoldable < TyCtxt < ' tcx > > for ExternalConstraints < ' tcx > {
163- fn try_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
164- self ,
165- folder : & mut F ,
166- ) -> Result < Self , F :: Error > {
167- Ok ( folder. interner ( ) . mk_external_constraints ( ( * self ) . clone ( ) . try_fold_with ( folder) ?) )
168- }
169- }
170-
171- impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for ExternalConstraints < ' tcx > {
172- fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > (
173- & self ,
174- visitor : & mut V ,
175- ) -> std:: ops:: ControlFlow < V :: BreakTy > {
176- ( * * self ) . visit_with ( visitor)
177- }
178- }
179-
180- // FIXME: Having to clone `region_constraints` for folding feels bad and
181- // probably isn't great wrt performance.
182- //
183- // Not sure how to fix this, maybe we should also intern `opaque_types` and
184- // `region_constraints` here or something.
185- impl < ' tcx > TypeFoldable < TyCtxt < ' tcx > > for PredefinedOpaques < ' tcx > {
186- fn try_fold_with < F : FallibleTypeFolder < TyCtxt < ' tcx > > > (
187- self ,
188- folder : & mut F ,
189- ) -> Result < Self , F :: Error > {
190- Ok ( folder. interner ( ) . mk_predefined_opaques_in_body ( ( * self ) . clone ( ) . try_fold_with ( folder) ?) )
191- }
192- }
193-
194- impl < ' tcx > TypeVisitable < TyCtxt < ' tcx > > for PredefinedOpaques < ' tcx > {
195- fn visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > (
196- & self ,
197- visitor : & mut V ,
198- ) -> std:: ops:: ControlFlow < V :: BreakTy > {
199- ( * * self ) . visit_with ( visitor)
200- }
201- }
202-
203155#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash , HashStable ) ]
204156pub enum IsNormalizesToHack {
205157 Yes ,
0 commit comments