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