rustc: remove Gc<Def> and depth from DefUpvar.

This commit is contained in:
Eduard Burtescu 2014-09-15 01:22:50 +03:00
parent 7c5df404b0
commit 74b8868b5f
9 changed files with 10 additions and 21 deletions

View file

@ -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

View file

@ -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;
@ -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))
}

View file

@ -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),
@ -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
@ -70,7 +66,7 @@ impl Def {
}
DefLocal(id) |
DefSelfTy(id) |
DefUpvar(id, _, _, _, _) |
DefUpvar(id, _, _) |
DefRegion(id) |
DefTyParamBinder(id) |
DefLabel(id) => {

View file

@ -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) => {

View file

@ -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;
@ -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 {
@ -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());

View file

@ -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

View file

@ -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) {

View file

@ -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);
}

View file

@ -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 {
@ -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,