@@ -58,10 +58,7 @@ pub fn search_for_structural_match_violation<'tcx>(
5858 tcx : TyCtxt < ' tcx > ,
5959 ty : Ty < ' tcx > ,
6060) -> 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 ( )
6562}
6663
6764/// This method returns true if and only if `adt_ty` itself has been marked as
@@ -114,27 +111,23 @@ fn type_marked_structural<'tcx>(
114111/// This implements the traversal over the structure of a given type to try to
115112/// find instances of ADTs (specifically structs or enums) that do not implement
116113/// the structural-match traits (`StructuralPartialEq` and `StructuralEq`).
117- struct Search < ' a , ' tcx > {
114+ struct Search < ' tcx > {
118115 span : Span ,
119116
120- infcx : InferCtxt < ' a , ' tcx > ,
117+ tcx : TyCtxt < ' tcx > ,
121118
122119 /// Tracks ADTs previously encountered during search, so that
123120 /// we will not recur on them again.
124121 seen : FxHashSet < hir:: def_id:: DefId > ,
125122}
126123
127- impl < ' a , ' tcx > Search < ' a , ' tcx > {
128- fn tcx ( & self ) -> TyCtxt < ' tcx > {
129- self . infcx . tcx
130- }
131-
124+ impl < ' tcx > Search < ' tcx > {
132125 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 )
134127 }
135128}
136129
137- impl < ' a , ' tcx > TypeVisitor < ' tcx > for Search < ' a , ' tcx > {
130+ impl < ' tcx > TypeVisitor < ' tcx > for Search < ' tcx > {
138131 type BreakTy = NonStructuralMatchTy < ' tcx > ;
139132
140133 fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
@@ -193,7 +186,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
193186 return ControlFlow :: CONTINUE ;
194187 }
195188 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 ) } =>
197190 {
198191 // rust-lang/rust#62336: ignore type of contents
199192 // for empty array.
@@ -214,7 +207,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
214207 bug ! ( "unexpected type during structural-match checking: {:?}" , ty) ;
215208 }
216209 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" ) ;
218211 // We still want to check other types after encountering an error,
219212 // as this may still emit relevant errors.
220213 return ControlFlow :: CONTINUE ;
@@ -244,9 +237,9 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
244237
245238 // even though we skip super_visit_with, we must recur on
246239 // fields of ADT.
247- let tcx = self . tcx ( ) ;
240+ let tcx = self . tcx ;
248241 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) ;
250243 debug ! ( "structural-match ADT: field_ty={:?}, ty={:?}" , field_ty, ty) ;
251244 ty. visit_with ( self )
252245 } )
0 commit comments