Skip to content

Commit

Permalink
rustc: remove Gc<Def> and depth from DefUpvar.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Sep 18, 2014
1 parent 7c5df40 commit 74b8868
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Expand Up @@ -29,7 +29,7 @@ This API is completely unstable and subject to change.
html_root_url = "http://doc.rust-lang.org/master/")]

#![allow(deprecated)]
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote)]
#![feature(macro_rules, globs, struct_variant, quote)]
#![feature(default_type_params, phase, unsafe_destructor)]

#![allow(unknown_features)] // NOTE: Remove after next snapshot
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/middle/astencode.rs
Expand Up @@ -41,7 +41,6 @@ use syntax;
use libc;
use std::io::Seek;
use std::mem;
use std::gc::GC;
use std::rc::Rc;

use rbml::io::SeekableMemWriter;
Expand Down Expand Up @@ -471,10 +470,8 @@ impl tr for def::Def {
def::DefPrimTy(p) => def::DefPrimTy(p),
def::DefTyParam(s, did, v) => def::DefTyParam(s, did.tr(dcx), v),
def::DefUse(did) => def::DefUse(did.tr(dcx)),
def::DefUpvar(nid1, def, depth, nid2, nid3) => {
def::DefUpvar(nid1, nid2, nid3) => {
def::DefUpvar(dcx.tr_id(nid1),
box(GC) (*def).tr(dcx),
depth,
dcx.tr_id(nid2),
dcx.tr_id(nid3))
}
Expand Down
6 changes: 1 addition & 5 deletions src/librustc/middle/def.rs
Expand Up @@ -12,8 +12,6 @@ use middle::subst::ParamSpace;
use syntax::ast;
use syntax::ast_util::local_def;

use std::gc::Gc;

#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum Def {
DefFn(ast::DefId, ast::FnStyle),
Expand All @@ -31,8 +29,6 @@ pub enum Def {
DefTyParam(ParamSpace, ast::DefId, uint),
DefUse(ast::DefId),
DefUpvar(ast::NodeId, // id of closed over local
Gc<Def>, // closed over def
u32, // number of closures implicitely capturing this local
ast::NodeId, // expr node that creates the closure
ast::NodeId), // block node for the closest enclosing proc
// or unboxed closure, DUMMY_NODE_ID otherwise
Expand Down Expand Up @@ -70,7 +66,7 @@ impl Def {
}
DefLocal(id) |
DefSelfTy(id) |
DefUpvar(id, _, _, _, _) |
DefUpvar(id, _, _) |
DefRegion(id) |
DefTyParamBinder(id) |
DefLabel(id) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Expand Up @@ -546,7 +546,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
}))
}

def::DefUpvar(var_id, _, _, fn_node_id, _) => {
def::DefUpvar(var_id, fn_node_id, _) => {
let ty = if_ok!(self.node_ty(fn_node_id));
match ty::get(ty).sty {
ty::ty_closure(ref closure_ty) => {
Expand Down
6 changes: 1 addition & 5 deletions src/librustc/middle/resolve.rs
Expand Up @@ -60,7 +60,6 @@ use syntax::visit::Visitor;

use std::collections::{HashMap, HashSet};
use std::cell::{Cell, RefCell};
use std::gc::GC;
use std::mem::replace;
use std::rc::{Rc, Weak};
use std::uint;
Expand Down Expand Up @@ -3849,7 +3848,6 @@ impl<'a> Resolver<'a> {
DlDef(d @ DefLocal(_)) => {
let node_id = d.def_id().node;
let mut def = d;
let mut depth = 0;
let mut last_proc_body_id = ast::DUMMY_NODE_ID;
for rib in ribs.iter() {
match rib.kind {
Expand All @@ -3861,9 +3859,7 @@ impl<'a> Resolver<'a> {
if maybe_proc_body != ast::DUMMY_NODE_ID {
last_proc_body_id = maybe_proc_body;
}
def = DefUpvar(node_id, box(GC) def,
depth, function_id, last_proc_body_id);
depth += 1;
def = DefUpvar(node_id, function_id, last_proc_body_id);

let mut seen = self.freevars_seen.borrow_mut();
let seen = seen.find_or_insert(function_id, NodeSet::new());
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/_match.rs
Expand Up @@ -1226,7 +1226,7 @@ pub fn trans_match<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
fn is_discr_reassigned(bcx: Block, discr: &ast::Expr, body: &ast::Expr) -> bool {
match discr.node {
ast::ExprPath(..) => match bcx.def(discr.id) {
def::DefLocal(vid) | def::DefUpvar(vid, _, _, _, _) => {
def::DefLocal(vid) | def::DefUpvar(vid, _, _) => {
let mut rc = ReassignmentChecker {
node: vid,
reassigned: false
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/expr.rs
Expand Up @@ -1176,7 +1176,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let _icx = push_ctxt("trans_local_var");

match def {
def::DefUpvar(nid, _, _, _, _) => {
def::DefUpvar(nid, _, _) => {
// Can't move upvars, so this is never a ZeroMemLastUse.
let local_ty = node_id_type(bcx, nid);
match bcx.fcx.llupvars.borrow().find(&nid) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/mod.rs
Expand Up @@ -5026,7 +5026,7 @@ pub fn polytype_for_def(fcx: &FnCtxt,
defn: def::Def)
-> Polytype {
match defn {
def::DefLocal(nid) | def::DefUpvar(nid, _, _, _, _) => {
def::DefLocal(nid) | def::DefUpvar(nid, _, _) => {
let typ = fcx.local_ty(sp, nid);
return no_params(typ);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/typeck/check/regionck.rs
Expand Up @@ -244,7 +244,7 @@ fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region {
def::DefLocal(node_id) => {
tcx.region_maps.var_region(node_id)
}
def::DefUpvar(node_id, _, _, _, body_id) => {
def::DefUpvar(node_id, _, body_id) => {
if body_id == ast::DUMMY_NODE_ID {
tcx.region_maps.var_region(node_id)
} else {
Expand Down Expand Up @@ -1029,7 +1029,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
// determining the final borrow_kind) and propagate that as
// a constraint on the outer closure.
match freevar.def {
def::DefUpvar(var_id, _, _, outer_closure_id, _) => {
def::DefUpvar(var_id, outer_closure_id, _) => {
// thing being captured is itself an upvar:
let outer_upvar_id = ty::UpvarId {
var_id: var_id,
Expand Down

4 comments on commit 74b8868

@bors
Copy link
Contributor

@bors bors commented on 74b8868 Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from nikomatsakis
at eddyb@74b8868

@bors
Copy link
Contributor

@bors bors commented on 74b8868 Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging eddyb/rust/def-no-gc = 74b8868 into auto

@bors
Copy link
Contributor

@bors bors commented on 74b8868 Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eddyb/rust/def-no-gc = 74b8868 merged ok, testing candidate = eb74a0e7

@bors
Copy link
Contributor

@bors bors commented on 74b8868 Sep 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.