@@ -54,6 +54,12 @@ impl<'i, I: Interner> InputTypeCollector<'i, I> {
5454 interner,
5555 }
5656 }
57+
58+ fn types_in ( interner : & ' i I , value : impl Visit < I > ) -> Vec < Ty < I > > {
59+ let mut collector = Self :: new ( interner) ;
60+ value. visit_with ( & mut collector, DebruijnIndex :: INNERMOST ) ;
61+ collector. types
62+ }
5763}
5864
5965impl < ' i , ' t , I : Interner > Visitor < ' i , I > for InputTypeCollector < ' i , I > {
@@ -168,13 +174,10 @@ where
168174 . map ( |wc| wc. into_from_env_goal ( interner) ) ,
169175 |gb| {
170176 // WellFormed(Vec<T>), for each field type `Vec<T>` or type that appears in the where clauses
171- let mut type_collector = InputTypeCollector :: new ( gb. interner ( ) ) ;
177+ let types =
178+ InputTypeCollector :: types_in ( gb. interner ( ) , ( & fields, & where_clauses) ) ;
172179
173- // ...in a field type...
174- fields. visit_with ( & mut type_collector, DebruijnIndex :: INNERMOST ) ;
175- // ...in a where clause.
176- where_clauses. visit_with ( & mut type_collector, DebruijnIndex :: INNERMOST ) ;
177- gb. all ( type_collector. types . into_iter ( ) . map ( |ty| ty. well_formed ( ) ) . chain ( sized_constraint_goal. into_iter ( ) ) )
180+ gb. all ( types. into_iter ( ) . map ( |ty| ty. well_formed ( ) ) . chain ( sized_constraint_goal. into_iter ( ) ) )
178181 } ,
179182 )
180183 } ) ;
@@ -264,14 +267,12 @@ fn impl_header_wf_goal<I: Interner>(
264267 // we would retrieve `HashSet<K>`, `Box<T>`, `Vec<Box<T>>`, `(HashSet<K>, Vec<Box<T>>)`.
265268 // We will have to prove that these types are well-formed (e.g. an additional `K: Hash`
266269 // bound would be needed here).
267- let mut type_collector = InputTypeCollector :: new ( interner) ;
268- where_clauses. visit_with ( & mut type_collector, DebruijnIndex :: INNERMOST ) ;
270+ let types = InputTypeCollector :: types_in ( gb. interner ( ) , & where_clauses) ;
269271
270272 // Things to prove well-formed: input types of the where-clauses, projection types
271273 // appearing in the header, associated type values, and of course the trait ref.
272- debug ! ( "verify_trait_impl: input_types={:?}" , type_collector. types) ;
273- let goals = type_collector
274- . types
274+ debug ! ( "verify_trait_impl: input_types={:?}" , types) ;
275+ let goals = types
275276 . into_iter ( )
276277 . map ( |ty| ty. well_formed ( ) . cast ( interner) )
277278 . chain ( Some ( ( * trait_ref) . clone ( ) . well_formed ( ) . cast ( interner) ) ) ;
@@ -307,11 +308,9 @@ fn impl_wf_environment<'i, I: Interner>(
307308 // // Inside here, we can rely on the fact that `K: Hash` holds
308309 // }
309310 // ```
310- let mut type_collector = InputTypeCollector :: new ( interner) ;
311- trait_ref. visit_with ( & mut type_collector, DebruijnIndex :: INNERMOST ) ;
311+ let types = InputTypeCollector :: types_in ( interner, trait_ref) ;
312312
313- let types_wf = type_collector
314- . types
313+ let types_wf = types
315314 . into_iter ( )
316315 . map ( move |ty| ty. into_from_env_goal ( interner) . cast ( interner) ) ;
317316
@@ -412,12 +411,10 @@ fn compute_assoc_ty_goal<I: Interner>(
412411 . cloned ( )
413412 . map ( |qwc| qwc. into_from_env_goal ( interner) ) ,
414413 |gb| {
415- let mut type_collector = InputTypeCollector :: new ( interner) ;
416- value_ty. visit_with ( & mut type_collector, DebruijnIndex :: INNERMOST ) ;
414+ let types = InputTypeCollector :: types_in ( gb. interner ( ) , value_ty) ;
417415
418416 // We require that `WellFormed(T)` for each type that appears in the value
419- let wf_goals = type_collector
420- . types
417+ let wf_goals = types
421418 . into_iter ( )
422419 . map ( |ty| ty. well_formed ( ) )
423420 . casted ( interner) ;
0 commit comments