@@ -532,11 +532,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
532
532
obligation. repr( self . tcx( ) ) ) ;
533
533
534
534
self . infcx . probe ( |snapshot| {
535
- let ( skol_obligation_trait_ref, skol_map) =
536
- self . infcx ( ) . skolemize_late_bound_regions ( & obligation. predicate , snapshot) ;
537
- match self . match_impl ( impl_def_id, obligation, snapshot,
538
- & skol_map, skol_obligation_trait_ref. trait_ref . clone ( ) ) {
539
- Ok ( substs) => {
535
+ match self . match_impl ( impl_def_id, obligation, snapshot) {
536
+ Ok ( ( substs, skol_map) ) => {
540
537
let vtable_impl = self . vtable_impl ( impl_def_id,
541
538
substs,
542
539
obligation. cause . clone ( ) ,
@@ -1160,10 +1157,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1160
1157
let all_impls = self . all_impls ( def_id) ;
1161
1158
for & impl_def_id in & all_impls {
1162
1159
self . infcx . probe ( |snapshot| {
1163
- let ( skol_obligation_trait_pred, skol_map) =
1164
- self . infcx ( ) . skolemize_late_bound_regions ( & obligation. predicate , snapshot) ;
1165
- match self . match_impl ( impl_def_id, obligation, snapshot,
1166
- & skol_map, skol_obligation_trait_pred. trait_ref . clone ( ) ) {
1160
+ match self . match_impl ( impl_def_id, obligation, snapshot) {
1167
1161
Ok ( _) => {
1168
1162
candidates. vec . push ( ImplCandidate ( impl_def_id) ) ;
1169
1163
}
@@ -2115,11 +2109,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2115
2109
// First, create the substitutions by matching the impl again,
2116
2110
// this time not in a probe.
2117
2111
self . infcx . commit_if_ok ( |snapshot| {
2118
- let ( skol_obligation_trait_ref, skol_map) =
2119
- self . infcx ( ) . skolemize_late_bound_regions ( & obligation. predicate , snapshot) ;
2120
- let substs =
2112
+ let ( substs, skol_map) =
2121
2113
self . rematch_impl ( impl_def_id, obligation,
2122
- snapshot, & skol_map , skol_obligation_trait_ref . trait_ref ) ;
2114
+ snapshot) ;
2123
2115
debug ! ( "confirm_impl_candidate substs={}" , substs. repr( self . tcx( ) ) ) ;
2124
2116
Ok ( self . vtable_impl ( impl_def_id, substs, obligation. cause . clone ( ) ,
2125
2117
obligation. recursion_depth + 1 , skol_map, snapshot) )
@@ -2306,14 +2298,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2306
2298
fn rematch_impl ( & mut self ,
2307
2299
impl_def_id : ast:: DefId ,
2308
2300
obligation : & TraitObligation < ' tcx > ,
2309
- snapshot : & infer:: CombinedSnapshot ,
2310
- skol_map : & infer:: SkolemizationMap ,
2311
- skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
2312
- -> Normalized < ' tcx , Substs < ' tcx > >
2301
+ snapshot : & infer:: CombinedSnapshot )
2302
+ -> ( Normalized < ' tcx , Substs < ' tcx > > , infer:: SkolemizationMap )
2313
2303
{
2314
- match self . match_impl ( impl_def_id, obligation, snapshot,
2315
- skol_map, skol_obligation_trait_ref) {
2316
- Ok ( substs) => substs,
2304
+ match self . match_impl ( impl_def_id, obligation, snapshot) {
2305
+ Ok ( ( substs, skol_map) ) => ( substs, skol_map) ,
2317
2306
Err ( ( ) ) => {
2318
2307
self . tcx ( ) . sess . bug (
2319
2308
& format ! ( "Impl {} was matchable against {} but now is not" ,
@@ -2326,10 +2315,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2326
2315
fn match_impl ( & mut self ,
2327
2316
impl_def_id : ast:: DefId ,
2328
2317
obligation : & TraitObligation < ' tcx > ,
2329
- snapshot : & infer:: CombinedSnapshot ,
2330
- skol_map : & infer:: SkolemizationMap ,
2331
- skol_obligation_trait_ref : Rc < ty:: TraitRef < ' tcx > > )
2332
- -> Result < Normalized < ' tcx , Substs < ' tcx > > , ( ) >
2318
+ snapshot : & infer:: CombinedSnapshot )
2319
+ -> Result < ( Normalized < ' tcx , Substs < ' tcx > > ,
2320
+ infer:: SkolemizationMap ) , ( ) >
2333
2321
{
2334
2322
let impl_trait_ref = ty:: impl_trait_ref ( self . tcx ( ) , impl_def_id) . unwrap ( ) ;
2335
2323
@@ -2340,6 +2328,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2340
2328
return Err ( ( ) ) ;
2341
2329
}
2342
2330
2331
+ let ( skol_obligation, skol_map) = self . infcx ( ) . skolemize_late_bound_regions (
2332
+ & obligation. predicate ,
2333
+ snapshot) ;
2334
+ let skol_obligation_trait_ref = skol_obligation. trait_ref ;
2335
+
2343
2336
let impl_substs = util:: fresh_type_vars_for_impl ( self . infcx ,
2344
2337
obligation. cause . span ,
2345
2338
impl_def_id) ;
@@ -2370,17 +2363,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2370
2363
return Err ( ( ) ) ;
2371
2364
}
2372
2365
2373
- if let Err ( e) = self . infcx . leak_check ( skol_map, snapshot) {
2366
+ if let Err ( e) = self . infcx . leak_check ( & skol_map, snapshot) {
2374
2367
debug ! ( "match_impl: failed leak check due to `{}`" ,
2375
2368
ty:: type_err_to_str( self . tcx( ) , & e) ) ;
2376
2369
return Err ( ( ) ) ;
2377
2370
}
2378
2371
2379
2372
debug ! ( "match_impl: success impl_substs={}" , impl_substs. repr( self . tcx( ) ) ) ;
2380
- Ok ( Normalized {
2373
+ Ok ( ( Normalized {
2381
2374
value : impl_substs,
2382
2375
obligations : impl_trait_ref. obligations
2383
- } )
2376
+ } , skol_map ) )
2384
2377
}
2385
2378
2386
2379
fn fast_reject_trait_refs ( & mut self ,
0 commit comments