@@ -126,7 +126,7 @@ use middle::ty::{ReScope};
126
126
use middle:: ty:: { mod, Ty , MethodCall } ;
127
127
use middle:: infer;
128
128
use middle:: pat_util;
129
- use util:: nodemap:: { DefIdMap , NodeMap , FnvHashMap } ;
129
+ use util:: nodemap:: { FnvHashMap } ;
130
130
use util:: ppaux:: { ty_to_string, Repr } ;
131
131
132
132
use syntax:: { ast, ast_util} ;
@@ -446,47 +446,6 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> {
446
446
}
447
447
}
448
448
449
- impl < ' fcx , ' tcx > mc:: Typer < ' tcx > for Rcx < ' fcx , ' tcx > {
450
- fn tcx < ' a > ( & ' a self ) -> & ' a ty:: ctxt < ' tcx > {
451
- self . fcx . ccx . tcx
452
- }
453
-
454
- fn node_ty ( & self , id : ast:: NodeId ) -> mc:: McResult < Ty < ' tcx > > {
455
- let t = self . resolve_node_type ( id) ;
456
- if ty:: type_is_error ( t) { Err ( ( ) ) } else { Ok ( t) }
457
- }
458
-
459
- fn node_method_ty ( & self , method_call : MethodCall ) -> Option < Ty < ' tcx > > {
460
- self . resolve_method_type ( method_call)
461
- }
462
-
463
- fn adjustments < ' a > ( & ' a self ) -> & ' a RefCell < NodeMap < ty:: AutoAdjustment < ' tcx > > > {
464
- & self . fcx . inh . adjustments
465
- }
466
-
467
- fn is_method_call ( & self , id : ast:: NodeId ) -> bool {
468
- self . fcx . inh . method_map . borrow ( ) . contains_key ( & MethodCall :: expr ( id) )
469
- }
470
-
471
- fn temporary_scope ( & self , id : ast:: NodeId ) -> Option < CodeExtent > {
472
- self . tcx ( ) . region_maps . temporary_scope ( id)
473
- }
474
-
475
- fn upvar_borrow ( & self , id : ty:: UpvarId ) -> ty:: UpvarBorrow {
476
- self . fcx . inh . upvar_borrow_map . borrow ( ) [ id] . clone ( )
477
- }
478
-
479
- fn capture_mode ( & self , closure_expr_id : ast:: NodeId )
480
- -> ast:: CaptureClause {
481
- self . tcx ( ) . capture_modes . borrow ( ) [ closure_expr_id] . clone ( )
482
- }
483
-
484
- fn unboxed_closures < ' a > ( & ' a self )
485
- -> & ' a RefCell < DefIdMap < ty:: UnboxedClosure < ' tcx > > > {
486
- & self . fcx . inh . unboxed_closures
487
- }
488
- }
489
-
490
449
impl < ' a , ' tcx , ' v > Visitor < ' v > for Rcx < ' a , ' tcx > {
491
450
// (..) FIXME(#3238) should use visit_pat, not visit_arm/visit_local,
492
451
// However, right now we run into an issue whereby some free
@@ -767,7 +726,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
767
726
constrain_bindings_in_pat ( & * * pat, rcx) ;
768
727
769
728
{
770
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
729
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
771
730
let pat_ty = rcx. resolve_node_type ( pat. id ) ;
772
731
let pat_cmt = mc. cat_rvalue ( pat. id ,
773
732
pat. span ,
@@ -1080,7 +1039,7 @@ fn constrain_callee(rcx: &mut Rcx,
1080
1039
ty:: RegionTraitStore ( r, _) => {
1081
1040
// While we're here, link the closure's region with a unique
1082
1041
// immutable borrow (gathered later in borrowck)
1083
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1042
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1084
1043
let expr_cmt = ignore_err ! ( mc. cat_expr( callee_expr) ) ;
1085
1044
link_region ( rcx, callee_expr. span , call_region,
1086
1045
ty:: UniqueImmBorrow , expr_cmt) ;
@@ -1189,7 +1148,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
1189
1148
method. ty. repr( rcx. tcx( ) ) ) [ ] )
1190
1149
} ;
1191
1150
{
1192
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1151
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1193
1152
let self_cmt = ignore_err ! ( mc. cat_expr_autoderefd( deref_expr, i) ) ;
1194
1153
link_region ( rcx, deref_expr. span , r,
1195
1154
ty:: BorrowKind :: from_mutbl ( m) , self_cmt) ;
@@ -1285,7 +1244,7 @@ fn link_addr_of(rcx: &mut Rcx, expr: &ast::Expr,
1285
1244
debug ! ( "link_addr_of(base=?)" ) ;
1286
1245
1287
1246
let cmt = {
1288
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1247
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1289
1248
ignore_err ! ( mc. cat_expr( base) )
1290
1249
} ;
1291
1250
link_region_from_node_type ( rcx, expr. span , expr. id , mutability, cmt) ;
@@ -1300,7 +1259,7 @@ fn link_local(rcx: &Rcx, local: &ast::Local) {
1300
1259
None => { return ; }
1301
1260
Some ( ref expr) => & * * expr,
1302
1261
} ;
1303
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1262
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1304
1263
let discr_cmt = ignore_err ! ( mc. cat_expr( init_expr) ) ;
1305
1264
link_pattern ( rcx, mc, discr_cmt, & * local. pat ) ;
1306
1265
}
@@ -1310,7 +1269,7 @@ fn link_local(rcx: &Rcx, local: &ast::Local) {
1310
1269
/// linked to the lifetime of its guarantor (if any).
1311
1270
fn link_match ( rcx : & Rcx , discr : & ast:: Expr , arms : & [ ast:: Arm ] ) {
1312
1271
debug ! ( "regionck::for_match()" ) ;
1313
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1272
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1314
1273
let discr_cmt = ignore_err ! ( mc. cat_expr( discr) ) ;
1315
1274
debug ! ( "discr_cmt={}" , discr_cmt. repr( rcx. tcx( ) ) ) ;
1316
1275
for arm in arms. iter ( ) {
@@ -1325,7 +1284,7 @@ fn link_match(rcx: &Rcx, discr: &ast::Expr, arms: &[ast::Arm]) {
1325
1284
/// linked to the lifetime of its guarantor (if any).
1326
1285
fn link_fn_args ( rcx : & Rcx , body_scope : CodeExtent , args : & [ ast:: Arg ] ) {
1327
1286
debug ! ( "regionck::link_fn_args(body_scope={})" , body_scope) ;
1328
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1287
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1329
1288
for arg in args. iter ( ) {
1330
1289
let arg_ty = rcx. fcx . node_ty ( arg. id ) ;
1331
1290
let re_scope = ty:: ReScope ( body_scope) ;
@@ -1340,7 +1299,7 @@ fn link_fn_args(rcx: &Rcx, body_scope: CodeExtent, args: &[ast::Arg]) {
1340
1299
/// Link lifetimes of any ref bindings in `root_pat` to the pointers found in the discriminant, if
1341
1300
/// needed.
1342
1301
fn link_pattern < ' a , ' tcx > ( rcx : & Rcx < ' a , ' tcx > ,
1343
- mc : mc:: MemCategorizationContext < Rcx < ' a , ' tcx > > ,
1302
+ mc : mc:: MemCategorizationContext < FnCtxt < ' a , ' tcx > > ,
1344
1303
discr_cmt : mc:: cmt < ' tcx > ,
1345
1304
root_pat : & ast:: Pat ) {
1346
1305
debug ! ( "link_pattern(discr_cmt={}, root_pat={})" ,
@@ -1379,7 +1338,7 @@ fn link_autoref(rcx: &Rcx,
1379
1338
autoref : & ty:: AutoRef ) {
1380
1339
1381
1340
debug ! ( "link_autoref(autoref={})" , autoref) ;
1382
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1341
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1383
1342
let expr_cmt = ignore_err ! ( mc. cat_expr_autoderefd( expr, autoderefs) ) ;
1384
1343
debug ! ( "expr_cmt={}" , expr_cmt. repr( rcx. tcx( ) ) ) ;
1385
1344
@@ -1401,7 +1360,7 @@ fn link_by_ref(rcx: &Rcx,
1401
1360
let tcx = rcx. tcx ( ) ;
1402
1361
debug ! ( "link_by_ref(expr={}, callee_scope={})" ,
1403
1362
expr. repr( tcx) , callee_scope) ;
1404
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1363
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1405
1364
let expr_cmt = ignore_err ! ( mc. cat_expr( expr) ) ;
1406
1365
let borrow_region = ty:: ReScope ( callee_scope) ;
1407
1366
link_region ( rcx, expr. span , borrow_region, ty:: ImmBorrow , expr_cmt) ;
@@ -1669,7 +1628,7 @@ fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
1669
1628
/// assignment expression.
1670
1629
fn adjust_borrow_kind_for_assignment_lhs ( rcx : & Rcx ,
1671
1630
lhs : & ast:: Expr ) {
1672
- let mc = mc:: MemCategorizationContext :: new ( rcx) ;
1631
+ let mc = mc:: MemCategorizationContext :: new ( rcx. fcx ) ;
1673
1632
let cmt = ignore_err ! ( mc. cat_expr( lhs) ) ;
1674
1633
adjust_upvar_borrow_kind_for_mut ( rcx, cmt) ;
1675
1634
}
0 commit comments