@@ -10,10 +10,9 @@ use rustc::traits::Reveal;
10
10
use rustc:: ty:: layout:: { self , Layout , Size , Align , HasDataLayout } ;
11
11
use rustc:: ty:: subst:: { Subst , Substs , Kind } ;
12
12
use rustc:: ty:: { self , Ty , TyCtxt , TypeFoldable , Binder } ;
13
- use rustc:: traits;
14
13
use rustc_data_structures:: indexed_vec:: Idx ;
15
- use syntax:: codemap:: { self , DUMMY_SP , Span } ;
16
- use syntax:: ast:: { self , Mutability } ;
14
+ use syntax:: codemap:: { self , DUMMY_SP } ;
15
+ use syntax:: ast:: Mutability ;
17
16
use syntax:: abi:: Abi ;
18
17
19
18
use super :: { EvalError , EvalResult , EvalErrorKind , GlobalId , Lvalue , LvalueExtra , Memory ,
@@ -2312,7 +2311,7 @@ fn resolve_associated_item<'a, 'tcx>(
2312
2311
) ;
2313
2312
2314
2313
let trait_ref = ty:: TraitRef :: from_method ( tcx, trait_id, rcvr_substs) ;
2315
- let vtbl = fulfill_obligation ( tcx, DUMMY_SP , ty:: Binder ( trait_ref) ) ;
2314
+ let vtbl = tcx. trans_fulfill_obligation ( DUMMY_SP , ty:: Binder ( trait_ref) ) ;
2316
2315
2317
2316
// Now that we know which impl is being used, we can dispatch to
2318
2317
// the actual function:
@@ -2419,85 +2418,6 @@ fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
2419
2418
ty. is_sized ( tcx, ty:: ParamEnv :: empty ( Reveal :: All ) , DUMMY_SP )
2420
2419
}
2421
2420
2422
- /// Attempts to resolve an obligation. The result is a shallow vtable resolution -- meaning that we
2423
- /// do not (necessarily) resolve all nested obligations on the impl. Note that type check should
2424
- /// guarantee to us that all nested obligations *could be* resolved if we wanted to.
2425
- fn fulfill_obligation < ' a , ' tcx > (
2426
- tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
2427
- span : Span ,
2428
- trait_ref : ty:: PolyTraitRef < ' tcx > ,
2429
- ) -> traits:: Vtable < ' tcx , ( ) > {
2430
- // Remove any references to regions; this helps improve caching.
2431
- let trait_ref = tcx. erase_regions ( & trait_ref) ;
2432
-
2433
- debug ! (
2434
- "trans::fulfill_obligation(trait_ref={:?}, def_id={:?})" ,
2435
- trait_ref,
2436
- trait_ref. def_id( )
2437
- ) ;
2438
-
2439
- // Do the initial selection for the obligation. This yields the
2440
- // shallow result we are looking for -- that is, what specific impl.
2441
- tcx. infer_ctxt ( ) . enter ( |infcx| {
2442
- let mut selcx = traits:: SelectionContext :: new ( & infcx) ;
2443
-
2444
- let obligation_cause = traits:: ObligationCause :: misc ( span, ast:: DUMMY_NODE_ID ) ;
2445
- let obligation = traits:: Obligation :: new (
2446
- obligation_cause,
2447
- ty:: ParamEnv :: empty ( Reveal :: All ) ,
2448
- trait_ref. to_poly_trait_predicate ( ) ,
2449
- ) ;
2450
-
2451
- let selection = match selcx. select ( & obligation) {
2452
- Ok ( Some ( selection) ) => selection,
2453
- Ok ( None ) => {
2454
- // Ambiguity can happen when monomorphizing during trans
2455
- // expands to some humongo type that never occurred
2456
- // statically -- this humongo type can then overflow,
2457
- // leading to an ambiguous result. So report this as an
2458
- // overflow bug, since I believe this is the only case
2459
- // where ambiguity can result.
2460
- debug ! (
2461
- "Encountered ambiguity selecting `{:?}` during trans, \
2462
- presuming due to overflow",
2463
- trait_ref
2464
- ) ;
2465
- tcx. sess . span_fatal (
2466
- span,
2467
- "reached the recursion limit during monomorphization \
2468
- (selection ambiguity)",
2469
- ) ;
2470
- }
2471
- Err ( e) => {
2472
- span_bug ! (
2473
- span,
2474
- "Encountered error `{:?}` selecting `{:?}` during trans" ,
2475
- e,
2476
- trait_ref
2477
- )
2478
- }
2479
- } ;
2480
-
2481
- debug ! ( "fulfill_obligation: selection={:?}" , selection) ;
2482
-
2483
- // Currently, we use a fulfillment context to completely resolve
2484
- // all nested obligations. This is because they can inform the
2485
- // inference of the impl's type parameters.
2486
- let mut fulfill_cx = traits:: FulfillmentContext :: new ( ) ;
2487
- let vtable = selection. map ( |predicate| {
2488
- debug ! (
2489
- "fulfill_obligation: register_predicate_obligation {:?}" ,
2490
- predicate
2491
- ) ;
2492
- fulfill_cx. register_predicate_obligation ( & infcx, predicate) ;
2493
- } ) ;
2494
- let vtable = infcx. drain_fulfillment_cx_or_panic ( span, & mut fulfill_cx, & vtable) ;
2495
-
2496
- debug ! ( "Cache miss: {:?} => {:?}" , trait_ref, vtable) ;
2497
- vtable
2498
- } )
2499
- }
2500
-
2501
2421
pub fn resolve_drop_in_place < ' a , ' tcx > (
2502
2422
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
2503
2423
ty : Ty < ' tcx > ,
0 commit comments