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| {
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)
}
ty::BrNamed(def, ident.name)
}
'f' => {
- let id = parse_uint(st);
+ let id = parse_u32(st);
assert_eq!(next(st), '|');
ty::BrFresh(id)
}
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), ']');
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)
'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), '|');
};
}
+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))
}
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))
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
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>
}
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 {
}
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() {
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);
}
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);
}
let lifetimes = last_seg.parameters.lifetimes();
for (i, lt) in lifetimes.iter().enumerate() {
if region_names.contains(<.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
};
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 {
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();
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(
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());
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();
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);
}
} else {
for (i, lt) in lifetimes.iter().enumerate() {
if region_names.contains(<.name) {
- insert.push(i);
+ insert.push(i as u32);
}
}
}
}
} 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);
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>>,
}
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); }
use util::ppaux::Repr;
use std::cell::{Cell, RefCell};
-use std::uint;
+use std::u32;
use syntax::ast;
mod doc;
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.
//
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);
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 {
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!")
}
(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,
(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,
}
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
.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)
}
}
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)
}
}
// 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 */
}
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(
}
}
- 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 {
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(());
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);
}
&self,
graph: &RegionGraph,
var_data: &[VarData],
- dup_vec: &mut [uint],
+ dup_vec: &mut [u32],
node_idx: RegionVid,
errors: &mut Vec<RegionResolutionError<'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(),
}
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,
&self,
graph: &RegionGraph,
var_data: &[VarData],
- dup_vec: &mut [uint],
+ dup_vec: &mut [u32],
node_idx: RegionVid,
errors: &mut Vec<RegionResolutionError<'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(),
}
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,
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>,
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;
}
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) => {
}
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.
}
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`.
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))
};
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)
}
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();
}
}
}
Bounded(ref mut relations) => relations
}
}
-
// 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>>>
// 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>>>
pub enum DefRegion {
DefStaticRegion,
DefEarlyBoundRegion(/* space */ subst::ParamSpace,
- /* index */ uint,
+ /* index */ u32,
/* lifetime decl */ ast::NodeId),
DefLateBoundRegion(ty::DebruijnIndex,
/* lifetime decl */ ast::NodeId),
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;
}
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 =>
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> {
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)
}
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 => {
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 {
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
}
#[deriving(Clone, Copy, PartialEq, Eq, Hash, Show)]
pub struct ParamTy {
pub space: subst::ParamSpace,
- pub idx: uint,
+ pub idx: u32,
pub def_id: DefId
}
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:
// 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
}
}
- 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,
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)
///
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
#[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)]
/// 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 {
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>>,
pub name: ast::Name,
pub def_id: ast::DefId,
pub space: subst::ParamSpace,
- pub index: uint,
+ pub index: u32,
pub bounds: Vec<ty::Region>,
}
flags: TypeFlags,
// maximum depth of any bound region that we have seen thus far
- depth: uint,
+ depth: u32,
}
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;
}
}
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 }))
}
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 }
-> 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")
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);
}
}
}
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 }
}
}
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,
// 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)
}
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);
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,
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;
}
_ => ()
}
}
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))
}
"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" => {
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))
}
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
.enumerate()
.map(|(i, def)| ty::ReEarlyBound(def.lifetime.id,
subst::TypeSpace,
- i,
+ i as u32,
def.lifetime.name))
.collect();
.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.
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(_) => {
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());
.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);
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()),
.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);
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,
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>
/// 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 {
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);
}
}