@@ -3,7 +3,6 @@ use std::fmt;
3
3
use std:: iter:: once;
4
4
5
5
use rustc_arena:: { DroplessArena , TypedArena } ;
6
- use rustc_data_structures:: captures:: Captures ;
7
6
use rustc_hir:: def_id:: DefId ;
8
7
use rustc_hir:: HirId ;
9
8
use rustc_index:: { Idx , IndexVec } ;
@@ -20,7 +19,7 @@ use rustc_target::abi::{FieldIdx, Integer, VariantIdx, FIRST_VARIANT};
20
19
use crate :: constructor:: {
21
20
IntRange , MaybeInfiniteInt , OpaqueId , RangeEnd , Slice , SliceKind , VariantVisibility ,
22
21
} ;
23
- use crate :: { errors, TypeCx } ;
22
+ use crate :: { errors, Captures , TypeCx } ;
24
23
25
24
use crate :: constructor:: Constructor :: * ;
26
25
@@ -210,19 +209,19 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
210
209
/// Returns the types of the fields for a given constructor. The result must have a length of
211
210
/// `ctor.arity()`.
212
211
#[ 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 > ,
216
215
ty : RevealedTy < ' tcx > ,
217
- ) -> & [ RevealedTy < ' tcx > ] {
216
+ ) -> impl Iterator < Item = RevealedTy < ' tcx > > + ExactSizeIterator + Captures < ' a > {
218
217
fn reveal_and_alloc < ' a , ' tcx > (
219
218
cx : & ' a RustcMatchCheckCtxt < ' _ , ' tcx > ,
220
219
iter : impl Iterator < Item = Ty < ' tcx > > ,
221
220
) -> & ' a [ RevealedTy < ' tcx > ] {
222
221
cx. dropless_arena . alloc_from_iter ( iter. map ( |ty| cx. reveal_opaque_ty ( ty) ) )
223
222
}
224
223
let cx = self ;
225
- match ctor {
224
+ let slice = match ctor {
226
225
Struct | Variant ( _) | UnionField => match ty. kind ( ) {
227
226
ty:: Tuple ( fs) => reveal_and_alloc ( cx, fs. iter ( ) ) ,
228
227
ty:: Adt ( adt, args) => {
@@ -263,7 +262,8 @@ impl<'p, 'tcx> RustcMatchCheckCtxt<'p, 'tcx> {
263
262
Or => {
264
263
bug ! ( "called `Fields::wildcards` on an `Or` ctor" )
265
264
}
266
- }
265
+ } ;
266
+ slice. iter ( ) . copied ( )
267
267
}
268
268
269
269
/// The number of fields for this constructor.
@@ -964,11 +964,11 @@ impl<'p, 'tcx> TypeCx for RustcMatchCheckCtxt<'p, 'tcx> {
964
964
fn ctor_arity ( & self , ctor : & crate :: constructor:: Constructor < Self > , ty : & Self :: Ty ) -> usize {
965
965
self . ctor_arity ( ctor, * ty)
966
966
}
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 > {
972
972
self . ctor_sub_tys ( ctor, * ty)
973
973
}
974
974
fn ctors_for_ty (
0 commit comments