@@ -22,14 +22,8 @@ struct OpaqueTypeCollector<'tcx> {
22
22
}
23
23
24
24
impl < ' tcx > OpaqueTypeCollector < ' tcx > {
25
- fn collect (
26
- tcx : TyCtxt < ' tcx > ,
27
- item : LocalDefId ,
28
- val : ty:: Binder < ' tcx , impl TypeVisitable < TyCtxt < ' tcx > > > ,
29
- ) -> Vec < LocalDefId > {
30
- let mut collector = Self { tcx, opaques : Vec :: new ( ) , item, seen : Default :: default ( ) } ;
31
- val. skip_binder ( ) . visit_with ( & mut collector) ;
32
- collector. opaques
25
+ fn new ( tcx : TyCtxt < ' tcx > , item : LocalDefId ) -> Self {
26
+ Self { tcx, opaques : Vec :: new ( ) , item, seen : Default :: default ( ) }
33
27
}
34
28
35
29
fn span ( & self ) -> Span {
@@ -166,21 +160,17 @@ fn opaque_types_defined_by<'tcx>(tcx: TyCtxt<'tcx>, item: LocalDefId) -> &'tcx [
166
160
match kind {
167
161
// We're also doing this for `AssocTy` for the wf checks in `check_opaque_meets_bounds`
168
162
DefKind :: Fn | DefKind :: AssocFn | DefKind :: AssocTy | DefKind :: AssocConst => {
169
- let defined_opaques = match kind {
170
- DefKind :: Fn => {
171
- OpaqueTypeCollector :: collect ( tcx, item, tcx. fn_sig ( item) . subst_identity ( ) )
163
+ let mut collector = OpaqueTypeCollector :: new ( tcx, item) ;
164
+ match kind {
165
+ DefKind :: AssocFn | DefKind :: Fn => {
166
+ tcx. fn_sig ( item) . subst_identity ( ) . visit_with ( & mut collector) ;
172
167
}
173
- DefKind :: AssocFn => {
174
- OpaqueTypeCollector :: collect ( tcx, item , tcx . fn_sig ( item) . subst_identity ( ) )
168
+ DefKind :: AssocTy | DefKind :: AssocConst => {
169
+ tcx. type_of ( item) . subst_identity ( ) . visit_with ( & mut collector ) ;
175
170
}
176
- DefKind :: AssocTy | DefKind :: AssocConst => OpaqueTypeCollector :: collect (
177
- tcx,
178
- item,
179
- ty:: Binder :: dummy ( tcx. type_of ( item) . subst_identity ( ) ) ,
180
- ) ,
181
171
_ => unreachable ! ( ) ,
182
- } ;
183
- tcx. arena . alloc_from_iter ( defined_opaques )
172
+ }
173
+ tcx. arena . alloc_from_iter ( collector . opaques )
184
174
}
185
175
DefKind :: Mod
186
176
| DefKind :: Struct
0 commit comments