Skip to content

Commit ab9c773

Browse files
committed
librustc: remove unused DefUpvar field.
1 parent 11ef6f1 commit ab9c773

File tree

8 files changed

+15
-30
lines changed

8 files changed

+15
-30
lines changed

src/librustc/middle/astencode.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -448,10 +448,8 @@ impl tr for def::Def {
448448
def::DefPrimTy(p) => def::DefPrimTy(p),
449449
def::DefTyParam(s, index, def_id, n) => def::DefTyParam(s, index, def_id.tr(dcx), n),
450450
def::DefUse(did) => def::DefUse(did.tr(dcx)),
451-
def::DefUpvar(nid1, nid2, nid3) => {
452-
def::DefUpvar(dcx.tr_id(nid1),
453-
dcx.tr_id(nid2),
454-
dcx.tr_id(nid3))
451+
def::DefUpvar(nid1, nid2) => {
452+
def::DefUpvar(dcx.tr_id(nid1), dcx.tr_id(nid2))
455453
}
456454
def::DefStruct(did) => def::DefStruct(did.tr(dcx)),
457455
def::DefRegion(nid) => def::DefRegion(dcx.tr_id(nid)),

src/librustc/middle/def.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ pub enum Def {
4343
DefTyParam(ParamSpace, u32, ast::DefId, ast::Name),
4444
DefUse(ast::DefId),
4545
DefUpvar(ast::NodeId, // id of closed over local
46-
ast::NodeId, // expr node that creates the closure
47-
ast::NodeId), // block node for the closest enclosing proc
48-
// or unboxed closure, DUMMY_NODE_ID otherwise
46+
ast::NodeId), // expr node that creates the closure
4947

5048
/// Note that if it's a tuple struct's definition, the node id of the ast::DefId
5149
/// may either refer to the item definition's id or the StructDef.ctor_id.
@@ -145,7 +143,7 @@ impl Def {
145143
}
146144
DefLocal(id) |
147145
DefSelfTy(id) |
148-
DefUpvar(id, _, _) |
146+
DefUpvar(id, _) |
149147
DefRegion(id) |
150148
DefTyParamBinder(id) |
151149
DefLabel(id) => {

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
593593
}))
594594
}
595595

596-
def::DefUpvar(var_id, fn_node_id, _) => {
596+
def::DefUpvar(var_id, fn_node_id) => {
597597
let ty = try!(self.node_ty(fn_node_id));
598598
match ty.sty {
599599
ty::ty_closure(closure_id, _, _) => {

src/librustc_resolve/lib.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ enum RibKind {
243243

244244
// We passed through a closure scope at the given node ID.
245245
// Translate upvars as appropriate.
246-
ClosureRibKind(NodeId /* func id */, NodeId /* body id if proc or unboxed */),
246+
ClosureRibKind(NodeId /* func id */),
247247

248248
// We passed through an impl or trait and are now in one of its
249249
// methods. Allow references to ty params that impl or trait
@@ -2605,18 +2605,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26052605
DlDef(d @ DefLocal(_)) => {
26062606
let node_id = d.def_id().node;
26072607
let mut def = d;
2608-
let mut last_proc_body_id = ast::DUMMY_NODE_ID;
26092608
for rib in ribs.iter() {
26102609
match rib.kind {
26112610
NormalRibKind => {
26122611
// Nothing to do. Continue.
26132612
}
2614-
ClosureRibKind(function_id, maybe_proc_body) => {
2613+
ClosureRibKind(function_id) => {
26152614
let prev_def = def;
2616-
if maybe_proc_body != ast::DUMMY_NODE_ID {
2617-
last_proc_body_id = maybe_proc_body;
2618-
}
2619-
def = DefUpvar(node_id, function_id, last_proc_body_id);
2615+
def = DefUpvar(node_id, function_id);
26202616

26212617
let mut seen = self.freevars_seen.borrow_mut();
26222618
let seen = match seen.entry(function_id) {
@@ -4523,7 +4519,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
45234519

45244520
ExprClosure(capture_clause, _, ref fn_decl, ref block) => {
45254521
self.capture_mode_map.insert(expr.id, capture_clause);
4526-
self.resolve_function(ClosureRibKind(expr.id, ast::DUMMY_NODE_ID),
4522+
self.resolve_function(ClosureRibKind(expr.id),
45274523
Some(&**fn_decl), NoTypeParameters,
45284524
&**block);
45294525
}

src/librustc_trans/trans/_match.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1228,19 +1228,19 @@ pub fn trans_match<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
12281228
fn is_discr_reassigned(bcx: Block, discr: &ast::Expr, body: &ast::Expr) -> bool {
12291229
let (vid, field) = match discr.node {
12301230
ast::ExprPath(_) | ast::ExprQPath(_) => match bcx.def(discr.id) {
1231-
def::DefLocal(vid) | def::DefUpvar(vid, _, _) => (vid, None),
1231+
def::DefLocal(vid) | def::DefUpvar(vid, _) => (vid, None),
12321232
_ => return false
12331233
},
12341234
ast::ExprField(ref base, field) => {
12351235
let vid = match bcx.tcx().def_map.borrow().get(&base.id) {
1236-
Some(&def::DefLocal(vid)) | Some(&def::DefUpvar(vid, _, _)) => vid,
1236+
Some(&def::DefLocal(vid)) | Some(&def::DefUpvar(vid, _)) => vid,
12371237
_ => return false
12381238
};
12391239
(vid, Some(mc::NamedField(field.node.name)))
12401240
},
12411241
ast::ExprTupField(ref base, field) => {
12421242
let vid = match bcx.tcx().def_map.borrow().get(&base.id) {
1243-
Some(&def::DefLocal(vid)) | Some(&def::DefUpvar(vid, _, _)) => vid,
1243+
Some(&def::DefLocal(vid)) | Some(&def::DefUpvar(vid, _)) => vid,
12441244
_ => return false
12451245
};
12461246
(vid, Some(mc::PositionalField(field.node)))

src/librustc_trans/trans/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
12631263
let _icx = push_ctxt("trans_local_var");
12641264

12651265
match def {
1266-
def::DefUpvar(nid, _, _) => {
1266+
def::DefUpvar(nid, _) => {
12671267
// Can't move upvars, so this is never a ZeroMemLastUse.
12681268
let local_ty = node_id_type(bcx, nid);
12691269
match bcx.fcx.llupvars.borrow().get(&nid) {

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4622,7 +4622,7 @@ pub fn type_scheme_for_def<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
46224622
defn: def::Def)
46234623
-> TypeScheme<'tcx> {
46244624
match defn {
4625-
def::DefLocal(nid) | def::DefUpvar(nid, _, _) => {
4625+
def::DefLocal(nid) | def::DefUpvar(nid, _) => {
46264626
let typ = fcx.local_ty(sp, nid);
46274627
return no_params(typ);
46284628
}

src/librustc_typeck/check/regionck.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,9 @@ pub struct Rcx<'a, 'tcx: 'a> {
177177
fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region {
178178
let tcx = fcx.tcx();
179179
match def {
180-
def::DefLocal(node_id) => {
180+
def::DefLocal(node_id) | def::DefUpvar(node_id, _) => {
181181
tcx.region_maps.var_region(node_id)
182182
}
183-
def::DefUpvar(node_id, _, body_id) => {
184-
if body_id == ast::DUMMY_NODE_ID {
185-
tcx.region_maps.var_region(node_id)
186-
} else {
187-
ReScope(CodeExtent::from_node_id(body_id))
188-
}
189-
}
190183
_ => {
191184
tcx.sess.bug(&format!("unexpected def in region_of_def: {:?}",
192185
def)[])

0 commit comments

Comments
 (0)