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