@@ -239,7 +239,7 @@ pub enum Vtable<'tcx, N> {
239
239
VtableParam ( Vec < N > ) ,
240
240
241
241
/// Virtual calls through an object
242
- VtableObject ( VtableObjectData < ' tcx > ) ,
242
+ VtableObject ( VtableObjectData < ' tcx , N > ) ,
243
243
244
244
/// Successful resolution for a builtin trait.
245
245
VtableBuiltin ( VtableBuiltinData < N > ) ,
@@ -250,7 +250,7 @@ pub enum Vtable<'tcx, N> {
250
250
VtableClosure ( VtableClosureData < ' tcx , N > ) ,
251
251
252
252
/// Same as above, but for a fn pointer type with the given signature.
253
- VtableFnPointer ( ty :: Ty < ' tcx > ) ,
253
+ VtableFnPointer ( VtableFnPointerData < ' tcx , N > ) ,
254
254
}
255
255
256
256
/// Identifies a particular impl in the source, along with a set of
@@ -293,14 +293,22 @@ pub struct VtableBuiltinData<N> {
293
293
/// A vtable for some object-safe trait `Foo` automatically derived
294
294
/// for the object type `Foo`.
295
295
#[ derive( PartialEq , Eq , Clone ) ]
296
- pub struct VtableObjectData < ' tcx > {
296
+ pub struct VtableObjectData < ' tcx , N > {
297
297
/// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
298
298
pub upcast_trait_ref : ty:: PolyTraitRef < ' tcx > ,
299
299
300
300
/// The vtable is formed by concatenating together the method lists of
301
301
/// the base object trait and all supertraits; this is the start of
302
302
/// `upcast_trait_ref`'s methods in that vtable.
303
- pub vtable_base : usize
303
+ pub vtable_base : usize ,
304
+
305
+ pub nested : Vec < N > ,
306
+ }
307
+
308
+ #[ derive( Clone , PartialEq , Eq ) ]
309
+ pub struct VtableFnPointerData < ' tcx , N > {
310
+ pub fn_ty : ty:: Ty < ' tcx > ,
311
+ pub nested : Vec < N >
304
312
}
305
313
306
314
/// Creates predicate obligations from the generic bounds.
@@ -569,7 +577,20 @@ impl<'tcx, N> Vtable<'tcx, N> {
569
577
VtableBuiltin ( i) => i. nested ,
570
578
VtableDefaultImpl ( d) => d. nested ,
571
579
VtableClosure ( c) => c. nested ,
572
- VtableObject ( _) | VtableFnPointer ( ..) => vec ! [ ]
580
+ VtableObject ( d) => d. nested ,
581
+ VtableFnPointer ( d) => d. nested ,
582
+ }
583
+ }
584
+
585
+ fn nested_obligations_mut ( & mut self ) -> & mut Vec < N > {
586
+ match self {
587
+ & mut VtableImpl ( ref mut i) => & mut i. nested ,
588
+ & mut VtableParam ( ref mut n) => n,
589
+ & mut VtableBuiltin ( ref mut i) => & mut i. nested ,
590
+ & mut VtableDefaultImpl ( ref mut d) => & mut d. nested ,
591
+ & mut VtableClosure ( ref mut c) => & mut c. nested ,
592
+ & mut VtableObject ( ref mut d) => & mut d. nested ,
593
+ & mut VtableFnPointer ( ref mut d) => & mut d. nested ,
573
594
}
574
595
}
575
596
@@ -578,18 +599,25 @@ impl<'tcx, N> Vtable<'tcx, N> {
578
599
VtableImpl ( i) => VtableImpl ( VtableImplData {
579
600
impl_def_id : i. impl_def_id ,
580
601
substs : i. substs ,
581
- nested : i. nested . into_iter ( ) . map ( f) . collect ( )
602
+ nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
582
603
} ) ,
583
604
VtableParam ( n) => VtableParam ( n. into_iter ( ) . map ( f) . collect ( ) ) ,
584
605
VtableBuiltin ( i) => VtableBuiltin ( VtableBuiltinData {
585
- nested : i. nested . into_iter ( ) . map ( f) . collect ( )
606
+ nested : i. nested . into_iter ( ) . map ( f) . collect ( ) ,
607
+ } ) ,
608
+ VtableObject ( o) => VtableObject ( VtableObjectData {
609
+ upcast_trait_ref : o. upcast_trait_ref ,
610
+ vtable_base : o. vtable_base ,
611
+ nested : o. nested . into_iter ( ) . map ( f) . collect ( ) ,
586
612
} ) ,
587
- VtableObject ( o) => VtableObject ( o) ,
588
613
VtableDefaultImpl ( d) => VtableDefaultImpl ( VtableDefaultImplData {
589
614
trait_def_id : d. trait_def_id ,
590
- nested : d. nested . into_iter ( ) . map ( f) . collect ( )
615
+ nested : d. nested . into_iter ( ) . map ( f) . collect ( ) ,
616
+ } ) ,
617
+ VtableFnPointer ( p) => VtableFnPointer ( VtableFnPointerData {
618
+ fn_ty : p. fn_ty ,
619
+ nested : p. nested . into_iter ( ) . map ( f) . collect ( ) ,
591
620
} ) ,
592
- VtableFnPointer ( f) => VtableFnPointer ( f) ,
593
621
VtableClosure ( c) => VtableClosure ( VtableClosureData {
594
622
closure_def_id : c. closure_def_id ,
595
623
substs : c. substs ,
0 commit comments