@@ -3,7 +3,6 @@ use std::fmt;
33use std:: iter:: once;
44
55use rustc_arena:: { DroplessArena , TypedArena } ;
6- use rustc_data_structures:: captures:: Captures ;
76use rustc_hir:: def_id:: DefId ;
87use rustc_hir:: HirId ;
98use rustc_index:: { Idx , IndexVec } ;
@@ -20,7 +19,7 @@ use rustc_target::abi::{FieldIdx, Integer, VariantIdx, FIRST_VARIANT};
2019use crate :: constructor:: {
2120 IntRange , MaybeInfiniteInt , OpaqueId , RangeEnd , Slice , SliceKind , VariantVisibility ,
2221} ;
23- use crate :: { errors, TypeCx } ;
22+ use crate :: { errors, Captures , TypeCx } ;
2423
2524use crate :: constructor:: Constructor :: * ;
2625
@@ -210,19 +209,19 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
210209 /// Returns the types of the fields for a given constructor. The result must have a length of
211210 /// `ctor.arity()`.
212211 #[ instrument( level = "trace" , skip( self ) ) ]
213- pub ( crate ) fn ctor_sub_tys (
214- & self ,
215- ctor : & Constructor < ' p , ' tcx > ,
212+ pub ( crate ) fn ctor_sub_tys < ' a > (
213+ & ' a self ,
214+ ctor : & ' a Constructor < ' p , ' tcx > ,
216215 ty : RevealedTy < ' tcx > ,
217- ) -> & [ RevealedTy < ' tcx > ] {
216+ ) -> impl Iterator < Item = RevealedTy < ' tcx > > + ExactSizeIterator + Captures < ' a > {
218217 fn reveal_and_alloc < ' a , ' tcx > (
219218 cx : & ' a RustcMatchCheckCtxt < ' _ , ' tcx > ,
220219 iter : impl Iterator < Item = Ty < ' tcx > > ,
221220 ) -> & ' a [ RevealedTy < ' tcx > ] {
222221 cx. dropless_arena . alloc_from_iter ( iter. map ( |ty| cx. reveal_opaque_ty ( ty) ) )
223222 }
224223 let cx = self ;
225- match ctor {
224+ let slice = match ctor {
226225 Struct | Variant ( _) | UnionField => match ty. kind ( ) {
227226 ty:: Tuple ( fs) => reveal_and_alloc ( cx, fs. iter ( ) ) ,
228227 ty:: Adt ( adt, args) => {
@@ -263,7 +262,8 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
263262 Or => {
264263 bug ! ( "called `Fields::wildcards` on an `Or` ctor" )
265264 }
266- }
265+ } ;
266+ slice. iter ( ) . copied ( )
267267 }
268268
269269 /// The number of fields for this constructor.
@@ -964,11 +964,11 @@ impl<'p, 'tcx> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
964964 fn ctor_arity ( & self , ctor : & crate :: constructor:: Constructor < Self > , ty : & Self :: Ty ) -> usize {
965965 self . ctor_arity ( ctor, * ty)
966966 }
967- fn ctor_sub_tys (
968- & self ,
969- ctor : & crate :: constructor:: Constructor < Self > ,
970- ty : & Self :: Ty ,
971- ) -> & [ Self :: Ty ] {
967+ fn ctor_sub_tys < ' a > (
968+ & ' a self ,
969+ ctor : & ' a crate :: constructor:: Constructor < Self > ,
970+ ty : & ' a Self :: Ty ,
971+ ) -> impl Iterator < Item = Self :: Ty > + ExactSizeIterator + Captures < ' a > {
972972 self . ctor_sub_tys ( ctor, * ty)
973973 }
974974 fn ctors_for_ty (
0 commit comments