@@ -3,9 +3,7 @@ use rustc_data_structures::intern::Interned;
3
3
use crate :: infer:: canonical:: { CanonicalVarValues , QueryRegionConstraints } ;
4
4
use crate :: traits:: query:: NoSolution ;
5
5
use 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 } ;
9
7
use rustc_span:: def_id:: DefId ;
10
8
11
9
use super :: BuiltinImplSource ;
@@ -112,7 +110,7 @@ pub struct PredefinedOpaquesData<'tcx> {
112
110
pub opaque_types : Vec < ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) > ,
113
111
}
114
112
115
- #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable ) ]
113
+ #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable , TypeVisitable , TypeFoldable ) ]
116
114
pub struct PredefinedOpaques < ' tcx > ( pub ( crate ) Interned < ' tcx , PredefinedOpaquesData < ' tcx > > ) ;
117
115
118
116
impl < ' tcx > std:: ops:: Deref for PredefinedOpaques < ' tcx > {
@@ -135,7 +133,7 @@ pub type CanonicalResponse<'tcx> = Canonical<'tcx, Response<'tcx>>;
135
133
/// solver, merge the two responses again.
136
134
pub type QueryResult < ' tcx > = Result < CanonicalResponse < ' tcx > , NoSolution > ;
137
135
138
- #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable ) ]
136
+ #[ derive( Debug , PartialEq , Eq , Copy , Clone , Hash , HashStable , TypeFoldable , TypeVisitable ) ]
139
137
pub struct ExternalConstraints < ' tcx > ( pub ( crate ) Interned < ' tcx , ExternalConstraintsData < ' tcx > > ) ;
140
138
141
139
impl < ' tcx > std:: ops:: Deref for ExternalConstraints < ' tcx > {
@@ -154,52 +152,6 @@ pub struct ExternalConstraintsData<'tcx> {
154
152
pub opaque_types : Vec < ( ty:: OpaqueTypeKey < ' tcx > , Ty < ' tcx > ) > ,
155
153
}
156
154
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
-
203
155
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash , HashStable ) ]
204
156
pub enum IsNormalizesToHack {
205
157
Yes ,
0 commit comments