@@ -58,10 +58,7 @@ pub fn search_for_structural_match_violation<'tcx>(
58
58
tcx : TyCtxt < ' tcx > ,
59
59
ty : Ty < ' tcx > ,
60
60
) -> Option < NonStructuralMatchTy < ' tcx > > {
61
- // FIXME: we should instead pass in an `infcx` from the outside.
62
- tcx. infer_ctxt ( ) . enter ( |infcx| {
63
- ty. visit_with ( & mut Search { infcx, span, seen : FxHashSet :: default ( ) } ) . break_value ( )
64
- } )
61
+ ty. visit_with ( & mut Search { tcx, span, seen : FxHashSet :: default ( ) } ) . break_value ( )
65
62
}
66
63
67
64
/// This method returns true if and only if `adt_ty` itself has been marked as
@@ -114,27 +111,23 @@ fn type_marked_structural<'tcx>(
114
111
/// This implements the traversal over the structure of a given type to try to
115
112
/// find instances of ADTs (specifically structs or enums) that do not implement
116
113
/// the structural-match traits (`StructuralPartialEq` and `StructuralEq`).
117
- struct Search < ' a , ' tcx > {
114
+ struct Search < ' tcx > {
118
115
span : Span ,
119
116
120
- infcx : InferCtxt < ' a , ' tcx > ,
117
+ tcx : TyCtxt < ' tcx > ,
121
118
122
119
/// Tracks ADTs previously encountered during search, so that
123
120
/// we will not recur on them again.
124
121
seen : FxHashSet < hir:: def_id:: DefId > ,
125
122
}
126
123
127
- impl < ' a , ' tcx > Search < ' a , ' tcx > {
128
- fn tcx ( & self ) -> TyCtxt < ' tcx > {
129
- self . infcx . tcx
130
- }
131
-
124
+ impl < ' tcx > Search < ' tcx > {
132
125
fn type_marked_structural ( & self , adt_ty : Ty < ' tcx > ) -> bool {
133
- adt_ty. is_structural_eq_shallow ( self . tcx ( ) )
126
+ adt_ty. is_structural_eq_shallow ( self . tcx )
134
127
}
135
128
}
136
129
137
- impl < ' a , ' tcx > TypeVisitor < ' tcx > for Search < ' a , ' tcx > {
130
+ impl < ' tcx > TypeVisitor < ' tcx > for Search < ' tcx > {
138
131
type BreakTy = NonStructuralMatchTy < ' tcx > ;
139
132
140
133
fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
@@ -193,7 +186,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
193
186
return ControlFlow :: CONTINUE ;
194
187
}
195
188
ty:: Array ( _, n)
196
- if { n. try_eval_usize ( self . tcx ( ) , ty:: ParamEnv :: reveal_all ( ) ) == Some ( 0 ) } =>
189
+ if { n. try_eval_usize ( self . tcx , ty:: ParamEnv :: reveal_all ( ) ) == Some ( 0 ) } =>
197
190
{
198
191
// rust-lang/rust#62336: ignore type of contents
199
192
// for empty array.
@@ -214,7 +207,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
214
207
bug ! ( "unexpected type during structural-match checking: {:?}" , ty) ;
215
208
}
216
209
ty:: Error ( _) => {
217
- self . tcx ( ) . sess . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
210
+ self . tcx . sess . delay_span_bug ( self . span , "ty::Error in structural-match check" ) ;
218
211
// We still want to check other types after encountering an error,
219
212
// as this may still emit relevant errors.
220
213
return ControlFlow :: CONTINUE ;
@@ -244,9 +237,9 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
244
237
245
238
// even though we skip super_visit_with, we must recur on
246
239
// fields of ADT.
247
- let tcx = self . tcx ( ) ;
240
+ let tcx = self . tcx ;
248
241
adt_def. all_fields ( ) . map ( |field| field. ty ( tcx, substs) ) . try_for_each ( |field_ty| {
249
- let ty = self . tcx ( ) . normalize_erasing_regions ( ty:: ParamEnv :: empty ( ) , field_ty) ;
242
+ let ty = self . tcx . normalize_erasing_regions ( ty:: ParamEnv :: empty ( ) , field_ty) ;
250
243
debug ! ( "structural-match ADT: field_ty={:?}, ty={:?}" , field_ty, ty) ;
251
244
ty. visit_with ( self )
252
245
} )
0 commit comments