mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-20 19:52:48 +00:00
librustc: Remove newtype enums from librustc
This commit is contained in:
parent
4faf63e472
commit
dc4869945c
@ -137,8 +137,8 @@ use syntax::{visit, ast_util};
|
||||
// if it detects an outstanding loan (that is, the addr is taken).
|
||||
pub type last_use_map = HashMap<node_id, @mut ~[node_id]>;
|
||||
|
||||
enum Variable = uint;
|
||||
enum LiveNode = uint;
|
||||
struct Variable(uint);
|
||||
struct LiveNode(uint);
|
||||
|
||||
impl cmp::Eq for Variable {
|
||||
pure fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) }
|
||||
|
@ -582,18 +582,20 @@ pub enum param_bound {
|
||||
}
|
||||
|
||||
#[deriving_eq]
|
||||
pub enum TyVid = uint;
|
||||
pub struct TyVid(uint);
|
||||
|
||||
#[deriving_eq]
|
||||
pub enum IntVid = uint;
|
||||
pub struct IntVid(uint);
|
||||
|
||||
#[deriving_eq]
|
||||
pub enum FloatVid = uint;
|
||||
pub struct FloatVid(uint);
|
||||
|
||||
#[deriving_eq]
|
||||
#[auto_encode]
|
||||
#[auto_decode]
|
||||
pub enum RegionVid = uint;
|
||||
pub struct RegionVid {
|
||||
id: uint
|
||||
}
|
||||
|
||||
#[deriving_eq]
|
||||
pub enum InferTy {
|
||||
@ -687,11 +689,11 @@ impl ToStr for FloatVid {
|
||||
}
|
||||
|
||||
impl Vid for RegionVid {
|
||||
pure fn to_uint(&self) -> uint { **self }
|
||||
pure fn to_uint(&self) -> uint { self.id }
|
||||
}
|
||||
|
||||
impl ToStr for RegionVid {
|
||||
pure fn to_str(&self) -> ~str { fmt!("%?", self) }
|
||||
pure fn to_str(&self) -> ~str { fmt!("%?", self.id) }
|
||||
}
|
||||
|
||||
impl ToStr for FnSig {
|
||||
|
@ -84,7 +84,7 @@ use syntax::ast;
|
||||
// Note: Coerce is not actually a combiner, in that it does not
|
||||
// conform to the same interface, though it performs a similar
|
||||
// function.
|
||||
pub enum Coerce = CombineFields;
|
||||
pub struct Coerce(CombineFields);
|
||||
|
||||
pub impl Coerce {
|
||||
fn tys(&self, a: ty::t, b: ty::t) -> CoerceResult {
|
||||
|
@ -29,7 +29,7 @@ use util::ppaux::mt_to_str;
|
||||
|
||||
use std::list;
|
||||
|
||||
pub enum Glb = CombineFields; // "greatest lower bound" (common subtype)
|
||||
pub struct Glb(CombineFields); // "greatest lower bound" (common subtype)
|
||||
|
||||
impl Combine for Glb {
|
||||
fn infcx(&self) -> @mut InferCtxt { self.infcx }
|
||||
|
@ -29,7 +29,7 @@ use syntax::ast::{pure_fn, ret_style, return_val, unsafe_fn};
|
||||
use syntax::ast::{Onceness, purity};
|
||||
use syntax::codemap::span;
|
||||
|
||||
pub enum Lub = CombineFields; // least-upper-bound: common supertype
|
||||
pub struct Lub(CombineFields); // least-upper-bound: common supertype
|
||||
|
||||
pub impl Lub {
|
||||
fn bot_ty(&self, b: ty::t) -> cres<ty::t> { Ok(b) }
|
||||
|
@ -700,7 +700,7 @@ pub impl RegionVarBindings {
|
||||
match undo_item {
|
||||
Snapshot => {}
|
||||
AddVar(vid) => {
|
||||
fail_unless!(self.var_spans.len() == *vid + 1);
|
||||
fail_unless!(self.var_spans.len() == vid.to_uint() + 1);
|
||||
self.var_spans.pop();
|
||||
}
|
||||
AddConstraint(ref constraint) => {
|
||||
@ -720,7 +720,7 @@ pub impl RegionVarBindings {
|
||||
fn new_region_var(&mut self, span: span) -> RegionVid {
|
||||
let id = self.num_vars();
|
||||
self.var_spans.push(span);
|
||||
let vid = RegionVid(id);
|
||||
let vid = RegionVid { id: id };
|
||||
if self.in_snapshot() {
|
||||
self.undo_log.push(AddVar(vid));
|
||||
}
|
||||
@ -863,15 +863,15 @@ pub impl RegionVarBindings {
|
||||
}
|
||||
|
||||
fn resolve_var(&mut self, rid: RegionVid) -> ty::Region {
|
||||
debug!("RegionVarBindings: resolve_var(%?=%u)", rid, *rid);
|
||||
debug!("RegionVarBindings: resolve_var(%?=%u)", rid, rid.to_uint());
|
||||
if self.values.is_empty() {
|
||||
self.tcx.sess.span_bug(
|
||||
self.var_spans[*rid],
|
||||
self.var_spans[rid.to_uint()],
|
||||
fmt!("Attempt to resolve region variable before values have \
|
||||
been computed!"));
|
||||
}
|
||||
|
||||
let v = self.values.with_ref(|values| values[*rid]);
|
||||
let v = self.values.with_ref(|values| values[rid.to_uint()]);
|
||||
match v {
|
||||
Value(r) => r,
|
||||
|
||||
@ -886,13 +886,13 @@ pub impl RegionVarBindings {
|
||||
// should ultimately have some bounds.
|
||||
|
||||
self.tcx.sess.span_err(
|
||||
self.var_spans[*rid],
|
||||
fmt!("Unconstrained region variable #%u", *rid));
|
||||
self.var_spans[rid.to_uint()],
|
||||
fmt!("Unconstrained region variable #%u", rid.to_uint()));
|
||||
|
||||
// Touch of a hack: to suppress duplicate messages,
|
||||
// replace the NoValue entry with ErrorValue.
|
||||
let mut values = self.values.take();
|
||||
values[*rid] = ErrorValue;
|
||||
values[rid.to_uint()] = ErrorValue;
|
||||
self.values.put_back(values);
|
||||
re_static
|
||||
}
|
||||
@ -1049,7 +1049,7 @@ priv impl RegionVarBindings {
|
||||
|
||||
(re_infer(ReVar(v_id)), _) | (_, re_infer(ReVar(v_id))) => {
|
||||
self.tcx.sess.span_bug(
|
||||
self.var_spans[*v_id],
|
||||
self.var_spans[v_id.to_uint()],
|
||||
fmt!("lub_concrete_regions invoked with \
|
||||
non-concrete regions: %?, %?", a, b));
|
||||
}
|
||||
@ -1111,7 +1111,7 @@ priv impl RegionVarBindings {
|
||||
(re_infer(ReVar(v_id)), _) |
|
||||
(_, re_infer(ReVar(v_id))) => {
|
||||
self.tcx.sess.span_bug(
|
||||
self.var_spans[*v_id],
|
||||
self.var_spans[v_id.to_uint()],
|
||||
fmt!("glb_concrete_regions invoked with \
|
||||
non-concrete regions: %?, %?", a, b));
|
||||
}
|
||||
@ -1275,8 +1275,8 @@ pub impl RegionVarBindings {
|
||||
edge_idx: uint) {
|
||||
let edge_dir = edge_dir as uint;
|
||||
graph.edges[edge_idx].next_edge[edge_dir] =
|
||||
graph.nodes[*node_id].head_edge[edge_dir];
|
||||
graph.nodes[*node_id].head_edge[edge_dir] =
|
||||
graph.nodes[node_id.to_uint()].head_edge[edge_dir];
|
||||
graph.nodes[node_id.to_uint()].head_edge[edge_dir] =
|
||||
edge_idx;
|
||||
}
|
||||
}
|
||||
@ -1285,14 +1285,14 @@ pub impl RegionVarBindings {
|
||||
do iterate_until_fixed_point(~"Expansion", graph) |nodes, edge| {
|
||||
match edge.constraint {
|
||||
ConstrainRegSubVar(a_region, b_vid) => {
|
||||
let b_node = &mut nodes[*b_vid];
|
||||
let b_node = &mut nodes[b_vid.to_uint()];
|
||||
self.expand_node(a_region, b_vid, b_node)
|
||||
}
|
||||
ConstrainVarSubVar(a_vid, b_vid) => {
|
||||
match nodes[*a_vid].value {
|
||||
match nodes[a_vid.to_uint()].value {
|
||||
NoValue | ErrorValue => false,
|
||||
Value(a_region) => {
|
||||
let b_node = &mut nodes[*b_vid];
|
||||
let b_node = &mut nodes[b_vid.to_uint()];
|
||||
self.expand_node(a_region, b_vid, b_node)
|
||||
}
|
||||
}
|
||||
@ -1349,16 +1349,16 @@ pub impl RegionVarBindings {
|
||||
false
|
||||
}
|
||||
ConstrainVarSubVar(a_vid, b_vid) => {
|
||||
match nodes[*b_vid].value {
|
||||
match nodes[b_vid.to_uint()].value {
|
||||
NoValue | ErrorValue => false,
|
||||
Value(b_region) => {
|
||||
let a_node = &mut nodes[*a_vid];
|
||||
let a_node = &mut nodes[a_vid.to_uint()];
|
||||
self.contract_node(a_vid, a_node, b_region)
|
||||
}
|
||||
}
|
||||
}
|
||||
ConstrainVarSubReg(a_vid, b_region) => {
|
||||
let a_node = &mut nodes[*a_vid];
|
||||
let a_node = &mut nodes[a_vid.to_uint()];
|
||||
self.contract_node(a_vid, a_node, b_region)
|
||||
}
|
||||
}
|
||||
@ -1474,7 +1474,7 @@ pub impl RegionVarBindings {
|
||||
that is not used is not a problem, so if this rule
|
||||
starts to create problems we'll have to revisit
|
||||
this portion of the code and think hard about it. =) */
|
||||
let node_vid = RegionVid(idx);
|
||||
let node_vid = RegionVid { id: idx };
|
||||
match node.classification {
|
||||
Expanding => {
|
||||
self.report_error_for_expanding_node(
|
||||
@ -1525,7 +1525,7 @@ pub impl RegionVarBindings {
|
||||
}
|
||||
|
||||
self.tcx.sess.span_err(
|
||||
self.var_spans[*node_idx],
|
||||
self.var_spans[node_idx.to_uint()],
|
||||
fmt!("cannot infer an appropriate lifetime \
|
||||
due to conflicting requirements"));
|
||||
|
||||
@ -1578,7 +1578,7 @@ pub impl RegionVarBindings {
|
||||
}
|
||||
|
||||
self.tcx.sess.span_err(
|
||||
self.var_spans[*node_idx],
|
||||
self.var_spans[node_idx.to_uint()],
|
||||
fmt!("cannot infer an appropriate lifetime \
|
||||
due to conflicting requirements"));
|
||||
|
||||
@ -1616,7 +1616,7 @@ pub impl RegionVarBindings {
|
||||
-> ~[SpannedRegion] {
|
||||
let set = HashMap();
|
||||
let mut stack = ~[orig_node_idx];
|
||||
set.insert(*orig_node_idx, ());
|
||||
set.insert(orig_node_idx.to_uint(), ());
|
||||
let mut result = ~[];
|
||||
while !vec::is_empty(stack) {
|
||||
let node_idx = stack.pop();
|
||||
@ -1627,7 +1627,7 @@ pub impl RegionVarBindings {
|
||||
Incoming => from_vid,
|
||||
Outgoing => to_vid
|
||||
};
|
||||
if set.insert(*vid, ()) {
|
||||
if set.insert(vid.to_uint(), ()) {
|
||||
stack.push(vid);
|
||||
}
|
||||
}
|
||||
@ -1658,7 +1658,8 @@ pub impl RegionVarBindings {
|
||||
node_idx: RegionVid,
|
||||
dir: Direction,
|
||||
op: &fn(edge: &GraphEdge) -> bool) {
|
||||
let mut edge_idx = graph.nodes[*node_idx].head_edge[dir as uint];
|
||||
let mut edge_idx =
|
||||
graph.nodes[node_idx.to_uint()].head_edge[dir as uint];
|
||||
while edge_idx != uint::max_value {
|
||||
let edge_ptr = &graph.edges[edge_idx];
|
||||
if !op(edge_ptr) {
|
||||
|
@ -29,7 +29,7 @@ use syntax::ast::{Onceness, m_const, purity, ret_style};
|
||||
use syntax::codemap::span;
|
||||
|
||||
|
||||
pub enum Sub = CombineFields; // "subtype", "subregion" etc
|
||||
pub struct Sub(CombineFields); // "subtype", "subregion" etc
|
||||
|
||||
impl Combine for Sub {
|
||||
fn infcx(&self) -> @mut InferCtxt { self.infcx }
|
||||
|
@ -74,7 +74,8 @@ impl region_scope for MethodRscope {
|
||||
}
|
||||
}
|
||||
|
||||
pub enum type_rscope = Option<ty::region_variance>;
|
||||
pub struct type_rscope(Option<ty::region_variance>);
|
||||
|
||||
impl type_rscope {
|
||||
priv fn replacement(&self) -> ty::Region {
|
||||
if self.is_some() {
|
||||
|
Loading…
Reference in New Issue
Block a user