Switch Region information from uint to u32.

This reduces memory use for building librustc with -O from 1.88 to 1.76
GB.
This commit is contained in:
Huon Wilson 2014-12-04 12:06:42 -08:00
parent a548f8917b
commit a33a7d20de
17 changed files with 157 additions and 138 deletions

View File

@ -1449,7 +1449,7 @@ fn doc_generics<'tcx>(base_doc: rbml::Doc,
let space = subst::ParamSpace::from_uint(reader::doc_as_u64(doc) as uint);
let doc = reader::get_doc(rp_doc, tag_region_param_def_index);
let index = reader::doc_as_u64(doc) as uint;
let index = reader::doc_as_u64(doc) as u32;
let mut bounds = Vec::new();
reader::tagged_docs(rp_doc, tag_items_data_region, |p| {

View File

@ -281,7 +281,7 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> subst::RegionSubsts {
fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion {
match next(st) {
'a' => {
let id = parse_uint(st);
let id = parse_u32(st);
assert_eq!(next(st), '|');
ty::BrAnon(id)
}
@ -291,7 +291,7 @@ fn parse_bound_region(st: &mut PState, conv: conv_did) -> ty::BoundRegion {
ty::BrNamed(def, ident.name)
}
'f' => {
let id = parse_uint(st);
let id = parse_u32(st);
assert_eq!(next(st), '|');
ty::BrFresh(id)
}
@ -304,7 +304,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
match next(st) {
'b' => {
assert_eq!(next(st), '[');
let id = ty::DebruijnIndex::new(parse_uint(st));
let id = ty::DebruijnIndex::new(parse_u32(st));
assert_eq!(next(st), '|');
let br = parse_bound_region(st, |x,y| conv(x,y));
assert_eq!(next(st), ']');
@ -316,7 +316,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
assert_eq!(next(st), '|');
let space = parse_param_space(st);
assert_eq!(next(st), '|');
let index = parse_uint(st);
let index = parse_u32(st);
assert_eq!(next(st), '|');
let nm = token::str_to_ident(parse_str(st, ']')[]);
ty::ReEarlyBound(node_id, space, index, nm.name)
@ -421,7 +421,7 @@ fn parse_ty<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did) -> Ty<'tcx> {
'p' => {
let did = parse_def(st, TypeParameter, |x,y| conv(x,y));
debug!("parsed ty_param: did={}", did);
let index = parse_uint(st);
let index = parse_u32(st);
assert_eq!(next(st), '|');
let space = parse_param_space(st);
assert_eq!(next(st), '|');
@ -535,6 +535,13 @@ fn parse_uint(st: &mut PState) -> uint {
};
}
fn parse_u32(st: &mut PState) -> u32 {
let n = parse_uint(st);
let m = n as u32;
assert_eq!(m as uint, n);
m
}
fn parse_param_space(st: &mut PState) -> subst::ParamSpace {
subst::ParamSpace::from_uint(parse_uint(st))
}
@ -697,7 +704,7 @@ fn parse_type_param_def<'a, 'tcx>(st: &mut PState<'a, 'tcx>, conv: conv_did)
let def_id = parse_def(st, NominalType, |x,y| conv(x,y));
let space = parse_param_space(st);
assert_eq!(next(st), '|');
let index = parse_uint(st);
let index = parse_u32(st);
assert_eq!(next(st), '|');
let associated_with = parse_opt(st, |st| {
parse_def(st, NominalType, |x,y| conv(x,y))

View File

@ -39,7 +39,7 @@ pub enum Def {
DefAssociatedPath(TyParamProvenance, ast::Ident),
DefTrait(ast::DefId),
DefPrimTy(ast::PrimTy),
DefTyParam(ParamSpace, ast::DefId, uint),
DefTyParam(ParamSpace, ast::DefId, u32),
DefUse(ast::DefId),
DefUpvar(ast::NodeId, // id of closed over local
ast::NodeId, // expr node that creates the closure

View File

@ -870,11 +870,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
struct RebuildPathInfo<'a> {
path: &'a ast::Path,
// indexes to insert lifetime on path.lifetimes
indexes: Vec<uint>,
indexes: Vec<u32>,
// number of lifetimes we expect to see on the type referred by `path`
// (e.g., expected=1 for struct Foo<'a>)
expected: uint,
anon_nums: &'a HashSet<uint>,
expected: u32,
anon_nums: &'a HashSet<u32>,
region_names: &'a HashSet<ast::Name>
}
@ -885,8 +885,8 @@ struct Rebuilder<'a, 'tcx: 'a> {
generics: &'a ast::Generics,
same_regions: &'a [SameRegions],
life_giver: &'a LifeGiver,
cur_anon: Cell<uint>,
inserted_anons: RefCell<HashSet<uint>>,
cur_anon: Cell<u32>,
inserted_anons: RefCell<HashSet<u32>>,
}
enum FreshOrKept {
@ -976,7 +976,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}
fn extract_anon_nums_and_names(&self, same_regions: &SameRegions)
-> (HashSet<uint>, HashSet<ast::Name>) {
-> (HashSet<u32>, HashSet<ast::Name>) {
let mut anon_nums = HashSet::new();
let mut region_names = HashSet::new();
for br in same_regions.regions.iter() {
@ -1008,7 +1008,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
all_region_names
}
fn inc_cur_anon(&self, n: uint) {
fn inc_cur_anon(&self, n: u32) {
let anon = self.cur_anon.get();
self.cur_anon.set(anon+n);
}
@ -1021,12 +1021,12 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
self.cur_anon.set(anon);
}
fn inc_and_offset_cur_anon(&self, n: uint) {
fn inc_and_offset_cur_anon(&self, n: u32) {
self.inc_cur_anon(n);
self.offset_cur_anon();
}
fn track_anon(&self, anon: uint) {
fn track_anon(&self, anon: u32) {
self.inserted_anons.borrow_mut().insert(anon);
}
@ -1070,13 +1070,13 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
let lifetimes = last_seg.parameters.lifetimes();
for (i, lt) in lifetimes.iter().enumerate() {
if region_names.contains(&lt.name) {
insert.push(i);
insert.push(i as u32);
}
}
let rebuild_info = RebuildPathInfo {
path: &tr.path,
indexes: insert,
expected: lifetimes.len(),
expected: lifetimes.len() as u32,
anon_nums: &HashSet::new(),
region_names: region_names
};
@ -1096,7 +1096,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
fn rebuild_expl_self(&self,
expl_self_opt: Option<ast::ExplicitSelf_>,
lifetime: ast::Lifetime,
anon_nums: &HashSet<uint>,
anon_nums: &HashSet<u32>,
region_names: &HashSet<ast::Name>)
-> Option<ast::ExplicitSelf_> {
match expl_self_opt {
@ -1150,7 +1150,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
fn rebuild_args_ty(&self,
inputs: &[ast::Arg],
lifetime: ast::Lifetime,
anon_nums: &HashSet<uint>,
anon_nums: &HashSet<u32>,
region_names: &HashSet<ast::Name>)
-> Vec<ast::Arg> {
let mut new_inputs = Vec::new();
@ -1169,7 +1169,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
fn rebuild_output(&self, ty: &ast::FunctionRetTy,
lifetime: ast::Lifetime,
anon_nums: &HashSet<uint>,
anon_nums: &HashSet<u32>,
region_names: &HashSet<ast::Name>) -> ast::FunctionRetTy {
match *ty {
ast::Return(ref ret_ty) => ast::Return(
@ -1182,7 +1182,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
fn rebuild_arg_ty_or_output(&self,
ty: &ast::Ty,
lifetime: ast::Lifetime,
anon_nums: &HashSet<uint>,
anon_nums: &HashSet<u32>,
region_names: &HashSet<ast::Name>)
-> P<ast::Ty> {
let mut new_ty = P(ty.clone());
@ -1229,7 +1229,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
let generics = ty::lookup_item_type(self.tcx, did).generics;
let expected =
generics.regions.len(subst::TypeSpace);
generics.regions.len(subst::TypeSpace) as u32;
let lifetimes =
path.segments.last().unwrap().parameters.lifetimes();
let mut insert = Vec::new();
@ -1238,7 +1238,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
for (i, a) in range(anon,
anon+expected).enumerate() {
if anon_nums.contains(&a) {
insert.push(i);
insert.push(i as u32);
}
self.track_anon(a);
}
@ -1246,7 +1246,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
} else {
for (i, lt) in lifetimes.iter().enumerate() {
if region_names.contains(&lt.name) {
insert.push(i);
insert.push(i as u32);
}
}
}
@ -1363,7 +1363,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
}
} else {
for (i, lt) in data.lifetimes.iter().enumerate() {
if indexes.contains(&i) {
if indexes.contains(&(i as u32)) {
new_lts.push(lifetime);
} else {
new_lts.push(*lt);

View File

@ -41,7 +41,7 @@ use super::unify::InferCtxtMethodsForSimplyUnifiableTypes;
pub struct TypeFreshener<'a, 'tcx:'a> {
infcx: &'a InferCtxt<'a, 'tcx>,
freshen_count: uint,
freshen_count: u32,
freshen_map: hash_map::HashMap<ty::InferTy, Ty<'tcx>>,
}
@ -59,7 +59,7 @@ impl<'a, 'tcx> TypeFreshener<'a, 'tcx> {
key: ty::InferTy,
freshener: F)
-> Ty<'tcx> where
F: FnOnce(uint) -> ty::InferTy,
F: FnOnce(u32) -> ty::InferTy,
{
match opt_ty {
Some(ty) => { return ty.fold_with(self); }

View File

@ -33,7 +33,7 @@ use util::nodemap::{FnvHashMap, FnvHashSet};
use util::ppaux::Repr;
use std::cell::{Cell, RefCell};
use std::uint;
use std::u32;
use syntax::ast;
mod doc;
@ -196,8 +196,8 @@ pub struct RegionVarBindings<'a, 'tcx: 'a> {
lubs: RefCell<CombineMap>,
glbs: RefCell<CombineMap>,
skolemization_count: Cell<uint>,
bound_count: Cell<uint>,
skolemization_count: Cell<u32>,
bound_count: Cell<u32>,
// The undo log records actions that might later be undone.
//
@ -278,7 +278,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
AddVar(vid) => {
let mut var_origins = self.var_origins.borrow_mut();
var_origins.pop().unwrap();
assert_eq!(var_origins.len(), vid.index);
assert_eq!(var_origins.len(), vid.index as uint);
}
AddConstraint(ref constraint) => {
self.constraints.borrow_mut().remove(constraint);
@ -303,8 +303,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
self.skolemization_count.set(snapshot.skolemization_count);
}
pub fn num_vars(&self) -> uint {
self.var_origins.borrow().len()
pub fn num_vars(&self) -> u32 {
let len = self.var_origins.borrow().len();
// enforce no overflow
assert!(len as u32 as uint == len);
len as u32
}
pub fn new_region_var(&self, origin: RegionVariableOrigin<'tcx>) -> RegionVid {
@ -547,7 +550,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
match *self.values.borrow() {
None => {
self.tcx.sess.span_bug(
(*self.var_origins.borrow())[rid.index].span(),
(*self.var_origins.borrow())[rid.index as uint].span(),
"attempt to resolve region variable before values have \
been computed!")
}
@ -737,7 +740,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
(ReInfer(ReVar(v_id)), _) | (_, ReInfer(ReVar(v_id))) => {
self.tcx.sess.span_bug(
(*self.var_origins.borrow())[v_id.index].span(),
(*self.var_origins.borrow())[v_id.index as uint].span(),
format!("lub_concrete_regions invoked with \
non-concrete regions: {}, {}",
a,
@ -840,7 +843,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
(ReInfer(ReVar(v_id)), _) |
(_, ReInfer(ReVar(v_id))) => {
self.tcx.sess.span_bug(
(*self.var_origins.borrow())[v_id.index].span(),
(*self.var_origins.borrow())[v_id.index as uint].span(),
format!("glb_concrete_regions invoked with \
non-concrete regions: {}, {}",
a,
@ -972,7 +975,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
fn construct_var_data(&self) -> Vec<VarData> {
Vec::from_fn(self.num_vars(), |_| {
Vec::from_fn(self.num_vars() as uint, |_| {
VarData {
// All nodes are initially classified as contracting; during
// the expansion phase, we will shift the classification for
@ -1001,14 +1004,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
.repr(self.tcx));
match *constraint {
ConstrainRegSubVar(a_region, b_vid) => {
let b_data = &mut var_data[b_vid.index];
let b_data = &mut var_data[b_vid.index as uint];
self.expand_node(a_region, b_vid, b_data)
}
ConstrainVarSubVar(a_vid, b_vid) => {
match var_data[a_vid.index].value {
match var_data[a_vid.index as uint].value {
NoValue | ErrorValue => false,
Value(a_region) => {
let b_node = &mut var_data[b_vid.index];
let b_node = &mut var_data[b_vid.index as uint];
self.expand_node(a_region, b_vid, b_node)
}
}
@ -1089,16 +1092,16 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
false
}
ConstrainVarSubVar(a_vid, b_vid) => {
match var_data[b_vid.index].value {
match var_data[b_vid.index as uint].value {
NoValue | ErrorValue => false,
Value(b_region) => {
let a_data = &mut var_data[a_vid.index];
let a_data = &mut var_data[a_vid.index as uint];
self.contract_node(a_vid, a_data, b_region)
}
}
}
ConstrainVarSubReg(a_vid, b_region) => {
let a_data = &mut var_data[a_vid.index];
let a_data = &mut var_data[a_vid.index as uint];
self.contract_node(a_vid, a_data, b_region)
}
}
@ -1244,11 +1247,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
// idea is to report errors that derive from independent
// regions of the graph, but not those that derive from
// overlapping locations.
let mut dup_vec = Vec::from_elem(self.num_vars(), uint::MAX);
let mut dup_vec = Vec::from_elem(self.num_vars() as uint, u32::MAX);
let mut opt_graph = None;
for idx in range(0u, self.num_vars()) {
for idx in range(0u, self.num_vars() as uint) {
match var_data[idx].value {
Value(_) => {
/* Inference successful */
@ -1288,7 +1291,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
let graph = opt_graph.as_ref().unwrap();
let node_vid = RegionVid { index: idx };
let node_vid = RegionVid { index: idx as u32 };
match var_data[idx].classification {
Expanding => {
self.collect_error_for_expanding_node(
@ -1305,7 +1308,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
}
Vec::from_fn(self.num_vars(), |idx| var_data[idx].value)
Vec::from_fn(self.num_vars() as uint, |idx| var_data[idx].value)
}
fn construct_graph(&self) -> RegionGraph {
@ -1314,10 +1317,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
let constraints = self.constraints.borrow();
let num_edges = constraints.len();
let mut graph = graph::Graph::with_capacity(num_vars + 1,
let mut graph = graph::Graph::with_capacity(num_vars as uint + 1,
num_edges);
for _ in range(0u, num_vars) {
for _ in range(0, num_vars) {
graph.add_node(());
}
let dummy_idx = graph.add_node(());
@ -1325,17 +1328,17 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
for (constraint, _) in constraints.iter() {
match *constraint {
ConstrainVarSubVar(a_id, b_id) => {
graph.add_edge(NodeIndex(a_id.index),
NodeIndex(b_id.index),
graph.add_edge(NodeIndex(a_id.index as uint),
NodeIndex(b_id.index as uint),
*constraint);
}
ConstrainRegSubVar(_, b_id) => {
graph.add_edge(dummy_idx,
NodeIndex(b_id.index),
NodeIndex(b_id.index as uint),
*constraint);
}
ConstrainVarSubReg(a_id, _) => {
graph.add_edge(NodeIndex(a_id.index),
graph.add_edge(NodeIndex(a_id.index as uint),
dummy_idx,
*constraint);
}
@ -1349,7 +1352,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
&self,
graph: &RegionGraph,
var_data: &[VarData],
dup_vec: &mut [uint],
dup_vec: &mut [u32],
node_idx: RegionVid,
errors: &mut Vec<RegionResolutionError<'tcx>>)
{
@ -1387,7 +1390,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
if !self.is_subregion_of(lower_bound.region,
upper_bound.region) {
errors.push(SubSupConflict(
(*self.var_origins.borrow())[node_idx.index].clone(),
(*self.var_origins.borrow())[node_idx.index as uint].clone(),
lower_bound.origin.clone(),
lower_bound.region,
upper_bound.origin.clone(),
@ -1398,7 +1401,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
self.tcx.sess.span_bug(
(*self.var_origins.borrow())[node_idx.index].span(),
(*self.var_origins.borrow())[node_idx.index as uint].span(),
format!("collect_error_for_expanding_node() could not find error \
for var {}, lower_bounds={}, upper_bounds={}",
node_idx,
@ -1410,7 +1413,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
&self,
graph: &RegionGraph,
var_data: &[VarData],
dup_vec: &mut [uint],
dup_vec: &mut [u32],
node_idx: RegionVid,
errors: &mut Vec<RegionResolutionError<'tcx>>)
{
@ -1431,7 +1434,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
Ok(_) => {}
Err(_) => {
errors.push(SupSupConflict(
(*self.var_origins.borrow())[node_idx.index].clone(),
(*self.var_origins.borrow())[node_idx.index as uint].clone(),
upper_bound_1.origin.clone(),
upper_bound_1.region,
upper_bound_2.origin.clone(),
@ -1443,7 +1446,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
self.tcx.sess.span_bug(
(*self.var_origins.borrow())[node_idx.index].span(),
(*self.var_origins.borrow())[node_idx.index as uint].span(),
format!("collect_error_for_contracting_node() could not find error \
for var {}, upper_bounds={}",
node_idx,
@ -1455,7 +1458,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
var_data: &[VarData],
orig_node_idx: RegionVid,
dir: Direction,
dup_vec: &mut [uint])
dup_vec: &mut [u32])
-> (Vec<RegionAndOrigin<'tcx>>, bool) {
struct WalkState<'tcx> {
set: FnvHashSet<RegionVid>,
@ -1477,12 +1480,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
while !state.stack.is_empty() {
let node_idx = state.stack.pop().unwrap();
let classification = var_data[node_idx.index].classification;
let classification = var_data[node_idx.index as uint].classification;
// check whether we've visited this node on some previous walk
if dup_vec[node_idx.index] == uint::MAX {
dup_vec[node_idx.index] = orig_node_idx.index;
} else if dup_vec[node_idx.index] != orig_node_idx.index {
if dup_vec[node_idx.index as uint] == u32::MAX {
dup_vec[node_idx.index as uint] = orig_node_idx.index;
} else if dup_vec[node_idx.index as uint] != orig_node_idx.index {
state.dup_found = true;
}
@ -1510,7 +1513,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
dir: Direction) {
debug!("process_edges(source_vid={}, dir={})", source_vid, dir);
let source_node_index = NodeIndex(source_vid.index);
let source_node_index = NodeIndex(source_vid.index as uint);
graph.each_adjacent_edge(source_node_index, dir, |_, edge| {
match edge.data {
ConstrainVarSubVar(from_vid, to_vid) => {
@ -1595,7 +1598,7 @@ fn normalize(values: &Vec<VarValue>, r: ty::Region) -> ty::Region {
}
fn lookup(values: &Vec<VarValue>, rid: ty::RegionVid) -> ty::Region {
match values[rid.index] {
match values[rid.index as uint] {
Value(r) => r,
NoValue => ReEmpty, // No constraints, return ty::ReEmpty
ErrorValue => ReStatic, // Previously reported error.

View File

@ -67,11 +67,11 @@ impl<'tcx> TypeVariableTable<'tcx> {
}
fn relations<'a>(&'a mut self, a: ty::TyVid) -> &'a mut Vec<Relation> {
relations(self.values.get_mut(a.index))
relations(self.values.get_mut(a.index as uint))
}
pub fn var_diverges<'a>(&'a self, vid: ty::TyVid) -> bool {
self.values.get(vid.index).diverging
self.values.get(vid.index as uint).diverging
}
/// Records that `a <: b`, `a :> b`, or `a == b`, depending on `dir`.
@ -95,7 +95,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
stack: &mut Vec<(Ty<'tcx>, RelationDir, ty::TyVid)>)
{
let old_value = {
let value_ptr = &mut self.values.get_mut(vid.index).value;
let value_ptr = &mut self.values.get_mut(vid.index as uint).value;
mem::replace(value_ptr, Known(ty))
};
@ -117,11 +117,11 @@ impl<'tcx> TypeVariableTable<'tcx> {
value: Bounded(vec![]),
diverging: diverging
});
ty::TyVid { index: index }
ty::TyVid { index: index as u32 }
}
pub fn probe(&self, vid: ty::TyVid) -> Option<Ty<'tcx>> {
match self.values.get(vid.index).value {
match self.values.get(vid.index as uint).value {
Bounded(..) => None,
Known(t) => Some(t)
}
@ -201,12 +201,12 @@ impl<'tcx> sv::SnapshotVecDelegate<TypeVariableData<'tcx>,UndoEntry> for Delegat
action: UndoEntry) {
match action {
SpecifyVar(vid, relations) => {
values[vid.index].value = Bounded(relations);
values[vid.index as uint].value = Bounded(relations);
}
Relate(a, b) => {
relations(&mut (*values)[a.index]).pop();
relations(&mut (*values)[b.index]).pop();
relations(&mut (*values)[a.index as uint]).pop();
relations(&mut (*values)[b.index as uint]).pop();
}
}
}
@ -218,4 +218,3 @@ fn relations<'a>(v: &'a mut TypeVariableData) -> &'a mut Vec<Relation> {
Bounded(ref mut relations) => relations
}
}

View File

@ -347,9 +347,9 @@ impl<'a,'tcx,V:SimplyUnifiable<'tcx>,K:UnifyKey<'tcx, Option<V>>>
// Integral type keys
impl<'tcx> UnifyKey<'tcx, Option<IntVarValue>> for ty::IntVid {
fn index(&self) -> uint { self.index }
fn index(&self) -> uint { self.index as uint }
fn from_index(i: uint) -> ty::IntVid { ty::IntVid { index: i } }
fn from_index(i: uint) -> ty::IntVid { ty::IntVid { index: i as u32 } }
fn unification_table<'v>(infcx: &'v InferCtxt)
-> &'v RefCell<UnificationTable<ty::IntVid, Option<IntVarValue>>>
@ -380,9 +380,9 @@ impl<'tcx> UnifyValue<'tcx> for Option<IntVarValue> { }
// Floating point type keys
impl<'tcx> UnifyKey<'tcx, Option<ast::FloatTy>> for ty::FloatVid {
fn index(&self) -> uint { self.index }
fn index(&self) -> uint { self.index as uint }
fn from_index(i: uint) -> ty::FloatVid { ty::FloatVid { index: i } }
fn from_index(i: uint) -> ty::FloatVid { ty::FloatVid { index: i as u32 } }
fn unification_table<'v>(infcx: &'v InferCtxt)
-> &'v RefCell<UnificationTable<ty::FloatVid, Option<ast::FloatTy>>>

View File

@ -37,7 +37,7 @@ use util::nodemap::NodeMap;
pub enum DefRegion {
DefStaticRegion,
DefEarlyBoundRegion(/* space */ subst::ParamSpace,
/* index */ uint,
/* index */ u32,
/* lifetime decl */ ast::NodeId),
DefLateBoundRegion(ty::DebruijnIndex,
/* lifetime decl */ ast::NodeId),
@ -508,10 +508,10 @@ impl<'a> LifetimeContext<'a> {
fn search_lifetimes<'a>(lifetimes: &'a Vec<ast::LifetimeDef>,
lifetime_ref: &ast::Lifetime)
-> Option<(uint, &'a ast::Lifetime)> {
-> Option<(u32, &'a ast::Lifetime)> {
for (i, lifetime_decl) in lifetimes.iter().enumerate() {
if lifetime_decl.lifetime.name == lifetime_ref.name {
return Some((i, &lifetime_decl.lifetime));
return Some((i as u32, &lifetime_decl.lifetime));
}
}
return None;

View File

@ -98,10 +98,10 @@ impl<'tcx> Substs<'tcx> {
}
pub fn type_for_def(&self, ty_param_def: &ty::TypeParameterDef) -> Ty<'tcx> {
*self.types.get(ty_param_def.space, ty_param_def.index)
*self.types.get(ty_param_def.space, ty_param_def.index as uint)
}
pub fn has_regions_escaping_depth(&self, depth: uint) -> bool {
pub fn has_regions_escaping_depth(&self, depth: u32) -> bool {
self.types.iter().any(|&t| ty::type_escapes_depth(t, depth)) || {
match self.regions {
ErasedRegions =>
@ -582,7 +582,7 @@ struct SubstFolder<'a, 'tcx: 'a> {
ty_stack_depth: uint,
// Number of region binders we have passed through while doing the substitution
region_binders_passed: uint,
region_binders_passed: u32,
}
impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
@ -607,7 +607,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
match self.substs.regions {
ErasedRegions => ty::ReStatic,
NonerasedRegions(ref regions) =>
match regions.opt_get(space, i) {
match regions.opt_get(space, i as uint) {
Some(&r) => {
self.shift_region_through_binders(r)
}
@ -663,7 +663,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
impl<'a,'tcx> SubstFolder<'a,'tcx> {
fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> {
// Look up the type in the substitutions. It really should be in there.
let opt_ty = self.substs.types.opt_get(p.space, p.idx);
let opt_ty = self.substs.types.opt_get(p.space, p.idx as uint);
let ty = match opt_ty {
Some(t) => *t,
None => {

View File

@ -862,7 +862,7 @@ pub struct TyS<'tcx> {
pub flags: TypeFlags,
// the maximal depth of any bound regions appearing in this type.
region_depth: uint,
region_depth: u32,
}
impl fmt::Show for TypeFlags {
@ -955,7 +955,7 @@ pub fn type_has_escaping_regions(ty: Ty) -> bool {
type_escapes_depth(ty, 0)
}
pub fn type_escapes_depth(ty: Ty, depth: uint) -> bool {
pub fn type_escapes_depth(ty: Ty, depth: u32) -> bool {
ty.region_depth > depth
}
@ -1009,7 +1009,7 @@ pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)]
pub struct ParamTy {
pub space: subst::ParamSpace,
pub idx: uint,
pub idx: u32,
pub def_id: DefId
}
@ -1056,7 +1056,7 @@ pub struct ParamTy {
pub struct DebruijnIndex {
// We maintain the invariant that this is never 0. So 1 indicates
// the innermost binder. To ensure this, create with `DebruijnIndex::new`.
pub depth: uint,
pub depth: u32,
}
/// Representation of regions:
@ -1067,7 +1067,7 @@ pub enum Region {
// parameters are substituted.
ReEarlyBound(/* param id */ ast::NodeId,
subst::ParamSpace,
/*index*/ uint,
/*index*/ u32,
ast::Name),
// Region bound in a function scope, which will be substituted when the
@ -1217,7 +1217,7 @@ impl Region {
}
}
pub fn escapes_depth(&self, depth: uint) -> bool {
pub fn escapes_depth(&self, depth: u32) -> bool {
match *self {
ty::ReLateBound(debruijn, _) => debruijn.depth > depth,
_ => false,
@ -1238,7 +1238,7 @@ pub struct FreeRegion {
RustcEncodable, RustcDecodable, Show, Copy)]
pub enum BoundRegion {
/// An anonymous region parameter for a given fn (&T)
BrAnon(uint),
BrAnon(u32),
/// Named region parameters for functions (a in &'a T)
///
@ -1247,7 +1247,7 @@ pub enum BoundRegion {
BrNamed(ast::DefId, ast::Name),
/// Fresh bound identifiers created during GLB computations.
BrFresh(uint),
BrFresh(u32),
// Anonymous region for the implicit env pointer parameter
// to a closure
@ -1538,22 +1538,22 @@ impl CLike for BuiltinBound {
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
pub struct TyVid {
pub index: uint
pub index: u32
}
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
pub struct IntVid {
pub index: uint
pub index: u32
}
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
pub struct FloatVid {
pub index: uint
pub index: u32
}
#[deriving(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
pub struct RegionVid {
pub index: uint
pub index: u32
}
#[deriving(Clone, Copy, PartialEq, Eq, Hash)]
@ -1565,18 +1565,18 @@ pub enum InferTy {
/// A `FreshTy` is one that is generated as a replacement for an
/// unbound type variable. This is convenient for caching etc. See
/// `middle::infer::freshen` for more details.
FreshTy(uint),
FreshTy(u32),
// FIXME -- once integral fallback is impl'd, we should remove
// this type. It's only needed to prevent spurious errors for
// integers whose type winds up never being constrained.
FreshIntTy(uint),
FreshIntTy(u32),
}
#[deriving(Clone, RustcEncodable, RustcDecodable, Eq, Hash, Show, Copy)]
pub enum InferRegion {
ReVar(RegionVid),
ReSkolemized(uint, BoundRegion)
ReSkolemized(u32, BoundRegion)
}
impl cmp::PartialEq for InferRegion {
@ -1653,7 +1653,7 @@ pub struct TypeParameterDef<'tcx> {
pub name: ast::Name,
pub def_id: ast::DefId,
pub space: subst::ParamSpace,
pub index: uint,
pub index: u32,
pub associated_with: Option<ast::DefId>,
pub bounds: ParamBounds<'tcx>,
pub default: Option<Ty<'tcx>>,
@ -1664,7 +1664,7 @@ pub struct RegionParameterDef {
pub name: ast::Name,
pub def_id: ast::DefId,
pub space: subst::ParamSpace,
pub index: uint,
pub index: u32,
pub bounds: Vec<ty::Region>,
}
@ -2176,7 +2176,7 @@ struct FlagComputation {
flags: TypeFlags,
// maximum depth of any bound region that we have seen thus far
depth: uint,
depth: u32,
}
impl FlagComputation {
@ -2194,7 +2194,7 @@ impl FlagComputation {
self.flags = self.flags | flags;
}
fn add_depth(&mut self, depth: uint) {
fn add_depth(&mut self, depth: u32) {
if depth > self.depth {
self.depth = depth;
}
@ -2508,7 +2508,7 @@ pub fn mk_infer<'tcx>(cx: &ctxt<'tcx>, it: InferTy) -> Ty<'tcx> {
}
pub fn mk_param<'tcx>(cx: &ctxt<'tcx>, space: subst::ParamSpace,
n: uint, k: DefId) -> Ty<'tcx> {
n: u32, k: DefId) -> Ty<'tcx> {
mk_t(cx, ty_param(ParamTy { space: space, idx: n, def_id: k }))
}
@ -2580,7 +2580,7 @@ pub fn fold_ty<'tcx, F>(cx: &ctxt<'tcx>, t0: Ty<'tcx>,
impl ParamTy {
pub fn new(space: subst::ParamSpace,
index: uint,
index: u32,
def_id: ast::DefId)
-> ParamTy {
ParamTy { space: space, idx: index, def_id: def_id }
@ -4823,7 +4823,7 @@ pub fn associated_type_parameter_index(cx: &ctxt,
-> uint {
for type_parameter_def in trait_def.generics.types.iter() {
if type_parameter_def.def_id == associated_type_id {
return type_parameter_def.index
return type_parameter_def.index as uint
}
}
cx.sess.bug("couldn't find associated type parameter index")
@ -6188,7 +6188,7 @@ pub fn construct_parameter_environment<'tcx>(
space,
def.repr(tcx),
i);
let ty = ty::mk_param(tcx, space, i, def.def_id);
let ty = ty::mk_param(tcx, space, i as u32, def.def_id);
types.push(space, ty);
}
}
@ -6509,12 +6509,12 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
}
impl DebruijnIndex {
pub fn new(depth: uint) -> DebruijnIndex {
pub fn new(depth: u32) -> DebruijnIndex {
assert!(depth > 0);
DebruijnIndex { depth: depth }
}
pub fn shifted(&self, amount: uint) -> DebruijnIndex {
pub fn shifted(&self, amount: u32) -> DebruijnIndex {
DebruijnIndex { depth: self.depth + amount }
}
}

View File

@ -717,13 +717,13 @@ impl<'a, 'tcx, F> TypeFolder<'tcx> for BottomUpFolder<'a, 'tcx, F> where
pub struct RegionFolder<'a, 'tcx: 'a> {
tcx: &'a ty::ctxt<'tcx>,
current_depth: uint,
fld_r: &'a mut (FnMut(ty::Region, uint) -> ty::Region + 'a),
current_depth: u32,
fld_r: &'a mut (FnMut(ty::Region, u32) -> ty::Region + 'a),
}
impl<'a, 'tcx> RegionFolder<'a, 'tcx> {
pub fn new<F>(tcx: &'a ty::ctxt<'tcx>, fld_r: &'a mut F) -> RegionFolder<'a, 'tcx>
where F : FnMut(ty::Region, uint) -> ty::Region
where F : FnMut(ty::Region, u32) -> ty::Region
{
RegionFolder {
tcx: tcx,
@ -813,7 +813,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionEraser<'a, 'tcx> {
// regions. See comment on `shift_regions_through_binders` method in
// `subst.rs` for more details.
pub fn shift_region(region: ty::Region, amount: uint) -> ty::Region {
pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region {
match region {
ty::ReLateBound(debruijn, br) => {
ty::ReLateBound(debruijn.shifted(amount), br)
@ -825,7 +825,7 @@ pub fn shift_region(region: ty::Region, amount: uint) -> ty::Region {
}
pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>>(tcx: &ty::ctxt<'tcx>,
amount: uint, value: &T) -> T {
amount: u32, value: &T) -> T {
debug!("shift_regions(value={}, amount={})",
value.repr(tcx), amount);

View File

@ -4254,7 +4254,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let def_like = DlDef(DefTyParam(space,
local_def(type_parameter.id),
index));
index as u32));
// Associate this type parameter with
// the item that bound it
self.record_def(type_parameter.id,

View File

@ -5502,7 +5502,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
match t.sty {
ty::ty_param(ParamTy {idx, ..}) => {
debug!("Found use of ty param num {}", idx);
tps_used[idx] = true;
tps_used[idx as uint] = true;
}
_ => ()
}
@ -5518,7 +5518,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
}
pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: uint) -> Ty<'tcx> {
fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
ty::mk_param(ccx.tcx, subst::FnSpace, n, local_def(0))
}
@ -5561,8 +5561,8 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
"breakpoint" => (0, Vec::new(), ty::mk_nil(tcx)),
"size_of" |
"pref_align_of" | "min_align_of" => (1u, Vec::new(), ty::mk_uint()),
"init" => (1u, Vec::new(), param(ccx, 0u)),
"uninit" => (1u, Vec::new(), param(ccx, 0u)),
"init" => (1u, Vec::new(), param(ccx, 0)),
"uninit" => (1u, Vec::new(), param(ccx, 0)),
"forget" => (1u, vec!( param(ccx, 0) ), ty::mk_nil(tcx)),
"transmute" => (2, vec!( param(ccx, 0) ), param(ccx, 1)),
"move_val_init" => {
@ -5570,7 +5570,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
vec!(
ty::mk_mut_rptr(tcx, ty::ReLateBound(ty::DebruijnIndex::new(1), ty::BrAnon(0)),
param(ccx, 0)),
param(ccx, 0u)
param(ccx, 0)
),
ty::mk_nil(tcx))
}

View File

@ -651,7 +651,7 @@ fn is_associated_type_valid_for_param(ty: Ty,
generics: &ty::Generics)
-> bool {
if let ty::ty_param(param_ty) = ty.sty {
let type_parameter = generics.types.get(param_ty.space, param_ty.idx);
let type_parameter = generics.types.get(param_ty.space, param_ty.idx as uint);
for trait_bound in type_parameter.bounds.trait_bounds.iter() {
if trait_bound.def_id() == trait_id {
return true
@ -1397,7 +1397,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
.enumerate()
.map(|(i, def)| ty::ReEarlyBound(def.lifetime.id,
subst::TypeSpace,
i,
i as u32,
def.lifetime.name))
.collect();
@ -1407,7 +1407,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
.iter()
.enumerate()
.map(|(i, def)| ty::mk_param(ccx.tcx, subst::TypeSpace,
i, local_def(def.id)))
i as u32, local_def(def.id)))
.collect();
// ...and also create generics synthesized from the associated types.
@ -1419,7 +1419,7 @@ pub fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
index += 1;
Some(ty::mk_param(ccx.tcx,
subst::AssocSpace,
index - 1,
index as u32 - 1,
local_def(trait_item.ty_param.id))).into_iter()
}
ast::RequiredMethod(_) | ast::ProvidedMethod(_) => {
@ -1621,7 +1621,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
ccx,
subst::AssocSpace,
&associated_type.ty_param,
generics.types.len(subst::AssocSpace),
generics.types.len(subst::AssocSpace) as u32,
Some(local_def(trait_id)));
ccx.tcx.ty_param_defs.borrow_mut().insert(associated_type.ty_param.id,
def.clone());
@ -1746,7 +1746,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
.collect();
let def = ty::RegionParameterDef { name: l.lifetime.name,
space: space,
index: i,
index: i as u32,
def_id: local_def(l.lifetime.id),
bounds: bounds };
debug!("ty_generics: def for region param: {}", def);
@ -1775,7 +1775,12 @@ fn ty_generics<'tcx,AC>(this: &AC,
let def = get_or_create_type_parameter_def(&gcx,
space,
param,
<<<<<<< HEAD
i,
=======
i as u32,
where_clause,
>>>>>>> Switch Region information from uint to u32.
None);
debug!("ty_generics: def for type param: {}, {}",
def.repr(this.tcx()),
@ -1788,7 +1793,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
.get_slice(space)
.iter() {
assert!(result.types.get_slice(space).len() ==
associated_type_param.index);
associated_type_param.index as uint);
debug!("ty_generics: def for associated type: {}, {}",
associated_type_param.repr(this.tcx()),
space);
@ -1915,7 +1920,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
name: associated_type_def.name,
def_id: associated_type_def.def_id,
space: space,
index: types.len() + index,
index: types.len() as u32 + index,
bounds: ty::ParamBounds {
builtin_bounds: associated_type_def.bounds.builtin_bounds,
@ -1963,7 +1968,12 @@ fn ty_generics<'tcx,AC>(this: &AC,
fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
space: subst::ParamSpace,
param: &ast::TyParam,
<<<<<<< HEAD
index: uint,
=======
index: u32,
where_clause: &ast::WhereClause,
>>>>>>> Switch Region information from uint to u32.
associated_with: Option<ast::DefId>)
-> ty::TypeParameterDef<'tcx>
where AC: AstConv<'tcx>

View File

@ -106,7 +106,7 @@ impl RegionScope for SpecificRscope {
/// A scope in which we generate anonymous, late-bound regions for
/// omitted regions. This occurs in function signatures.
pub struct BindingRscope {
anon_bindings: Cell<uint>,
anon_bindings: Cell<u32>,
}
impl BindingRscope {

View File

@ -854,18 +854,18 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
for p in type_param_defs.iter() {
let variance_decl =
self.declared_variance(p.def_id, def_id, TypeParam,
p.space, p.index);
p.space, p.index as uint);
let variance_i = self.xform(variance, variance_decl);
let substs_ty = *substs.types.get(p.space, p.index);
let substs_ty = *substs.types.get(p.space, p.index as uint);
self.add_constraints_from_ty(substs_ty, variance_i);
}
for p in region_param_defs.iter() {
let variance_decl =
self.declared_variance(p.def_id, def_id,
RegionParam, p.space, p.index);
RegionParam, p.space, p.index as uint);
let variance_i = self.xform(variance, variance_decl);
let substs_r = *substs.regions().get(p.space, p.index);
let substs_r = *substs.regions().get(p.space, p.index as uint);
self.add_constraints_from_region(substs_r, variance_i);
}
}