@@ -30,7 +30,7 @@ use super::SelectionResult;
3030use super :: { VtableBuiltin , VtableImpl , VtableParam , VtableClosure ,
3131 VtableFnPointer , VtableObject , VtableDefaultImpl } ;
3232use super :: { VtableImplData , VtableObjectData , VtableBuiltinData ,
33- VtableClosureData , VtableDefaultImplData } ;
33+ VtableClosureData , VtableDefaultImplData , VtableFnPointerData } ;
3434use super :: util;
3535
3636use hir:: def_id:: DefId ;
@@ -42,13 +42,24 @@ use traits;
4242use ty:: fast_reject;
4343use ty:: relate:: TypeRelation ;
4444
45+ use rustc_data_structures:: snapshot_vec:: { SnapshotVecDelegate , SnapshotVec } ;
4546use std:: cell:: RefCell ;
4647use std:: fmt;
48+ use std:: marker:: PhantomData ;
4749use std:: rc:: Rc ;
4850use syntax:: abi:: Abi ;
4951use hir;
5052use util:: nodemap:: FnvHashMap ;
5153
54+ struct InferredObligationsSnapshotVecDelegate < ' tcx > {
55+ phantom : PhantomData < & ' tcx i32 > ,
56+ }
57+ impl < ' tcx > SnapshotVecDelegate for InferredObligationsSnapshotVecDelegate < ' tcx > {
58+ type Value = PredicateObligation < ' tcx > ;
59+ type Undo = ( ) ;
60+ fn reverse ( _: & mut Vec < Self :: Value > , _: Self :: Undo ) { }
61+ }
62+
5263pub struct SelectionContext < ' cx , ' gcx : ' cx +' tcx , ' tcx : ' cx > {
5364 infcx : & ' cx InferCtxt < ' cx , ' gcx , ' tcx > ,
5465
@@ -74,6 +85,8 @@ pub struct SelectionContext<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> {
7485 /// there is no type that the user could *actually name* that
7586 /// would satisfy it. This avoids crippling inference, basically.
7687 intercrate : bool ,
88+
89+ inferred_obligations : SnapshotVec < InferredObligationsSnapshotVecDelegate < ' tcx > > ,
7790}
7891
7992// A stack that walks back up the stack frame.
@@ -300,6 +313,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
300313 infcx : infcx,
301314 freshener : infcx. freshener ( ) ,
302315 intercrate : false ,
316+ inferred_obligations : SnapshotVec :: new ( ) ,
303317 }
304318 }
305319
@@ -308,6 +322,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
308322 infcx : infcx,
309323 freshener : infcx. freshener ( ) ,
310324 intercrate : true ,
325+ inferred_obligations : SnapshotVec :: new ( ) ,
311326 }
312327 }
313328
@@ -1977,9 +1992,9 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
19771992 }
19781993
19791994 FnPointerCandidate => {
1980- let fn_type =
1995+ let data =
19811996 self . confirm_fn_pointer_candidate ( obligation) ?;
1982- Ok ( VtableFnPointer ( fn_type ) )
1997+ Ok ( VtableFnPointer ( data ) )
19831998 }
19841999
19852000 ProjectionCandidate => {
@@ -2227,7 +2242,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
22272242
22282243 fn confirm_object_candidate ( & mut self ,
22292244 obligation : & TraitObligation < ' tcx > )
2230- -> VtableObjectData < ' tcx >
2245+ -> VtableObjectData < ' tcx , PredicateObligation < ' tcx > >
22312246 {
22322247 debug ! ( "confirm_object_candidate({:?})" ,
22332248 obligation) ;
@@ -2279,15 +2294,16 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
22792294
22802295 }
22812296
2297+ // FIXME(#32730) propagate obligations
22822298 VtableObjectData {
22832299 upcast_trait_ref : upcast_trait_ref. unwrap ( ) ,
22842300 vtable_base : vtable_base,
2301+ nested : vec ! [ ]
22852302 }
22862303 }
22872304
2288- fn confirm_fn_pointer_candidate ( & mut self ,
2289- obligation : & TraitObligation < ' tcx > )
2290- -> Result < ty:: Ty < ' tcx > , SelectionError < ' tcx > >
2305+ fn confirm_fn_pointer_candidate ( & mut self , obligation : & TraitObligation < ' tcx > )
2306+ -> Result < VtableFnPointerData < ' tcx , PredicateObligation < ' tcx > > , SelectionError < ' tcx > >
22912307 {
22922308 debug ! ( "confirm_fn_pointer_candidate({:?})" ,
22932309 obligation) ;
@@ -2305,7 +2321,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
23052321 self . confirm_poly_trait_refs ( obligation. cause . clone ( ) ,
23062322 obligation. predicate . to_poly_trait_ref ( ) ,
23072323 trait_ref) ?;
2308- Ok ( self_ty)
2324+ // FIXME(#32730) propagate obligations
2325+ Ok ( VtableFnPointerData { fn_ty : self_ty, nested : vec ! [ ] } )
23092326 }
23102327
23112328 fn confirm_closure_candidate ( & mut self ,
0 commit comments