Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dc486994
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dc486994
编写于
3月 07, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
librustc: Remove newtype enums from librustc
上级
4faf63e4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
41 addition
and
37 deletion
+41
-37
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+2
-2
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+8
-6
src/librustc/middle/typeck/infer/coercion.rs
src/librustc/middle/typeck/infer/coercion.rs
+1
-1
src/librustc/middle/typeck/infer/glb.rs
src/librustc/middle/typeck/infer/glb.rs
+1
-1
src/librustc/middle/typeck/infer/lub.rs
src/librustc/middle/typeck/infer/lub.rs
+1
-1
src/librustc/middle/typeck/infer/region_inference.rs
src/librustc/middle/typeck/infer/region_inference.rs
+25
-24
src/librustc/middle/typeck/infer/sub.rs
src/librustc/middle/typeck/infer/sub.rs
+1
-1
src/librustc/middle/typeck/rscope.rs
src/librustc/middle/typeck/rscope.rs
+2
-1
未找到文件。
src/librustc/middle/liveness.rs
浏览文件 @
dc486994
...
...
@@ -137,8 +137,8 @@
// 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
)
}
...
...
src/librustc/middle/ty.rs
浏览文件 @
dc486994
...
...
@@ -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
{
...
...
src/librustc/middle/typeck/infer/coercion.rs
浏览文件 @
dc486994
...
...
@@ -84,7 +84,7 @@ fn foo<A>(a: A, b: A) { ... }
// 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
{
...
...
src/librustc/middle/typeck/infer/glb.rs
浏览文件 @
dc486994
...
...
@@ -29,7 +29,7 @@
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
}
...
...
src/librustc/middle/typeck/infer/lub.rs
浏览文件 @
dc486994
...
...
@@ -29,7 +29,7 @@
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
)
}
...
...
src/librustc/middle/typeck/infer/region_inference.rs
浏览文件 @
dc486994
...
...
@@ -700,7 +700,7 @@ fn rollback_to(&mut self, snapshot: uint) {
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 @@ fn num_vars(&mut self) -> uint {
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 @@ fn glb_regions(&mut self,
}
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 @@ fn resolve_var(&mut self, rid: RegionVid) -> ty::Region {
// 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 @@ fn lub_concrete_regions(&mut self, +a: Region, +b: Region) -> Region {
(
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 @@ fn glb_concrete_regions(&mut self,
(
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 @@ fn insert_edge(+graph: &mut Graph,
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 @@ fn expansion(&mut self, graph: &mut Graph) {
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 @@ fn contraction(&mut self, graph: &mut Graph) {
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 @@ fn extract_values_and_report_conflicts(
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 @@ fn report_error_for_expanding_node(&mut self,
}
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 @@ fn report_error_for_contracting_node(&mut self,
}
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 @@ fn collect_concrete_regions(&mut self,
->
~
[
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 @@ fn collect_concrete_regions(&mut self,
Incoming
=>
from_vid
,
Outgoing
=>
to_vid
};
if
set
.insert
(
*
vid
,
())
{
if
set
.insert
(
vid
.to_uint
()
,
())
{
stack
.push
(
vid
);
}
}
...
...
@@ -1658,7 +1658,8 @@ fn each_edge(&mut self,
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
)
{
...
...
src/librustc/middle/typeck/infer/sub.rs
浏览文件 @
dc486994
...
...
@@ -29,7 +29,7 @@
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
}
...
...
src/librustc/middle/typeck/rscope.rs
浏览文件 @
dc486994
...
...
@@ -74,7 +74,8 @@ fn named_region(&self, span: span, id: ast::ident)
}
}
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
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录