Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
195f1d77
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
195f1d77
编写于
10月 29, 2013
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename and modernize region enum names
上级
5e54a732
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
316 addition
and
308 deletion
+316
-308
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tydecode.rs
+10
-10
src/librustc/metadata/tyencode.rs
src/librustc/metadata/tyencode.rs
+11
-11
src/librustc/middle/astencode.rs
src/librustc/middle/astencode.rs
+11
-11
src/librustc/middle/borrowck/gather_loans/lifetime.rs
src/librustc/middle/borrowck/gather_loans/lifetime.rs
+9
-9
src/librustc/middle/borrowck/gather_loans/mod.rs
src/librustc/middle/borrowck/gather_loans/mod.rs
+10
-10
src/librustc/middle/kind.rs
src/librustc/middle/kind.rs
+3
-3
src/librustc/middle/region.rs
src/librustc/middle/region.rs
+5
-5
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+2
-2
src/librustc/middle/subst.rs
src/librustc/middle/subst.rs
+2
-2
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/_match.rs
+2
-2
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/consts.rs
+3
-3
src/librustc/middle/trans/datum.rs
src/librustc/middle/trans/datum.rs
+1
-1
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/expr.rs
+1
-1
src/librustc/middle/trans/glue.rs
src/librustc/middle/trans/glue.rs
+1
-1
src/librustc/middle/trans/reflect.rs
src/librustc/middle/trans/reflect.rs
+1
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+41
-33
src/librustc/middle/typeck/astconv.rs
src/librustc/middle/typeck/astconv.rs
+14
-14
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+13
-13
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/regionck.rs
+10
-10
src/librustc/middle/typeck/check/regionmanip.rs
src/librustc/middle/typeck/check/regionmanip.rs
+4
-4
src/librustc/middle/typeck/check/vtable.rs
src/librustc/middle/typeck/check/vtable.rs
+1
-1
src/librustc/middle/typeck/collect.rs
src/librustc/middle/typeck/collect.rs
+3
-3
src/librustc/middle/typeck/infer/glb.rs
src/librustc/middle/typeck/infer/glb.rs
+3
-3
src/librustc/middle/typeck/infer/lattice.rs
src/librustc/middle/typeck/infer/lattice.rs
+3
-3
src/librustc/middle/typeck/infer/lub.rs
src/librustc/middle/typeck/infer/lub.rs
+2
-2
src/librustc/middle/typeck/infer/mod.rs
src/librustc/middle/typeck/infer/mod.rs
+8
-8
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
+70
-70
src/librustc/middle/typeck/infer/resolve.rs
src/librustc/middle/typeck/infer/resolve.rs
+3
-3
src/librustc/middle/typeck/infer/sub.rs
src/librustc/middle/typeck/infer/sub.rs
+1
-1
src/librustc/middle/typeck/infer/test.rs
src/librustc/middle/typeck/infer/test.rs
+6
-6
src/librustc/middle/typeck/mod.rs
src/librustc/middle/typeck/mod.rs
+5
-5
src/librustc/middle/typeck/rscope.rs
src/librustc/middle/typeck/rscope.rs
+3
-3
src/librustc/middle/typeck/variance.rs
src/librustc/middle/typeck/variance.rs
+5
-5
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+47
-47
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+2
-2
未找到文件。
src/librustc/metadata/tydecode.rs
浏览文件 @
195f1d77
...
...
@@ -228,22 +228,22 @@ fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts {
}
}
fn
parse_bound_region
(
st
:
&
mut
PState
,
conv
:
conv_did
)
->
ty
::
bound_r
egion
{
fn
parse_bound_region
(
st
:
&
mut
PState
,
conv
:
conv_did
)
->
ty
::
BoundR
egion
{
match
next
(
st
)
{
'a'
=>
{
let
id
=
parse_uint
(
st
);
assert_eq!
(
next
(
st
),
'|'
);
ty
::
br_a
non
(
id
)
ty
::
BrA
non
(
id
)
}
'['
=>
{
let
def
=
parse_def
(
st
,
RegionParameter
,
|
x
,
y
|
conv
(
x
,
y
));
let
ident
=
st
.tcx.sess
.ident_of
(
parse_str
(
st
,
']'
));
ty
::
br_n
amed
(
def
,
ident
)
ty
::
BrN
amed
(
def
,
ident
)
}
'f'
=>
{
let
id
=
parse_uint
(
st
);
assert_eq!
(
next
(
st
),
'|'
);
ty
::
br_f
resh
(
id
)
ty
::
BrF
resh
(
id
)
}
_
=>
fail
!
(
"parse_bound_region: bad input"
)
}
...
...
@@ -257,7 +257,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
assert_eq!
(
next
(
st
),
'|'
);
let
br
=
parse_bound_region
(
st
,
|
x
,
y
|
conv
(
x
,
y
));
assert_eq!
(
next
(
st
),
']'
);
ty
::
re_fn_b
ound
(
id
,
br
)
ty
::
ReLateB
ound
(
id
,
br
)
}
'B'
=>
{
assert_eq!
(
next
(
st
),
'['
);
...
...
@@ -266,7 +266,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
let
index
=
parse_uint
(
st
);
assert_eq!
(
next
(
st
),
'|'
);
let
nm
=
st
.tcx.sess
.ident_of
(
parse_str
(
st
,
']'
));
ty
::
re_type_b
ound
(
node_id
,
index
,
nm
)
ty
::
ReEarlyB
ound
(
node_id
,
index
,
nm
)
}
'f'
=>
{
assert_eq!
(
next
(
st
),
'['
);
...
...
@@ -274,19 +274,19 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
assert_eq!
(
next
(
st
),
'|'
);
let
br
=
parse_bound_region
(
st
,
|
x
,
y
|
conv
(
x
,
y
));
assert_eq!
(
next
(
st
),
']'
);
ty
::
re_f
ree
(
ty
::
FreeRegion
{
scope_id
:
id
,
ty
::
ReF
ree
(
ty
::
FreeRegion
{
scope_id
:
id
,
bound_region
:
br
})
}
's'
=>
{
let
id
=
parse_uint
(
st
)
as
int
;
assert_eq!
(
next
(
st
),
'|'
);
ty
::
re_s
cope
(
id
)
ty
::
ReS
cope
(
id
)
}
't'
=>
{
ty
::
re_s
tatic
ty
::
ReS
tatic
}
'e'
=>
{
ty
::
re_s
tatic
ty
::
ReS
tatic
}
_
=>
fail
!
(
"parse_region: bad input"
)
}
...
...
src/librustc/metadata/tyencode.rs
浏览文件 @
195f1d77
...
...
@@ -155,49 +155,49 @@ fn enc_region_substs(w: @mut MemWriter, cx: @ctxt, substs: &ty::RegionSubsts) {
fn
enc_region
(
w
:
@
mut
MemWriter
,
cx
:
@
ctxt
,
r
:
ty
::
Region
)
{
match
r
{
ty
::
re_fn_b
ound
(
id
,
br
)
=>
{
ty
::
ReLateB
ound
(
id
,
br
)
=>
{
mywrite!
(
w
,
"b[{}|"
,
id
);
enc_bound_region
(
w
,
cx
,
br
);
mywrite!
(
w
,
"]"
);
}
ty
::
re_type_b
ound
(
node_id
,
index
,
ident
)
=>
{
ty
::
ReEarlyB
ound
(
node_id
,
index
,
ident
)
=>
{
mywrite!
(
w
,
"B[{}|{}|{}]"
,
node_id
,
index
,
cx
.tcx.sess
.str_of
(
ident
));
}
ty
::
re_f
ree
(
ref
fr
)
=>
{
ty
::
ReF
ree
(
ref
fr
)
=>
{
mywrite!
(
w
,
"f[{}|"
,
fr
.scope_id
);
enc_bound_region
(
w
,
cx
,
fr
.bound_region
);
mywrite!
(
w
,
"]"
);
}
ty
::
re_s
cope
(
nid
)
=>
{
ty
::
ReS
cope
(
nid
)
=>
{
mywrite!
(
w
,
"s{}|"
,
nid
);
}
ty
::
re_s
tatic
=>
{
ty
::
ReS
tatic
=>
{
mywrite!
(
w
,
"t"
);
}
ty
::
re_e
mpty
=>
{
ty
::
ReE
mpty
=>
{
mywrite!
(
w
,
"e"
);
}
ty
::
re_i
nfer
(
_
)
=>
{
ty
::
ReI
nfer
(
_
)
=>
{
// these should not crop up after typeck
cx
.diag
.handler
()
.bug
(
"Cannot encode region variables"
);
}
}
}
fn
enc_bound_region
(
w
:
@
mut
MemWriter
,
cx
:
@
ctxt
,
br
:
ty
::
bound_r
egion
)
{
fn
enc_bound_region
(
w
:
@
mut
MemWriter
,
cx
:
@
ctxt
,
br
:
ty
::
BoundR
egion
)
{
match
br
{
ty
::
br_a
non
(
idx
)
=>
{
ty
::
BrA
non
(
idx
)
=>
{
mywrite!
(
w
,
"a{}|"
,
idx
);
}
ty
::
br_n
amed
(
d
,
s
)
=>
{
ty
::
BrN
amed
(
d
,
s
)
=>
{
mywrite!
(
w
,
"[{}|{}]"
,
(
cx
.ds
)(
d
),
cx
.tcx.sess
.str_of
(
s
));
}
ty
::
br_f
resh
(
id
)
=>
{
ty
::
BrF
resh
(
id
)
=>
{
mywrite!
(
w
,
"f{}|"
,
id
);
}
}
...
...
src/librustc/middle/astencode.rs
浏览文件 @
195f1d77
...
...
@@ -476,27 +476,27 @@ fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoRef {
impl
tr
for
ty
::
Region
{
fn
tr
(
&
self
,
xcx
:
@
ExtendedDecodeContext
)
->
ty
::
Region
{
match
*
self
{
ty
::
re_fn_bound
(
id
,
br
)
=>
ty
::
re_fn_b
ound
(
xcx
.tr_id
(
id
),
ty
::
ReLateBound
(
id
,
br
)
=>
ty
::
ReLateB
ound
(
xcx
.tr_id
(
id
),
br
.tr
(
xcx
)),
ty
::
re_type_bound
(
id
,
index
,
ident
)
=>
ty
::
re_type_b
ound
(
xcx
.tr_id
(
id
),
ty
::
ReEarlyBound
(
id
,
index
,
ident
)
=>
ty
::
ReEarlyB
ound
(
xcx
.tr_id
(
id
),
index
,
ident
),
ty
::
re_scope
(
id
)
=>
ty
::
re_s
cope
(
xcx
.tr_id
(
id
)),
ty
::
re_empty
|
ty
::
re_static
|
ty
::
re_i
nfer
(
*
)
=>
*
self
,
ty
::
re_f
ree
(
ref
fr
)
=>
{
ty
::
re_f
ree
(
ty
::
FreeRegion
{
scope_id
:
xcx
.tr_id
(
fr
.scope_id
),
ty
::
ReScope
(
id
)
=>
ty
::
ReS
cope
(
xcx
.tr_id
(
id
)),
ty
::
ReEmpty
|
ty
::
ReStatic
|
ty
::
ReI
nfer
(
*
)
=>
*
self
,
ty
::
ReF
ree
(
ref
fr
)
=>
{
ty
::
ReF
ree
(
ty
::
FreeRegion
{
scope_id
:
xcx
.tr_id
(
fr
.scope_id
),
bound_region
:
fr
.bound_region
.tr
(
xcx
)})
}
}
}
}
impl
tr
for
ty
::
bound_r
egion
{
fn
tr
(
&
self
,
xcx
:
@
ExtendedDecodeContext
)
->
ty
::
bound_r
egion
{
impl
tr
for
ty
::
BoundR
egion
{
fn
tr
(
&
self
,
xcx
:
@
ExtendedDecodeContext
)
->
ty
::
BoundR
egion
{
match
*
self
{
ty
::
br_a
non
(
_
)
|
ty
::
br_f
resh
(
_
)
=>
*
self
,
ty
::
br_named
(
id
,
ident
)
=>
ty
::
br_n
amed
(
xcx
.tr_def_id
(
id
),
ty
::
BrA
non
(
_
)
|
ty
::
BrF
resh
(
_
)
=>
*
self
,
ty
::
BrNamed
(
id
,
ident
)
=>
ty
::
BrN
amed
(
xcx
.tr_def_id
(
id
),
ident
),
}
}
...
...
src/librustc/middle/borrowck/gather_loans/lifetime.rs
浏览文件 @
195f1d77
...
...
@@ -199,7 +199,7 @@ fn check_root(&self,
// Make sure that the loan does not exceed the maximum time
// that we can root the value, dynamically.
let
root_region
=
ty
::
re_s
cope
(
self
.root_scope_id
);
let
root_region
=
ty
::
ReS
cope
(
self
.root_scope_id
);
if
!
self
.bccx
.is_subregion_of
(
self
.loan_region
,
root_region
)
{
self
.report_error
(
err_out_of_root_scope
(
root_region
,
self
.loan_region
));
...
...
@@ -208,9 +208,9 @@ fn check_root(&self,
// Extract the scope id that indicates how long the rooting is required
let
root_scope
=
match
self
.loan_region
{
ty
::
re_s
cope
(
id
)
=>
id
,
ty
::
ReS
cope
(
id
)
=>
id
,
_
=>
{
// the check above should fail for anything is not
re_s
cope
// the check above should fail for anything is not
ReS
cope
self
.bccx.tcx.sess
.span_bug
(
cmt_base
.span
,
format!
(
"Cannot issue root for scope region: {:?}"
,
...
...
@@ -260,12 +260,12 @@ fn check_root(&self,
note_and_explain_region
(
self
.bccx.tcx
,
"managed value only needs to be frozen for "
,
ty
::
re_s
cope
(
root_scope
),
ty
::
ReS
cope
(
root_scope
),
"..."
);
note_and_explain_region
(
self
.bccx.tcx
,
"...but due to Issue #6248, it will be frozen for "
,
ty
::
re_s
cope
(
cleanup_scope
),
ty
::
ReS
cope
(
cleanup_scope
),
""
);
}
...
...
@@ -324,13 +324,13 @@ fn scope(&self, cmt: mc::cmt) -> ty::Region {
match
cmt
.cat
{
mc
::
cat_rvalue
(
cleanup_scope_id
)
=>
{
ty
::
re_s
cope
(
cleanup_scope_id
)
ty
::
ReS
cope
(
cleanup_scope_id
)
}
mc
::
cat_copied_upvar
(
_
)
=>
{
ty
::
re_s
cope
(
self
.item_scope_id
)
ty
::
ReS
cope
(
self
.item_scope_id
)
}
mc
::
cat_static_item
=>
{
ty
::
re_s
tatic
ty
::
ReS
tatic
}
mc
::
cat_local
(
local_id
)
|
mc
::
cat_arg
(
local_id
)
|
...
...
@@ -338,7 +338,7 @@ fn scope(&self, cmt: mc::cmt) -> ty::Region {
self
.bccx.tcx.region_maps
.encl_region
(
local_id
)
}
mc
::
cat_deref
(
_
,
_
,
mc
::
unsafe_ptr
(
*
))
=>
{
ty
::
re_s
tatic
ty
::
ReS
tatic
}
mc
::
cat_deref
(
_
,
_
,
mc
::
region_ptr
(
_
,
r
))
=>
{
r
...
...
src/librustc/middle/borrowck/gather_loans/mod.rs
浏览文件 @
195f1d77
...
...
@@ -277,7 +277,7 @@ fn gather_loans_in_expr(this: &mut GatherLoanCtxt,
// Currently these do not use adjustments, so we have to
// hardcode this check here (note that the receiver DOES use
// adjustments).
let
scope_r
=
ty
::
re_s
cope
(
ex
.id
);
let
scope_r
=
ty
::
ReS
cope
(
ex
.id
);
let
arg_cmt
=
this
.bccx
.cat_expr
(
arg
);
this
.guarantee_valid
(
arg
.id
,
arg
.span
,
...
...
@@ -441,7 +441,7 @@ pub fn guarantee_valid(&mut self,
// a loan for the empty region can never be dereferenced, so
// it is always safe
if
loan_region
==
ty
::
re_e
mpty
{
if
loan_region
==
ty
::
ReE
mpty
{
return
;
}
...
...
@@ -470,10 +470,10 @@ pub fn guarantee_valid(&mut self,
restrictions
::
SafeIf
(
loan_path
,
restrictions
)
=>
{
let
loan_scope
=
match
loan_region
{
ty
::
re_s
cope
(
id
)
=>
id
,
ty
::
re_f
ree
(
ref
fr
)
=>
fr
.scope_id
,
ty
::
ReS
cope
(
id
)
=>
id
,
ty
::
ReF
ree
(
ref
fr
)
=>
fr
.scope_id
,
ty
::
re_s
tatic
=>
{
ty
::
ReS
tatic
=>
{
// If we get here, an error must have been
// reported in
// `lifetime::guarantee_lifetime()`, because
...
...
@@ -485,10 +485,10 @@ pub fn guarantee_valid(&mut self,
return
;
}
ty
::
re_e
mpty
|
ty
::
re_fn_b
ound
(
*
)
|
ty
::
re_type_b
ound
(
*
)
|
ty
::
re_i
nfer
(
*
)
=>
{
ty
::
ReE
mpty
|
ty
::
ReLateB
ound
(
*
)
|
ty
::
ReEarlyB
ound
(
*
)
|
ty
::
ReI
nfer
(
*
)
=>
{
self
.tcx
()
.sess
.span_bug
(
cmt
.span
,
format!
(
"Invalid borrow lifetime: {:?}"
,
loan_region
));
...
...
@@ -715,7 +715,7 @@ fn gather_pat(&mut self,
let
cmt_discr
=
match
arm_match_ids
{
None
=>
cmt
,
Some
((
arm_id
,
match_id
))
=>
{
let
arm_scope
=
ty
::
re_s
cope
(
arm_id
);
let
arm_scope
=
ty
::
ReS
cope
(
arm_id
);
if
self
.bccx
.is_subregion_of
(
scope_r
,
arm_scope
)
{
self
.bccx
.cat_discr
(
cmt
,
match_id
)
}
else
{
...
...
src/librustc/middle/kind.rs
浏览文件 @
195f1d77
...
...
@@ -545,7 +545,7 @@ pub fn check_cast_for_escaping_regions(
// Check, based on the region associated with the trait, whether it can
// possibly escape the enclosing fn item (note that all type parameters
// must have been declared on the enclosing fn item).
if
target_regions
.iter
()
.any
(|
r
|
is_
re_s
cope
(
*
r
))
{
if
target_regions
.iter
()
.any
(|
r
|
is_
ReS
cope
(
*
r
))
{
return
;
/* case (1) */
}
...
...
@@ -584,9 +584,9 @@ pub fn check_cast_for_escaping_regions(
}
});
fn
is_
re_s
cope
(
r
:
ty
::
Region
)
->
bool
{
fn
is_
ReS
cope
(
r
:
ty
::
Region
)
->
bool
{
match
r
{
ty
::
re_s
cope
(
*
)
=>
true
,
ty
::
ReS
cope
(
*
)
=>
true
,
_
=>
false
}
}
...
...
src/librustc/middle/region.rs
浏览文件 @
195f1d77
...
...
@@ -137,7 +137,7 @@ pub fn cleanup_scope(&self, expr_id: ast::NodeId) -> ast::NodeId {
pub
fn
encl_region
(
&
self
,
id
:
ast
::
NodeId
)
->
ty
::
Region
{
//! Returns the narrowest scope region that encloses `id`, if any.
ty
::
re_s
cope
(
self
.encl_scope
(
id
))
ty
::
ReS
cope
(
self
.encl_scope
(
id
))
}
pub
fn
scopes_intersect
(
&
self
,
scope1
:
ast
::
NodeId
,
scope2
:
ast
::
NodeId
)
...
...
@@ -227,19 +227,19 @@ pub fn is_subregion_of(&self,
sub_region
==
super_region
||
{
match
(
sub_region
,
super_region
)
{
(
_
,
ty
::
re_s
tatic
)
=>
{
(
_
,
ty
::
ReS
tatic
)
=>
{
true
}
(
ty
::
re_scope
(
sub_scope
),
ty
::
re_s
cope
(
super_scope
))
=>
{
(
ty
::
ReScope
(
sub_scope
),
ty
::
ReS
cope
(
super_scope
))
=>
{
self
.is_subscope_of
(
sub_scope
,
super_scope
)
}
(
ty
::
re_scope
(
sub_scope
),
ty
::
re_f
ree
(
ref
fr
))
=>
{
(
ty
::
ReScope
(
sub_scope
),
ty
::
ReF
ree
(
ref
fr
))
=>
{
self
.is_subscope_of
(
sub_scope
,
fr
.scope_id
)
}
(
ty
::
re_free
(
sub_fr
),
ty
::
re_f
ree
(
super_fr
))
=>
{
(
ty
::
ReFree
(
sub_fr
),
ty
::
ReF
ree
(
super_fr
))
=>
{
self
.sub_free_region
(
sub_fr
,
super_fr
)
}
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
195f1d77
...
...
@@ -176,7 +176,7 @@ fn resolve_lifetime_ref(&self,
ItemScope
(
lifetimes
)
=>
{
match
search_lifetimes
(
lifetimes
,
lifetime_ref
)
{
Some
((
index
,
decl_id
))
=>
{
let
def
=
ast
::
Def
Type
BoundRegion
(
index
,
decl_id
);
let
def
=
ast
::
Def
Early
BoundRegion
(
index
,
decl_id
);
self
.insert_lifetime
(
lifetime_ref
,
def
);
return
;
}
...
...
@@ -189,7 +189,7 @@ fn resolve_lifetime_ref(&self,
FnScope
(
id
,
lifetimes
,
s
)
=>
{
match
search_lifetimes
(
lifetimes
,
lifetime_ref
)
{
Some
((
_
index
,
decl_id
))
=>
{
let
def
=
ast
::
Def
Fn
BoundRegion
(
id
,
depth
,
decl_id
);
let
def
=
ast
::
Def
Late
BoundRegion
(
id
,
depth
,
decl_id
);
self
.insert_lifetime
(
lifetime_ref
,
def
);
return
;
}
...
...
src/librustc/middle/subst.rs
浏览文件 @
195f1d77
...
...
@@ -193,9 +193,9 @@ fn subst(&self, _tcx: ty::ctxt, substs: &ty::substs) -> ty::Region {
// the specialized routine
// `middle::typeck::check::regionmanip::replace_bound_regions_in_fn_sig()`.
match
self
{
&
ty
::
re_type_b
ound
(
_
,
i
,
_
)
=>
{
&
ty
::
ReEarlyB
ound
(
_
,
i
,
_
)
=>
{
match
substs
.regions
{
ty
::
ErasedRegions
=>
ty
::
re_s
tatic
,
ty
::
ErasedRegions
=>
ty
::
ReS
tatic
,
ty
::
NonerasedRegions
(
ref
regions
)
=>
*
regions
.get
(
i
),
}
}
...
...
src/librustc/middle/trans/_match.rs
浏览文件 @
195f1d77
...
...
@@ -1048,7 +1048,7 @@ fn extract_vec_elems(bcx: @mut Block,
let
slice_len
=
Sub
(
bcx
,
len
,
slice_len_offset
);
let
slice_ty
=
ty
::
mk_evec
(
bcx
.tcx
(),
ty
::
mt
{
ty
:
vt
.unit_ty
,
mutbl
:
ast
::
MutImmutable
},
ty
::
vstore_slice
(
ty
::
re_s
tatic
)
ty
::
vstore_slice
(
ty
::
ReS
tatic
)
);
let
scratch
=
scratch_datum
(
bcx
,
slice_ty
,
""
,
false
);
Store
(
bcx
,
slice_begin
,
...
...
@@ -1697,7 +1697,7 @@ fn compile_submatch_continue(mut bcx: @mut Block,
let
t
=
node_id_type
(
bcx
,
pat_id
);
let
Result
{
bcx
:
after_cx
,
val
:
matches
}
=
{
do
with_scope_result
(
bcx
,
None
,
"compa
re_s
cope"
)
|
bcx
|
{
"compa
ReS
cope"
)
|
bcx
|
{
match
trans_opt
(
bcx
,
opt
)
{
single_result
(
Result
{
bcx
,
val
})
=>
{
...
...
src/librustc/middle/trans/consts.rs
浏览文件 @
195f1d77
...
...
@@ -181,7 +181,7 @@ pub fn const_expr(cx: @mut CrateContext, e: &ast::Expr) -> (ValueRef, bool) {
let
adjustment
=
cx
.tcx.adjustments
.find_copy
(
&
e
.id
);
match
adjustment
{
None
=>
{
}
Some
(
@
ty
::
AutoAddEnv
(
ty
::
re_s
tatic
,
ast
::
BorrowedSigil
))
=>
{
Some
(
@
ty
::
AutoAddEnv
(
ty
::
ReS
tatic
,
ast
::
BorrowedSigil
))
=>
{
llconst
=
C_struct
([
llconst
,
C_null
(
Type
::
opaque_box
(
cx
)
.ptr_to
())],
false
)
}
Some
(
@
ty
::
AutoAddEnv
(
ref
r
,
ref
s
))
=>
{
...
...
@@ -211,11 +211,11 @@ pub fn const_expr(cx: @mut CrateContext, e: &ast::Expr) -> (ValueRef, bool) {
};
match
*
autoref
{
ty
::
AutoUnsafe
(
m
)
|
ty
::
AutoPtr
(
ty
::
re_s
tatic
,
m
)
=>
{
ty
::
AutoPtr
(
ty
::
ReS
tatic
,
m
)
=>
{
assert
!
(
m
!=
ast
::
MutMutable
);
llconst
=
llptr
;
}
ty
::
AutoBorrowVec
(
ty
::
re_s
tatic
,
m
)
=>
{
ty
::
AutoBorrowVec
(
ty
::
ReS
tatic
,
m
)
=>
{
assert
!
(
m
!=
ast
::
MutMutable
);
assert_eq!
(
abi
::
slice_elt_base
,
0
);
assert_eq!
(
abi
::
slice_elt_len
,
1
);
...
...
src/librustc/middle/trans/datum.rs
浏览文件 @
195f1d77
...
...
@@ -588,7 +588,7 @@ pub fn to_rptr(&self, bcx: @mut Block) -> Datum {
// result (which will be by-value). Note that it is not
// significant *which* region we pick here.
let
llval
=
self
.to_ref_llval
(
bcx
);
let
rptr_ty
=
ty
::
mk_imm_rptr
(
bcx
.tcx
(),
ty
::
re_s
tatic
,
let
rptr_ty
=
ty
::
mk_imm_rptr
(
bcx
.tcx
(),
ty
::
ReS
tatic
,
self
.ty
);
Datum
{
val
:
llval
,
ty
:
rptr_ty
,
mode
:
ByValue
}
}
...
...
src/librustc/middle/trans/expr.rs
浏览文件 @
195f1d77
...
...
@@ -271,7 +271,7 @@ fn auto_slice(bcx: @mut Block,
// real one, but it will have the same runtime representation
let
slice_ty
=
ty
::
mk_evec
(
tcx
,
ty
::
mt
{
ty
:
unit_ty
,
mutbl
:
ast
::
MutImmutable
},
ty
::
vstore_slice
(
ty
::
re_s
tatic
));
ty
::
vstore_slice
(
ty
::
ReS
tatic
));
let
scratch
=
scratch_datum
(
bcx
,
slice_ty
,
"__adjust"
,
false
);
...
...
src/librustc/middle/trans/glue.rs
浏览文件 @
195f1d77
...
...
@@ -339,7 +339,7 @@ pub fn make_visit_glue(bcx: @mut Block, v: ValueRef, t: ty::t) -> @mut Block {
do
with_scope
(
bcx
,
None
,
"visitor cleanup"
)
|
bcx
|
{
let
mut
bcx
=
bcx
;
let
(
visitor_trait
,
object_ty
)
=
match
ty
::
visitor_object_ty
(
bcx
.tcx
(),
ty
::
re_s
tatic
)
{
ty
::
ReS
tatic
)
{
Ok
(
pair
)
=>
pair
,
Err
(
s
)
=>
{
bcx
.tcx
()
.sess
.fatal
(
s
);
...
...
src/librustc/middle/trans/reflect.rs
浏览文件 @
195f1d77
...
...
@@ -59,7 +59,7 @@ pub fn c_slice(&mut self, s: @str) -> ValueRef {
// We're careful to not use first class aggregates here because that
// will kick us off fast isel. (Issue #4352.)
let
bcx
=
self
.bcx
;
let
str_vstore
=
ty
::
vstore_slice
(
ty
::
re_s
tatic
);
let
str_vstore
=
ty
::
vstore_slice
(
ty
::
ReS
tatic
);
let
str_ty
=
ty
::
mk_estr
(
bcx
.tcx
(),
str_vstore
);
let
scratch
=
scratch_datum
(
bcx
,
str_ty
,
""
,
false
);
let
len
=
C_uint
(
bcx
.ccx
(),
s
.len
());
...
...
src/librustc/middle/ty.rs
浏览文件 @
195f1d77
...
...
@@ -470,43 +470,45 @@ pub struct param_ty {
/// Representation of regions:
#[deriving(Clone,
Eq,
IterBytes,
Encodable,
Decodable,
ToStr)]
pub
enum
Region
{
// Region bound in a type declaration (type/enum/struct/trait),
// which will be substituted when an instance of the type is accessed
re_type_bound
(
/* param id */
ast
::
NodeId
,
/*index*/
uint
,
ast
::
Ident
),
// Region bound in a type or fn declaration which will be
// substituted 'early' -- that is, at the same time when type
// parameters are substituted.
ReEarlyBound
(
/* param id */
ast
::
NodeId
,
/*index*/
uint
,
ast
::
Ident
),
// Region bound in a fn scope, which will be substituted when the
// fn is called.
re_fn_bound
(
/* binder_id */
ast
::
NodeId
,
bound_region
),
// Region bound in a function scope, which will be substituted when the
// function is called. The first argument must be the `binder_id` of
// some enclosing function signature.
ReLateBound
(
/* binder_id */
ast
::
NodeId
,
BoundRegion
),
/// When checking a function body, the types of all arguments and so forth
/// that refer to bound region parameters are modified to refer to free
/// region parameters.
re_f
ree
(
FreeRegion
),
ReF
ree
(
FreeRegion
),
/// A concrete region naming some expression within the current function.
re_s
cope
(
NodeId
),
ReS
cope
(
NodeId
),
/// Static data that has an "infinite" lifetime. Top in the region lattice.
re_s
tatic
,
ReS
tatic
,
/// A region variable. Should not exist after typeck.
re_i
nfer
(
InferRegion
),
ReI
nfer
(
InferRegion
),
/// Empty lifetime is for data that is never accessed.
/// Bottom in the region lattice. We treat
re_e
mpty somewhat
/// Bottom in the region lattice. We treat
ReE
mpty somewhat
/// specially; at least right now, we do not generate instances of
/// it during the GLB computations, but rather
/// generate an error instead. This is to improve error messages.
/// The only way to get an instance of
re_e
mpty is to have a region
/// The only way to get an instance of
ReE
mpty is to have a region
/// variable with no constraints.
re_e
mpty
,
ReE
mpty
,
}
impl
Region
{
pub
fn
is_bound
(
&
self
)
->
bool
{
match
self
{
&
ty
::
re_type_b
ound
(
*
)
=>
true
,
&
ty
::
re_fn_b
ound
(
*
)
=>
true
,
&
ty
::
ReEarlyB
ound
(
*
)
=>
true
,
&
ty
::
ReLateB
ound
(
*
)
=>
true
,
_
=>
false
}
}
...
...
@@ -515,28 +517,28 @@ pub fn is_bound(&self) -> bool {
#[deriving(Clone,
Eq,
TotalOrd,
TotalEq,
IterBytes,
Encodable,
Decodable,
ToStr)]
pub
struct
FreeRegion
{
scope_id
:
NodeId
,
bound_region
:
bound_r
egion
bound_region
:
BoundR
egion
}
#[deriving(Clone,
Eq,
TotalEq,
TotalOrd,
IterBytes,
Encodable,
Decodable,
ToStr)]
pub
enum
bound_r
egion
{
pub
enum
BoundR
egion
{
/// An anonymous region parameter for a given fn (&T)
br_a
non
(
uint
),
BrA
non
(
uint
),
/// Named region parameters for functions (a in &'a T)
///
/// The def-id is needed to distinguish free regions in
/// the event of shadowing.
br_n
amed
(
ast
::
DefId
,
ast
::
Ident
),
BrN
amed
(
ast
::
DefId
,
ast
::
Ident
),
/// Fresh bound identifiers created during GLB computations.
br_f
resh
(
uint
),
BrF
resh
(
uint
),
}
/**
* Represents the values to use when substituting lifetime parameters.
* If the value is `ErasedRegions`, then this subst is occurring during
* trans, and all region parameters will be replaced with `ty::
re_s
tatic`. */
* trans, and all region parameters will be replaced with `ty::
ReS
tatic`. */
#[deriving(Clone,
Eq,
IterBytes)]
pub
enum
RegionSubsts
{
ErasedRegions
,
...
...
@@ -701,8 +703,8 @@ pub enum type_err {
terr_regions_does_not_outlive
(
Region
,
Region
),
terr_regions_not_same
(
Region
,
Region
),
terr_regions_no_overlap
(
Region
,
Region
),
terr_regions_insufficiently_polymorphic
(
bound_r
egion
,
Region
),
terr_regions_overly_polymorphic
(
bound_r
egion
,
Region
),
terr_regions_insufficiently_polymorphic
(
BoundR
egion
,
Region
),
terr_regions_overly_polymorphic
(
BoundR
egion
,
Region
),
terr_vstores_differ
(
terr_vstore_kind
,
expected_found
<
vstore
>
),
terr_trait_stores_differ
(
terr_vstore_kind
,
expected_found
<
TraitStore
>
),
terr_in_field
(
@
type_err
,
ast
::
Ident
),
...
...
@@ -778,7 +780,7 @@ pub enum InferTy {
#[deriving(Clone,
Encodable,
Decodable,
IterBytes,
ToStr)]
pub
enum
InferRegion
{
ReVar
(
RegionVid
),
ReSkolemized
(
uint
,
bound_r
egion
)
ReSkolemized
(
uint
,
BoundR
egion
)
}
impl
cmp
::
Eq
for
InferRegion
{
...
...
@@ -1043,7 +1045,7 @@ pub fn mk_t(cx: ctxt, st: sty) -> t {
fn
rflags
(
r
:
Region
)
->
uint
{
(
has_regions
as
uint
)
|
{
match
r
{
ty
::
re_i
nfer
(
_
)
=>
needs_infer
as
uint
,
ty
::
ReI
nfer
(
_
)
=>
needs_infer
as
uint
,
_
=>
0u
}
}
...
...
@@ -2148,7 +2150,7 @@ fn borrowed_contents(region: ty::Region,
ast
::
MutMutable
=>
TC
::
ReachesMutable
|
TC
::
OwnsAffine
,
ast
::
MutImmutable
=>
TC
::
None
,
};
b
|
(
TC
::
ReachesBorrowed
)
.when
(
region
!=
ty
::
re_s
tatic
)
b
|
(
TC
::
ReachesBorrowed
)
.when
(
region
!=
ty
::
ReS
tatic
)
}
fn
closure_contents
(
cx
:
ctxt
,
cty
:
&
ClosureTy
)
->
TypeContents
{
...
...
@@ -4220,12 +4222,12 @@ fn fold_ty(&mut self, t: ty::t) -> ty::t {
fn
fold_vstore
(
&
mut
self
,
vstore
:
vstore
)
->
vstore
{
match
vstore
{
vstore_fixed
(
*
)
|
vstore_uniq
|
vstore_box
=>
vstore
,
vstore_slice
(
_
)
=>
vstore_slice
(
re_s
tatic
)
vstore_slice
(
_
)
=>
vstore_slice
(
ReS
tatic
)
}
}
fn
fold_region
(
&
mut
self
,
_
:
ty
::
Region
)
->
ty
::
Region
{
ty
::
re_s
tatic
ty
::
ReS
tatic
}
fn
fold_substs
(
&
mut
self
,
...
...
@@ -4564,10 +4566,16 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: @str) -> u64 {
let
mut
hash
=
SipState
::
new
(
0
,
0
);
let
region
=
|
_
hash
:
&
mut
SipState
,
r
:
Region
|
{
match
r
{
re_static
=>
{}
re_empty
|
re_bound
(
*
)
|
re_free
(
*
)
|
re_scope
(
*
)
|
re_infer
(
*
)
=>
ReStatic
=>
{}
ReEmpty
|
ReEarlyBound
(
*
)
|
ReLateBound
(
*
)
|
ReFree
(
*
)
|
ReStatic
(
*
)
|
ReInfer
(
*
)
=>
{
tcx
.sess
.bug
(
"non-static region found when hashing a type"
)
}
}
};
let
vstore
=
|
hash
:
&
mut
SipState
,
v
:
vstore
|
{
...
...
@@ -4751,9 +4759,9 @@ pub fn construct_parameter_environment(
// map bound 'a => free 'a
let
region_params
=
item_region_params
.iter
()
.
map
(|
r
|
ty
::
re_f
ree
(
ty
::
FreeRegion
{
map
(|
r
|
ty
::
ReF
ree
(
ty
::
FreeRegion
{
scope_id
:
free_id
,
bound_region
:
ty
::
br_n
amed
(
r
.def_id
,
r
.ident
)}))
.
bound_region
:
ty
::
BrN
amed
(
r
.def_id
,
r
.ident
)}))
.
collect
();
let
free_substs
=
substs
{
...
...
src/librustc/middle/typeck/astconv.rs
浏览文件 @
195f1d77
...
...
@@ -87,23 +87,23 @@ pub fn ast_region_to_region(
}
Some
(
&
ast
::
DefStaticRegion
)
=>
{
ty
::
re_s
tatic
ty
::
ReS
tatic
}
Some
(
&
ast
::
Def
Fn
BoundRegion
(
binder_id
,
_
,
id
))
=>
{
ty
::
re_fn_bound
(
binder_id
,
ty
::
br_n
amed
(
ast_util
::
local_def
(
id
),
lifetime
.ident
))
Some
(
&
ast
::
Def
Late
BoundRegion
(
binder_id
,
_
,
id
))
=>
{
ty
::
ReLateBound
(
binder_id
,
ty
::
BrN
amed
(
ast_util
::
local_def
(
id
),
lifetime
.ident
))
}
Some
(
&
ast
::
Def
Type
BoundRegion
(
index
,
id
))
=>
{
ty
::
re_type_b
ound
(
id
,
index
,
lifetime
.ident
)
Some
(
&
ast
::
Def
Early
BoundRegion
(
index
,
id
))
=>
{
ty
::
ReEarlyB
ound
(
id
,
index
,
lifetime
.ident
)
}
Some
(
&
ast
::
DefFreeRegion
(
scope_id
,
id
))
=>
{
ty
::
re_f
ree
(
ty
::
FreeRegion
{
ty
::
ReF
ree
(
ty
::
FreeRegion
{
scope_id
:
scope_id
,
bound_region
:
ty
::
br_n
amed
(
ast_util
::
local_def
(
id
),
lifetime
.ident
)
bound_region
:
ty
::
BrN
amed
(
ast_util
::
local_def
(
id
),
lifetime
.ident
)
})
}
};
...
...
@@ -133,7 +133,7 @@ pub fn opt_ast_region_to_region<AC:AstConv,RS:RegionScope>(
debug!
(
"optional region in illegal location"
);
this
.tcx
()
.sess
.span_err
(
default_span
,
"missing lifetime specifier"
);
ty
::
re_s
tatic
ty
::
ReS
tatic
}
Some
(
rs
)
=>
{
...
...
@@ -190,7 +190,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
match
anon_regions
{
Some
(
v
)
=>
opt_vec
::
from
(
v
),
None
=>
opt_vec
::
from
(
vec
::
from_fn
(
expected_num_region_params
,
|
_
|
ty
::
re_s
tatic
))
// hokey
|
_
|
ty
::
ReS
tatic
))
// hokey
}
};
...
...
@@ -431,7 +431,7 @@ fn check_path_args(tcx: ty::ctxt,
let
bounds
=
conv_builtin_bounds
(
this
.tcx
(),
&
f
.bounds
,
match
f
.sigil
{
// Use corresponding trait store to figure out default bounds
// if none were specified.
ast
::
BorrowedSigil
=>
ty
::
RegionTraitStore
(
ty
::
re_e
mpty
),
// dummy region
ast
::
BorrowedSigil
=>
ty
::
RegionTraitStore
(
ty
::
ReE
mpty
),
// dummy region
ast
::
OwnedSigil
=>
ty
::
UniqTraitStore
,
ast
::
ManagedSigil
=>
ty
::
BoxTraitStore
,
});
...
...
@@ -713,7 +713,7 @@ pub fn ty_of_closure<AC:AstConv,RS:RegionScope>(
ast
::
OwnedSigil
|
ast
::
ManagedSigil
=>
{
// @fn(), ~fn() default to static as the bound
// on their upvars:
ty
::
re_s
tatic
ty
::
ReS
tatic
}
ast
::
BorrowedSigil
=>
{
// &fn() defaults as normal for an omitted lifetime:
...
...
@@ -803,7 +803,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt, ast_bounds: &Option<OptVec<ast::TyParamBou
// @Trait is sugar for @Trait:'static.
// &'static Trait is sugar for &'static Trait:'static.
(
&
None
,
ty
::
BoxTraitStore
)
|
(
&
None
,
ty
::
RegionTraitStore
(
ty
::
re_s
tatic
))
=>
{
(
&
None
,
ty
::
RegionTraitStore
(
ty
::
ReS
tatic
))
=>
{
let
mut
set
=
ty
::
EmptyBuiltinBounds
();
set
.add
(
ty
::
BoundStatic
);
set
}
// &'r Trait is sugar for &'r Trait:<no-bounds>.
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
195f1d77
...
...
@@ -438,7 +438,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
let
(
_
,
opt_self_ty
,
fn_sig
)
=
replace_bound_regions_in_fn_sig
(
tcx
,
opt_self_ty
,
fn_sig
,
|
br
|
ty
::
re_f
ree
(
ty
::
FreeRegion
{
scope_id
:
body
.id
,
|
br
|
ty
::
ReF
ree
(
ty
::
FreeRegion
{
scope_id
:
body
.id
,
bound_region
:
br
}));
let
opt_self_info
=
opt_self_info
.map
(
...
...
@@ -931,9 +931,9 @@ pub fn compare_impl_method(tcx: ty::ctxt,
collect
();
let
dummy_impl_regions
:
OptVec
<
ty
::
Region
>
=
impl_generics
.region_param_defs
.iter
()
.
map
(|
l
|
ty
::
re_f
ree
(
ty
::
FreeRegion
{
map
(|
l
|
ty
::
ReF
ree
(
ty
::
FreeRegion
{
scope_id
:
impl_m_body_id
,
bound_region
:
ty
::
br_n
amed
(
l
.def_id
,
l
.ident
)}))
.
bound_region
:
ty
::
BrN
amed
(
l
.def_id
,
l
.ident
)}))
.
collect
();
let
dummy_substs
=
ty
::
substs
{
tps
:
vec
::
append
(
dummy_impl_tps
,
dummy_method_tps
),
...
...
@@ -1090,7 +1090,7 @@ pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> ty::t {
}
pub
fn
block_region
(
&
self
)
->
ty
::
Region
{
ty
::
re_s
cope
(
self
.region_lb
)
ty
::
ReS
cope
(
self
.region_lb
)
}
#[inline]
...
...
@@ -1357,10 +1357,10 @@ pub fn check_lit(fcx: @mut FnCtxt, lit: @ast::lit) -> ty::t {
let
tcx
=
fcx
.ccx.tcx
;
match
lit
.node
{
ast
::
lit_str
(
*
)
=>
ty
::
mk_estr
(
tcx
,
ty
::
vstore_slice
(
ty
::
re_s
tatic
)),
ast
::
lit_str
(
*
)
=>
ty
::
mk_estr
(
tcx
,
ty
::
vstore_slice
(
ty
::
ReS
tatic
)),
ast
::
lit_binary
(
*
)
=>
{
ty
::
mk_evec
(
tcx
,
ty
::
mt
{
ty
:
ty
::
mk_u8
(),
mutbl
:
ast
::
MutImmutable
},
ty
::
vstore_slice
(
ty
::
re_s
tatic
))
ty
::
vstore_slice
(
ty
::
ReS
tatic
))
}
ast
::
lit_char
(
_
)
=>
ty
::
mk_char
(),
ast
::
lit_int
(
_
,
t
)
=>
ty
::
mk_mach_int
(
t
),
...
...
@@ -3925,19 +3925,19 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t {
//We only care about the operation here
match
split
[
1
]
{
"cxchg"
=>
(
0
,
~
[
ty
::
mk_mut_rptr
(
tcx
,
ty
::
re_fn_bound
(
it
.id
,
ty
::
br_a
non
(
0
)),
ty
::
ReLateBound
(
it
.id
,
ty
::
BrA
non
(
0
)),
ty
::
mk_int
()),
ty
::
mk_int
(),
ty
::
mk_int
()
],
ty
::
mk_int
()),
"load"
=>
(
0
,
~
[
ty
::
mk_imm_rptr
(
tcx
,
ty
::
re_fn_bound
(
it
.id
,
ty
::
br_a
non
(
0
)),
ty
::
mk_int
())
ty
::
mk_imm_rptr
(
tcx
,
ty
::
ReLateBound
(
it
.id
,
ty
::
BrA
non
(
0
)),
ty
::
mk_int
())
],
ty
::
mk_int
()),
"store"
=>
(
0
,
~
[
ty
::
mk_mut_rptr
(
tcx
,
ty
::
re_fn_bound
(
it
.id
,
ty
::
br_a
non
(
0
)),
ty
::
mk_int
()),
ty
::
mk_mut_rptr
(
tcx
,
ty
::
ReLateBound
(
it
.id
,
ty
::
BrA
non
(
0
)),
ty
::
mk_int
()),
ty
::
mk_int
()
],
ty
::
mk_nil
()),
...
...
@@ -3945,7 +3945,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t {
"xchg"
|
"xadd"
|
"xsub"
|
"and"
|
"nand"
|
"or"
|
"xor"
|
"max"
|
"min"
|
"umax"
|
"umin"
=>
{
(
0
,
~
[
ty
::
mk_mut_rptr
(
tcx
,
ty
::
re_fn_bound
(
it
.id
,
ty
::
br_a
non
(
0
)),
ty
::
ReLateBound
(
it
.id
,
ty
::
BrA
non
(
0
)),
ty
::
mk_int
()),
ty
::
mk_int
()
],
ty
::
mk_int
())
}
"fence"
=>
{
...
...
@@ -3971,7 +3971,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t {
"move_val"
|
"move_val_init"
=>
{
(
1u
,
~
[
ty
::
mk_mut_rptr
(
tcx
,
ty
::
re_fn_bound
(
it
.id
,
ty
::
br_a
non
(
0
)),
param
(
ccx
,
0
)),
ty
::
mk_mut_rptr
(
tcx
,
ty
::
ReLateBound
(
it
.id
,
ty
::
BrA
non
(
0
)),
param
(
ccx
,
0
)),
param
(
ccx
,
0u
)
],
ty
::
mk_nil
())
...
...
@@ -3983,7 +3983,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t {
"atomic_xchg_rel"
|
"atomic_xadd_rel"
|
"atomic_xsub_rel"
=>
{
(
0
,
~
[
ty
::
mk_mut_rptr
(
tcx
,
ty
::
re_fn_bound
(
it
.id
,
ty
::
br_a
non
(
0
)),
ty
::
mk_int
()),
ty
::
mk_mut_rptr
(
tcx
,
ty
::
ReLateBound
(
it
.id
,
ty
::
BrA
non
(
0
)),
ty
::
mk_int
()),
ty
::
mk_int
()
],
ty
::
mk_int
())
...
...
@@ -4006,7 +4006,7 @@ fn param(ccx: @mut CrateCtxt, n: uint) -> ty::t {
Ok
(
t
)
=>
t
,
Err
(
s
)
=>
{
tcx
.sess
.span_fatal
(
it
.span
,
s
);
}
};
let
region
=
ty
::
re_fn_bound
(
it
.id
,
ty
::
br_a
non
(
0
));
let
region
=
ty
::
ReLateBound
(
it
.id
,
ty
::
BrA
non
(
0
));
let
visitor_object_ty
=
match
ty
::
visitor_object_ty
(
tcx
,
region
)
{
Ok
((
_
,
vot
))
=>
vot
,
Err
(
s
)
=>
{
tcx
.sess
.span_fatal
(
it
.span
,
s
);
}
...
...
src/librustc/middle/typeck/check/regionck.rs
浏览文件 @
195f1d77
...
...
@@ -29,7 +29,7 @@
use
middle
::
freevars
::
get_freevars
;
use
middle
::
ty
::{
re_s
cope
};
use
middle
::
ty
::{
ReS
cope
};
use
middle
::
ty
;
use
middle
::
typeck
::
check
::
FnCtxt
;
use
middle
::
typeck
::
check
::
regionmanip
::
relate_nested_regions
;
...
...
@@ -64,7 +64,7 @@ fn encl_region_of_def(fcx: @mut FnCtxt, def: ast::Def) -> ty::Region {
DefUpvar
(
_
,
subdef
,
closure_id
,
body_id
)
=>
{
match
ty
::
ty_closure_sigil
(
fcx
.node_ty
(
closure_id
))
{
BorrowedSigil
=>
encl_region_of_def
(
fcx
,
*
subdef
),
ManagedSigil
|
OwnedSigil
=>
re_s
cope
(
body_id
)
ManagedSigil
|
OwnedSigil
=>
ReS
cope
(
body_id
)
}
}
_
=>
{
...
...
@@ -317,7 +317,7 @@ fn visit_expr(rcx: &mut Rcx, expr: @ast::Expr) {
//
// FIXME(#6268) remove to support nested method calls
constrain_regions_in_type_of_node
(
rcx
,
expr
.id
,
ty
::
re_s
cope
(
expr
.id
),
rcx
,
expr
.id
,
ty
::
ReS
cope
(
expr
.id
),
infer
::
AutoBorrow
(
expr
.span
));
}
}
...
...
@@ -416,7 +416,7 @@ fn visit_expr(rcx: &mut Rcx, expr: @ast::Expr) {
//
// FIXME(#6268) nested method calls requires that this rule change
let
ty0
=
rcx
.resolve_node_type
(
expr
.id
);
constrain_regions_in_type
(
rcx
,
ty
::
re_s
cope
(
expr
.id
),
constrain_regions_in_type
(
rcx
,
ty
::
ReS
cope
(
expr
.id
),
infer
::
AddrOf
(
expr
.span
),
ty0
);
visit
::
walk_expr
(
rcx
,
expr
,
());
}
...
...
@@ -474,7 +474,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
// (since otherwise that would require
// infinite stack).
constrain_free_variables
(
rcx
,
region
,
expr
);
let
repeating_scope
=
ty
::
re_s
cope
(
rcx
.repeating_scope
);
let
repeating_scope
=
ty
::
ReS
cope
(
rcx
.repeating_scope
);
rcx
.fcx
.mk_subr
(
true
,
infer
::
InfStackClosure
(
expr
.span
),
region
,
repeating_scope
);
}
...
...
@@ -500,7 +500,7 @@ fn constrain_callee(rcx: &mut Rcx,
call_expr
:
@
ast
::
Expr
,
callee_expr
:
@
ast
::
Expr
)
{
let
call_region
=
ty
::
re_s
cope
(
call_expr
.id
);
let
call_region
=
ty
::
ReS
cope
(
call_expr
.id
);
let
callee_ty
=
rcx
.resolve_node_type
(
callee_id
);
match
ty
::
get
(
callee_ty
)
.sty
{
...
...
@@ -555,7 +555,7 @@ fn constrain_call(rcx: &mut Rcx,
//
// FIXME(#6268) to support nested method calls, should be callee_id
let
callee_scope
=
call_expr
.id
;
let
callee_region
=
ty
::
re_s
cope
(
callee_scope
);
let
callee_region
=
ty
::
ReS
cope
(
callee_scope
);
for
&
arg_expr
in
arg_exprs
.iter
()
{
debug!
(
"Argument"
);
...
...
@@ -604,7 +604,7 @@ fn constrain_derefs(rcx: &mut Rcx,
* the deref expr.
*/
let
tcx
=
rcx
.fcx
.tcx
();
let
r_deref_expr
=
ty
::
re_s
cope
(
deref_expr
.id
);
let
r_deref_expr
=
ty
::
ReS
cope
(
deref_expr
.id
);
for
i
in
range
(
0u
,
derefs
)
{
debug!
(
"constrain_derefs(deref_expr=?, derefd_ty={}, derefs={:?}/{:?}"
,
rcx
.fcx
.infcx
()
.ty_to_str
(
derefd_ty
),
...
...
@@ -650,7 +650,7 @@ fn constrain_index(rcx: &mut Rcx,
debug!
(
"constrain_index(index_expr=?, indexed_ty={}"
,
rcx
.fcx
.infcx
()
.ty_to_str
(
indexed_ty
));
let
r_index_expr
=
ty
::
re_s
cope
(
index_expr
.id
);
let
r_index_expr
=
ty
::
ReS
cope
(
index_expr
.id
);
match
ty
::
get
(
indexed_ty
)
.sty
{
ty
::
ty_estr
(
ty
::
vstore_slice
(
r_ptr
))
|
ty
::
ty_evec
(
_
,
ty
::
vstore_slice
(
r_ptr
))
=>
{
...
...
@@ -912,7 +912,7 @@ pub fn for_by_ref(rcx: &mut Rcx,
let
expr_cat
=
categorize
(
rcx
,
expr
);
debug!
(
"guarantor::for_by_ref(expr={:?}, callee_scope={:?}) category={:?}"
,
expr
.id
,
callee_scope
,
expr_cat
);
let
minimum_lifetime
=
ty
::
re_s
cope
(
callee_scope
);
let
minimum_lifetime
=
ty
::
ReS
cope
(
callee_scope
);
for
guarantor
in
expr_cat
.guarantor
.iter
()
{
mk_subregion_due_to_derefence
(
rcx
,
expr
.span
,
minimum_lifetime
,
*
guarantor
);
...
...
src/librustc/middle/typeck/check/regionmanip.rs
浏览文件 @
195f1d77
...
...
@@ -23,8 +23,8 @@ pub fn replace_bound_regions_in_fn_sig(
tcx
:
ty
::
ctxt
,
opt_self_ty
:
Option
<
ty
::
t
>
,
fn_sig
:
&
ty
::
FnSig
,
mapf
:
&
fn
(
ty
::
bound_r
egion
)
->
ty
::
Region
)
->
(
HashMap
<
ty
::
bound_r
egion
,
ty
::
Region
>
,
Option
<
ty
::
t
>
,
ty
::
FnSig
)
mapf
:
&
fn
(
ty
::
BoundR
egion
)
->
ty
::
Region
)
->
(
HashMap
<
ty
::
BoundR
egion
,
ty
::
Region
>
,
Option
<
ty
::
t
>
,
ty
::
FnSig
)
{
debug!
(
"replace_bound_regions_in_fn_sig(self_ty={}, fn_sig={})"
,
opt_self_ty
.repr
(
tcx
),
...
...
@@ -35,7 +35,7 @@ pub fn replace_bound_regions_in_fn_sig(
let
mut
f
=
ty_fold
::
RegionFolder
::
regions
(
tcx
,
|
r
|
{
debug!
(
"region r={}"
,
r
.to_str
());
match
r
{
ty
::
re_fn_b
ound
(
s
,
br
)
if
s
==
fn_sig
.binder_id
=>
{
ty
::
ReLateB
ound
(
s
,
br
)
if
s
==
fn_sig
.binder_id
=>
{
*
map
.find_or_insert_with
(
br
,
|
_
|
mapf
(
br
))
}
_
=>
r
...
...
@@ -175,7 +175,7 @@ pub fn relate_free_regions(
debug!
(
"relate_free_regions(t={})"
,
ppaux
::
ty_to_str
(
tcx
,
t
));
relate_nested_regions
(
tcx
,
None
,
t
,
|
a
,
b
|
{
match
(
&
a
,
&
b
)
{
(
&
ty
::
re_free
(
free_a
),
&
ty
::
re_f
ree
(
free_b
))
=>
{
(
&
ty
::
ReFree
(
free_a
),
&
ty
::
ReF
ree
(
free_b
))
=>
{
tcx
.region_maps
.relate_free_regions
(
free_a
,
free_b
);
}
_
=>
{}
...
...
src/librustc/middle/typeck/check/vtable.rs
浏览文件 @
195f1d77
...
...
@@ -480,7 +480,7 @@ fn fixup_substs(vcx: &VtableContext,
// use a dummy type just to package up the substs that need fixing up
let
t
=
ty
::
mk_trait
(
tcx
,
id
,
substs
,
ty
::
RegionTraitStore
(
ty
::
re_s
tatic
),
ty
::
RegionTraitStore
(
ty
::
ReS
tatic
),
ast
::
MutImmutable
,
ty
::
EmptyBuiltinBounds
());
do
fixup_ty
(
vcx
,
location_info
,
t
,
is_early
)
.map
|
t_f
|
{
...
...
src/librustc/middle/typeck/collect.rs
浏览文件 @
195f1d77
...
...
@@ -282,8 +282,8 @@ fn make_static_method_ty(ccx: &CrateCtxt,
// Convert the regions 'a, 'b, 'c defined on the trait into
// bound regions on the fn.
let
rps_from_trait
=
trait_ty_generics
.region_param_defs
.iter
()
.map
(|
d
|
{
ty
::
re_fn_b
ound
(
m
.fty.sig.binder_id
,
ty
::
br_n
amed
(
d
.def_id
,
d
.ident
))
ty
::
ReLateB
ound
(
m
.fty.sig.binder_id
,
ty
::
BrN
amed
(
d
.def_id
,
d
.ident
))
})
.collect
();
// build up the substitution from
...
...
@@ -964,7 +964,7 @@ pub fn mk_item_substs(ccx: &CrateCtxt,
let
regions
:
OptVec
<
ty
::
Region
>
=
ty_generics
.region_param_defs
.iter
()
.enumerate
()
.map
(
|(
i
,
l
)|
ty
::
re_type_b
ound
(
l
.def_id.node
,
i
,
l
.ident
))
.collect
();
|(
i
,
l
)|
ty
::
ReEarlyB
ound
(
l
.def_id.node
,
i
,
l
.ident
))
.collect
();
substs
{
regions
:
ty
::
NonerasedRegions
(
regions
),
self_ty
:
self_ty
,
...
...
src/librustc/middle/typeck/infer/glb.rs
浏览文件 @
195f1d77
...
...
@@ -161,7 +161,7 @@ fn generalize_region(this: &Glb,
snapshot
:
uint
,
new_vars
:
&
[
RegionVid
],
new_binder_id
:
NodeId
,
a_map
:
&
HashMap
<
ty
::
bound_r
egion
,
ty
::
Region
>
,
a_map
:
&
HashMap
<
ty
::
BoundR
egion
,
ty
::
Region
>
,
a_vars
:
&
[
RegionVid
],
b_vars
:
&
[
RegionVid
],
r0
:
ty
::
Region
)
->
ty
::
Region
{
...
...
@@ -228,13 +228,13 @@ fn generalize_region(this: &Glb,
}
fn
rev_lookup
(
this
:
&
Glb
,
a_map
:
&
HashMap
<
ty
::
bound_r
egion
,
ty
::
Region
>
,
a_map
:
&
HashMap
<
ty
::
BoundR
egion
,
ty
::
Region
>
,
new_binder_id
:
NodeId
,
r
:
ty
::
Region
)
->
ty
::
Region
{
for
(
a_br
,
a_r
)
in
a_map
.iter
()
{
if
*
a_r
==
r
{
return
ty
::
re_fn_b
ound
(
new_binder_id
,
*
a_br
);
return
ty
::
ReLateB
ound
(
new_binder_id
,
*
a_br
);
}
}
this
.infcx.tcx.sess
.span_bug
(
...
...
src/librustc/middle/typeck/infer/lattice.rs
浏览文件 @
195f1d77
...
...
@@ -522,10 +522,10 @@ pub fn lattice_var_and_t<L:LatticeDir + Combine,
// fn types
pub
fn
var_ids
<
T
:
Combine
>
(
this
:
&
T
,
map
:
&
HashMap
<
ty
::
bound_r
egion
,
ty
::
Region
>
)
map
:
&
HashMap
<
ty
::
BoundR
egion
,
ty
::
Region
>
)
->
~
[
RegionVid
]
{
map
.iter
()
.map
(|(
_
,
r
)|
match
*
r
{
ty
::
re_i
nfer
(
ty
::
ReVar
(
r
))
=>
{
r
}
ty
::
ReI
nfer
(
ty
::
ReVar
(
r
))
=>
{
r
}
r
=>
{
this
.infcx
()
.tcx.sess
.span_bug
(
this
.trace
()
.origin
.span
(),
...
...
@@ -536,7 +536,7 @@ pub fn var_ids<T:Combine>(this: &T,
pub
fn
is_var_in_set
(
new_vars
:
&
[
RegionVid
],
r
:
ty
::
Region
)
->
bool
{
match
r
{
ty
::
re_i
nfer
(
ty
::
ReVar
(
ref
v
))
=>
new_vars
.iter
()
.any
(|
x
|
x
==
v
),
ty
::
ReI
nfer
(
ty
::
ReVar
(
ref
v
))
=>
new_vars
.iter
()
.any
(|
x
|
x
==
v
),
_
=>
false
}
}
src/librustc/middle/typeck/infer/lub.rs
浏览文件 @
195f1d77
...
...
@@ -149,7 +149,7 @@ fn generalize_region(this: &Lub,
snapshot
:
uint
,
new_vars
:
&
[
RegionVid
],
new_scope
:
NodeId
,
a_map
:
&
HashMap
<
ty
::
bound_r
egion
,
ty
::
Region
>
,
a_map
:
&
HashMap
<
ty
::
BoundR
egion
,
ty
::
Region
>
,
r0
:
ty
::
Region
)
->
ty
::
Region
{
// Regions that pre-dated the LUB computation stay as they are.
...
...
@@ -182,7 +182,7 @@ fn generalize_region(this: &Lub,
debug!
(
"generalize_region(r0={:?}):
\
replacing with {:?}, tainted={:?}"
,
r0
,
*
a_br
,
tainted
);
return
ty
::
re_fn_b
ound
(
new_scope
,
*
a_br
);
return
ty
::
ReLateB
ound
(
new_scope
,
*
a_br
);
}
}
...
...
src/librustc/middle/typeck/infer/mod.rs
浏览文件 @
195f1d77
...
...
@@ -216,11 +216,11 @@ pub enum RegionVariableOrigin {
// Region variables created for bound regions
// in a function or method that is called
BoundRegionInFnCall
(
Span
,
ty
::
bound_r
egion
),
BoundRegionInFnCall
(
Span
,
ty
::
BoundR
egion
),
// Region variables created for bound regions
// when doing subtyping/lub/glb computations
BoundRegionInFnType
(
Span
,
ty
::
bound_r
egion
),
BoundRegionInFnType
(
Span
,
ty
::
BoundR
egion
),
BoundRegionInTypeOrImpl
(
Span
),
...
...
@@ -638,7 +638,7 @@ pub fn next_float_var(&mut self) -> ty::t {
}
pub
fn
next_region_var
(
&
mut
self
,
origin
:
RegionVariableOrigin
)
->
ty
::
Region
{
ty
::
re_i
nfer
(
ty
::
ReVar
(
self
.region_vars
.new_region_var
(
origin
)))
ty
::
ReI
nfer
(
ty
::
ReVar
(
self
.region_vars
.new_region_var
(
origin
)))
}
pub
fn
next_region_vars
(
&
mut
self
,
...
...
@@ -798,7 +798,7 @@ pub fn replace_bound_regions_with_fresh_regions(&mut self,
trace
:
TypeTrace
,
fsig
:
&
ty
::
FnSig
)
->
(
ty
::
FnSig
,
HashMap
<
ty
::
bound_r
egion
,
HashMap
<
ty
::
BoundR
egion
,
ty
::
Region
>
)
{
let
(
map
,
_
,
fn_sig
)
=
replace_bound_regions_in_fn_sig
(
self
.tcx
,
None
,
fsig
,
|
br
|
{
...
...
@@ -933,13 +933,13 @@ fn repr(&self, tcx: ty::ctxt) -> ~str {
AddrOfSlice
(
a
)
=>
format!
(
"AddrOfSlice({})"
,
a
.repr
(
tcx
)),
Autoref
(
a
)
=>
format!
(
"Autoref({})"
,
a
.repr
(
tcx
)),
Coercion
(
a
)
=>
format!
(
"Coercion({})"
,
a
.repr
(
tcx
)),
BoundRegionInFnCall
(
a
,
b
)
=>
format!
(
"
BoundR
egionInFnCall({},{})"
,
BoundRegionInFnCall
(
a
,
b
)
=>
format!
(
"
bound_r
egionInFnCall({},{})"
,
a
.repr
(
tcx
),
b
.repr
(
tcx
)),
BoundRegionInFnType
(
a
,
b
)
=>
format!
(
"
BoundR
egionInFnType({},{})"
,
BoundRegionInFnType
(
a
,
b
)
=>
format!
(
"
bound_r
egionInFnType({},{})"
,
a
.repr
(
tcx
),
b
.repr
(
tcx
)),
BoundRegionInTypeOrImpl
(
a
)
=>
format!
(
"
BoundR
egionInTypeOrImpl({})"
,
BoundRegionInTypeOrImpl
(
a
)
=>
format!
(
"
bound_r
egionInTypeOrImpl({})"
,
a
.repr
(
tcx
)),
BoundRegionInCoherence
=>
format!
(
"
BoundR
egionInCoherence"
),
BoundRegionInCoherence
=>
format!
(
"
bound_r
egionInCoherence"
),
}
}
}
...
...
src/librustc/middle/typeck/infer/region_inference/mod.rs
浏览文件 @
195f1d77
...
...
@@ -13,9 +13,9 @@
use
middle
::
ty
;
use
middle
::
ty
::{
FreeRegion
,
Region
,
RegionVid
};
use
middle
::
ty
::{
re_empty
,
re_static
,
re_infer
,
re_free
,
re_type_b
ound
,
re_fn_b
ound
};
use
middle
::
ty
::{
re_scope
,
ReVar
,
ReSkolemized
,
br_f
resh
};
use
middle
::
ty
::{
ReEmpty
,
ReStatic
,
ReInfer
,
ReFree
,
ReEarlyB
ound
,
ReLateB
ound
};
use
middle
::
ty
::{
ReScope
,
ReVar
,
ReSkolemized
,
BrF
resh
};
use
middle
::
typeck
::
infer
::
cres
;
use
middle
::
typeck
::
infer
::{
RegionVariableOrigin
,
SubregionOrigin
};
use
middle
::
typeck
::
infer
;
...
...
@@ -187,10 +187,10 @@ pub fn new_region_var(&mut self, origin: RegionVariableOrigin) -> RegionVid {
return
vid
;
}
pub
fn
new_skolemized
(
&
mut
self
,
br
:
ty
::
bound_r
egion
)
->
Region
{
pub
fn
new_skolemized
(
&
mut
self
,
br
:
ty
::
BoundR
egion
)
->
Region
{
let
sc
=
self
.skolemization_count
;
self
.skolemization_count
+=
1
;
re_i
nfer
(
ReSkolemized
(
sc
,
br
))
ReI
nfer
(
ReSkolemized
(
sc
,
br
))
}
pub
fn
new_bound
(
&
mut
self
,
binder_id
:
ast
::
NodeId
)
->
Region
{
...
...
@@ -219,7 +219,7 @@ pub fn new_bound(&mut self, binder_id: ast::NodeId) -> Region {
self
.tcx.sess
.bug
(
"Rollover in RegionInference new_bound()"
);
}
re_fn_bound
(
binder_id
,
br_f
resh
(
sc
))
ReLateBound
(
binder_id
,
BrF
resh
(
sc
))
}
pub
fn
add_constraint
(
&
mut
self
,
...
...
@@ -246,23 +246,23 @@ pub fn make_subregion(&mut self,
debug!
(
"RegionVarBindings: make_subregion({:?}, {:?})"
,
sub
,
sup
);
match
(
sub
,
sup
)
{
(
re_type_b
ound
(
*
),
_
)
|
(
re_fn_b
ound
(
*
),
_
)
|
(
_
,
re_type_b
ound
(
*
))
|
(
_
,
re_fn_b
ound
(
*
))
=>
{
(
ReEarlyB
ound
(
*
),
_
)
|
(
ReLateB
ound
(
*
),
_
)
|
(
_
,
ReEarlyB
ound
(
*
))
|
(
_
,
ReLateB
ound
(
*
))
=>
{
self
.tcx.sess
.span_bug
(
origin
.span
(),
format!
(
"Cannot relate bound region: {} <= {}"
,
sub
.repr
(
self
.tcx
),
sup
.repr
(
self
.tcx
)));
}
(
re_infer
(
ReVar
(
sub_id
)),
re_i
nfer
(
ReVar
(
sup_id
)))
=>
{
(
ReInfer
(
ReVar
(
sub_id
)),
ReI
nfer
(
ReVar
(
sup_id
)))
=>
{
self
.add_constraint
(
ConstrainVarSubVar
(
sub_id
,
sup_id
),
origin
);
}
(
r
,
re_i
nfer
(
ReVar
(
sup_id
)))
=>
{
(
r
,
ReI
nfer
(
ReVar
(
sup_id
)))
=>
{
self
.add_constraint
(
ConstrainRegSubVar
(
r
,
sup_id
),
origin
);
}
(
re_i
nfer
(
ReVar
(
sub_id
)),
r
)
=>
{
(
ReI
nfer
(
ReVar
(
sub_id
)),
r
)
=>
{
self
.add_constraint
(
ConstrainVarSubReg
(
sub_id
,
r
),
origin
);
}
_
=>
{
...
...
@@ -281,8 +281,8 @@ pub fn lub_regions(&mut self,
debug!
(
"RegionVarBindings: lub_regions({:?}, {:?})"
,
a
,
b
);
match
(
a
,
b
)
{
(
re_static
,
_
)
|
(
_
,
re_s
tatic
)
=>
{
re_s
tatic
// nothing lives longer than static
(
ReStatic
,
_
)
|
(
_
,
ReS
tatic
)
=>
{
ReS
tatic
// nothing lives longer than static
}
_
=>
{
...
...
@@ -304,7 +304,7 @@ pub fn glb_regions(&mut self,
debug!
(
"RegionVarBindings: glb_regions({:?}, {:?})"
,
a
,
b
);
match
(
a
,
b
)
{
(
re_static
,
r
)
|
(
r
,
re_s
tatic
)
=>
{
(
ReStatic
,
r
)
|
(
r
,
ReS
tatic
)
=>
{
// static lives longer than everything else
r
}
...
...
@@ -333,13 +333,13 @@ pub fn resolve_var(&mut self, rid: RegionVid) -> ty::Region {
Value
(
r
)
=>
r
,
NoValue
=>
{
// No constraints, return ty::
re_e
mpty
re_e
mpty
// No constraints, return ty::
ReE
mpty
ReE
mpty
}
ErrorValue
=>
{
// An error that has previously been reported.
re_s
tatic
ReS
tatic
}
}
}
...
...
@@ -366,7 +366,7 @@ pub fn combine_vars(&mut self,
let
vars
=
TwoRegions
{
a
:
a
,
b
:
b
};
match
self
.combine_map
(
t
)
.find
(
&
vars
)
{
Some
(
&
c
)
=>
{
return
re_i
nfer
(
ReVar
(
c
));
return
ReI
nfer
(
ReVar
(
c
));
}
None
=>
{}
}
...
...
@@ -375,10 +375,10 @@ pub fn combine_vars(&mut self,
if
self
.in_snapshot
()
{
self
.undo_log
.push
(
AddCombination
(
t
,
vars
));
}
relate
(
self
,
a
,
re_i
nfer
(
ReVar
(
c
)));
relate
(
self
,
b
,
re_i
nfer
(
ReVar
(
c
)));
relate
(
self
,
a
,
ReI
nfer
(
ReVar
(
c
)));
relate
(
self
,
b
,
ReI
nfer
(
ReVar
(
c
)));
debug!
(
"combine_vars() c={:?}"
,
c
);
re_i
nfer
(
ReVar
(
c
))
ReI
nfer
(
ReVar
(
c
))
}
pub
fn
vars_created_since_snapshot
(
&
mut
self
,
snapshot
:
uint
)
...
...
@@ -421,14 +421,14 @@ pub fn tainted(&mut self, snapshot: uint, r0: Region) -> ~[Region] {
// nb: can't use uint::range() here as we move result_set
let
regs
=
match
self
.undo_log
[
undo_index
]
{
AddConstraint
(
ConstrainVarSubVar
(
ref
a
,
ref
b
))
=>
{
Some
((
re_i
nfer
(
ReVar
(
*
a
)),
re_i
nfer
(
ReVar
(
*
b
))))
Some
((
ReI
nfer
(
ReVar
(
*
a
)),
ReI
nfer
(
ReVar
(
*
b
))))
}
AddConstraint
(
ConstrainRegSubVar
(
ref
a
,
ref
b
))
=>
{
Some
((
*
a
,
re_i
nfer
(
ReVar
(
*
b
))))
Some
((
*
a
,
ReI
nfer
(
ReVar
(
*
b
))))
}
AddConstraint
(
ConstrainVarSubReg
(
ref
a
,
ref
b
))
=>
{
Some
((
re_i
nfer
(
ReVar
(
*
a
)),
*
b
))
Some
((
ReI
nfer
(
ReVar
(
*
a
)),
*
b
))
}
AddConstraint
(
ConstrainRegSubReg
(
a
,
b
))
=>
{
Some
((
a
,
b
))
...
...
@@ -495,33 +495,33 @@ fn is_subregion_of(&self, sub: Region, sup: Region) -> bool {
fn
lub_concrete_regions
(
&
self
,
a
:
Region
,
b
:
Region
)
->
Region
{
match
(
a
,
b
)
{
(
re_fn_b
ound
(
*
),
_
)
|
(
_
,
re_fn_b
ound
(
*
))
|
(
re_type_b
ound
(
*
),
_
)
|
(
_
,
re_type_b
ound
(
*
))
=>
{
(
ReLateB
ound
(
*
),
_
)
|
(
_
,
ReLateB
ound
(
*
))
|
(
ReEarlyB
ound
(
*
),
_
)
|
(
_
,
ReEarlyB
ound
(
*
))
=>
{
self
.tcx.sess
.bug
(
format!
(
"Cannot relate bound region: LUB({}, {})"
,
a
.repr
(
self
.tcx
),
b
.repr
(
self
.tcx
)));
}
(
re_static
,
_
)
|
(
_
,
re_s
tatic
)
=>
{
re_s
tatic
// nothing lives longer than static
(
ReStatic
,
_
)
|
(
_
,
ReS
tatic
)
=>
{
ReS
tatic
// nothing lives longer than static
}
(
re_empty
,
r
)
|
(
r
,
re_e
mpty
)
=>
{
(
ReEmpty
,
r
)
|
(
r
,
ReE
mpty
)
=>
{
r
// everything lives longer than empty
}
(
re_infer
(
ReVar
(
v_id
)),
_
)
|
(
_
,
re_i
nfer
(
ReVar
(
v_id
)))
=>
{
(
ReInfer
(
ReVar
(
v_id
)),
_
)
|
(
_
,
ReI
nfer
(
ReVar
(
v_id
)))
=>
{
self
.tcx.sess
.span_bug
(
self
.var_origins
[
v_id
.to_uint
()]
.span
(),
format!
(
"lub_concrete_regions invoked with
\
non-concrete regions: {:?}, {:?}"
,
a
,
b
));
}
(
f
@
re_free
(
ref
fr
),
re_s
cope
(
s_id
))
|
(
re_scope
(
s_id
),
f
@
re_f
ree
(
ref
fr
))
=>
{
(
f
@
ReFree
(
ref
fr
),
ReS
cope
(
s_id
))
|
(
ReScope
(
s_id
),
f
@
ReF
ree
(
ref
fr
))
=>
{
// A "free" region can be interpreted as "some region
// at least as big as the block fr.scope_id". So, we can
// reasonably compare free regions and scopes:
...
...
@@ -534,30 +534,30 @@ fn lub_concrete_regions(&self, a: Region, b: Region) -> Region {
// otherwise, we don't know what the free region is,
// so we must conservatively say the LUB is static:
_
=>
re_s
tatic
_
=>
ReS
tatic
}
}
(
re_scope
(
a_id
),
re_s
cope
(
b_id
))
=>
{
(
ReScope
(
a_id
),
ReS
cope
(
b_id
))
=>
{
// The region corresponding to an outer block is a
// subtype of the region corresponding to an inner
// block.
let
rm
=
self
.tcx.region_maps
;
match
rm
.nearest_common_ancestor
(
a_id
,
b_id
)
{
Some
(
r_id
)
=>
re_s
cope
(
r_id
),
_
=>
re_s
tatic
Some
(
r_id
)
=>
ReS
cope
(
r_id
),
_
=>
ReS
tatic
}
}
(
re_free
(
ref
a_fr
),
re_f
ree
(
ref
b_fr
))
=>
{
(
ReFree
(
ref
a_fr
),
ReF
ree
(
ref
b_fr
))
=>
{
self
.lub_free_regions
(
a_fr
,
b_fr
)
}
// For these types, we cannot define any additional
// relationship:
(
re_i
nfer
(
ReSkolemized
(
*
)),
_
)
|
(
_
,
re_i
nfer
(
ReSkolemized
(
*
)))
=>
{
if
a
==
b
{
a
}
else
{
re_s
tatic
}
(
ReI
nfer
(
ReSkolemized
(
*
)),
_
)
|
(
_
,
ReI
nfer
(
ReSkolemized
(
*
)))
=>
{
if
a
==
b
{
a
}
else
{
ReS
tatic
}
}
}
}
...
...
@@ -575,7 +575,7 @@ fn lub_free_regions(&self,
return
match
a
.cmp
(
b
)
{
Less
=>
helper
(
self
,
a
,
b
),
Greater
=>
helper
(
self
,
b
,
a
),
Equal
=>
ty
::
re_f
ree
(
*
a
)
Equal
=>
ty
::
ReF
ree
(
*
a
)
};
fn
helper
(
this
:
&
RegionVarBindings
,
...
...
@@ -584,11 +584,11 @@ fn helper(this: &RegionVarBindings,
{
let
rm
=
this
.tcx.region_maps
;
if
rm
.sub_free_region
(
*
a
,
*
b
)
{
ty
::
re_f
ree
(
*
b
)
ty
::
ReF
ree
(
*
b
)
}
else
if
rm
.sub_free_region
(
*
b
,
*
a
)
{
ty
::
re_f
ree
(
*
a
)
ty
::
ReF
ree
(
*
a
)
}
else
{
ty
::
re_s
tatic
ty
::
ReS
tatic
}
}
}
...
...
@@ -599,36 +599,36 @@ fn glb_concrete_regions(&self,
->
cres
<
Region
>
{
debug!
(
"glb_concrete_regions({:?}, {:?})"
,
a
,
b
);
match
(
a
,
b
)
{
(
re_fn_b
ound
(
*
),
_
)
|
(
_
,
re_fn_b
ound
(
*
))
|
(
re_type_b
ound
(
*
),
_
)
|
(
_
,
re_type_b
ound
(
*
))
=>
{
(
ReLateB
ound
(
*
),
_
)
|
(
_
,
ReLateB
ound
(
*
))
|
(
ReEarlyB
ound
(
*
),
_
)
|
(
_
,
ReEarlyB
ound
(
*
))
=>
{
self
.tcx.sess
.bug
(
format!
(
"Cannot relate bound region: GLB({}, {})"
,
a
.repr
(
self
.tcx
),
b
.repr
(
self
.tcx
)));
}
(
re_static
,
r
)
|
(
r
,
re_s
tatic
)
=>
{
(
ReStatic
,
r
)
|
(
r
,
ReS
tatic
)
=>
{
// static lives longer than everything else
Ok
(
r
)
}
(
re_empty
,
_
)
|
(
_
,
re_e
mpty
)
=>
{
(
ReEmpty
,
_
)
|
(
_
,
ReE
mpty
)
=>
{
// nothing lives shorter than everything else
Ok
(
re_e
mpty
)
Ok
(
ReE
mpty
)
}
(
re_i
nfer
(
ReVar
(
v_id
)),
_
)
|
(
_
,
re_i
nfer
(
ReVar
(
v_id
)))
=>
{
(
ReI
nfer
(
ReVar
(
v_id
)),
_
)
|
(
_
,
ReI
nfer
(
ReVar
(
v_id
)))
=>
{
self
.tcx.sess
.span_bug
(
self
.var_origins
[
v_id
.to_uint
()]
.span
(),
format!
(
"glb_concrete_regions invoked with
\
non-concrete regions: {:?}, {:?}"
,
a
,
b
));
}
(
re_free
(
ref
fr
),
s
@
re_s
cope
(
s_id
))
|
(
s
@
re_scope
(
s_id
),
re_f
ree
(
ref
fr
))
=>
{
(
ReFree
(
ref
fr
),
s
@
ReS
cope
(
s_id
))
|
(
s
@
ReScope
(
s_id
),
ReF
ree
(
ref
fr
))
=>
{
// Free region is something "at least as big as
// `fr.scope_id`." If we find that the scope `fr.scope_id` is bigger
// than the scope `s_id`, then we can say that the GLB
...
...
@@ -641,18 +641,18 @@ fn glb_concrete_regions(&self,
}
}
(
re_scope
(
a_id
),
re_s
cope
(
b_id
))
=>
{
(
ReScope
(
a_id
),
ReS
cope
(
b_id
))
=>
{
self
.intersect_scopes
(
a
,
b
,
a_id
,
b_id
)
}
(
re_free
(
ref
a_fr
),
re_f
ree
(
ref
b_fr
))
=>
{
(
ReFree
(
ref
a_fr
),
ReF
ree
(
ref
b_fr
))
=>
{
self
.glb_free_regions
(
a_fr
,
b_fr
)
}
// For these types, we cannot define any additional
// relationship:
(
re_i
nfer
(
ReSkolemized
(
*
)),
_
)
|
(
_
,
re_i
nfer
(
ReSkolemized
(
*
)))
=>
{
(
ReI
nfer
(
ReSkolemized
(
*
)),
_
)
|
(
_
,
ReI
nfer
(
ReSkolemized
(
*
)))
=>
{
if
a
==
b
{
Ok
(
a
)
}
else
{
...
...
@@ -675,7 +675,7 @@ fn glb_free_regions(&self,
return
match
a
.cmp
(
b
)
{
Less
=>
helper
(
self
,
a
,
b
),
Greater
=>
helper
(
self
,
b
,
a
),
Equal
=>
Ok
(
ty
::
re_f
ree
(
*
a
))
Equal
=>
Ok
(
ty
::
ReF
ree
(
*
a
))
};
fn
helper
(
this
:
&
RegionVarBindings
,
...
...
@@ -684,11 +684,11 @@ fn helper(this: &RegionVarBindings,
{
let
rm
=
this
.tcx.region_maps
;
if
rm
.sub_free_region
(
*
a
,
*
b
)
{
Ok
(
ty
::
re_f
ree
(
*
a
))
Ok
(
ty
::
ReF
ree
(
*
a
))
}
else
if
rm
.sub_free_region
(
*
b
,
*
a
)
{
Ok
(
ty
::
re_f
ree
(
*
b
))
Ok
(
ty
::
ReF
ree
(
*
b
))
}
else
{
this
.intersect_scopes
(
ty
::
re_free
(
*
a
),
ty
::
re_f
ree
(
*
b
),
this
.intersect_scopes
(
ty
::
ReFree
(
*
a
),
ty
::
ReF
ree
(
*
b
),
a
.scope_id
,
b
.scope_id
)
}
}
...
...
@@ -715,8 +715,8 @@ fn intersect_scopes(&self,
scope_a
,
scope_b
,
region_a
,
region_b
);
let
rm
=
self
.tcx.region_maps
;
match
rm
.nearest_common_ancestor
(
scope_a
,
scope_b
)
{
Some
(
r_id
)
if
scope_a
==
r_id
=>
Ok
(
re_s
cope
(
scope_b
)),
Some
(
r_id
)
if
scope_b
==
r_id
=>
Ok
(
re_s
cope
(
scope_a
)),
Some
(
r_id
)
if
scope_a
==
r_id
=>
Ok
(
ReS
cope
(
scope_b
)),
Some
(
r_id
)
if
scope_b
==
r_id
=>
Ok
(
ReS
cope
(
scope_a
)),
_
=>
Err
(
ty
::
terr_regions_no_overlap
(
region_a
,
region_b
))
}
}
...
...
src/librustc/middle/typeck/infer/resolve.rs
浏览文件 @
195f1d77
...
...
@@ -192,21 +192,21 @@ pub fn resolve_type(&mut self, typ: ty::t) -> ty::t {
pub
fn
resolve_region
(
&
mut
self
,
orig
:
ty
::
Region
)
->
ty
::
Region
{
debug!
(
"Resolve_region({})"
,
orig
.inf_str
(
self
.infcx
));
match
orig
{
ty
::
re_i
nfer
(
ty
::
ReVar
(
rid
))
=>
self
.resolve_region_var
(
rid
),
ty
::
ReI
nfer
(
ty
::
ReVar
(
rid
))
=>
self
.resolve_region_var
(
rid
),
_
=>
orig
}
}
pub
fn
resolve_region_var
(
&
mut
self
,
rid
:
RegionVid
)
->
ty
::
Region
{
if
!
self
.should
(
resolve_rvar
)
{
return
ty
::
re_i
nfer
(
ty
::
ReVar
(
rid
));
return
ty
::
ReI
nfer
(
ty
::
ReVar
(
rid
));
}
self
.infcx.region_vars
.resolve_var
(
rid
)
}
pub
fn
assert_not_rvar
(
&
mut
self
,
rid
:
RegionVid
,
r
:
ty
::
Region
)
{
match
r
{
ty
::
re_i
nfer
(
ty
::
ReVar
(
rid2
))
=>
{
ty
::
ReI
nfer
(
ty
::
ReVar
(
rid2
))
=>
{
self
.err
=
Some
(
region_var_bound_by_region_var
(
rid
,
rid2
));
}
_
=>
{
}
...
...
src/librustc/middle/typeck/infer/sub.rs
浏览文件 @
195f1d77
...
...
@@ -192,7 +192,7 @@ fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
// Each skolemized should only be relatable to itself
// or new variables:
match
*
tainted_region
{
ty
::
re_i
nfer
(
ty
::
ReVar
(
ref
vid
))
=>
{
ty
::
ReI
nfer
(
ty
::
ReVar
(
ref
vid
))
=>
{
if
new_vars
.iter
()
.any
(|
x
|
x
==
vid
)
{
continue
;
}
}
_
=>
{
...
...
src/librustc/middle/typeck/infer/test.rs
浏览文件 @
195f1d77
...
...
@@ -188,7 +188,7 @@ pub fn t_fn(&self, input_tys: &[ty::t], output_ty: ty::t) -> ty::t {
meta
:
FnMeta
{
purity
:
ast
::
impure_fn
,
proto
:
ast
::
ProtoBare
,
onceness
:
ast
::
Many
,
region
:
ty
::
re_s
tatic
,
region
:
ty
::
ReS
tatic
,
bounds
:
@~
[]},
sig
:
FnSig
{
inputs
:
inputs
,
...
...
@@ -203,22 +203,22 @@ pub fn t_int(&self) -> ty::t {
}
pub
fn
t_rptr_bound
(
&
self
,
id
:
uint
)
->
ty
::
t
{
ty
::
mk_imm_rptr
(
self
.tcx
,
ty
::
re_bound
(
ty
::
br_a
non
(
id
)),
self
.t_int
())
ty
::
mk_imm_rptr
(
self
.tcx
,
ty
::
re_bound
(
ty
::
BrA
non
(
id
)),
self
.t_int
())
}
pub
fn
t_rptr_scope
(
&
self
,
id
:
ast
::
node_id
)
->
ty
::
t
{
ty
::
mk_imm_rptr
(
self
.tcx
,
ty
::
re_s
cope
(
id
),
self
.t_int
())
ty
::
mk_imm_rptr
(
self
.tcx
,
ty
::
ReS
cope
(
id
),
self
.t_int
())
}
pub
fn
t_rptr_free
(
&
self
,
nid
:
ast
::
node_id
,
id
:
uint
)
->
ty
::
t
{
ty
::
mk_imm_rptr
(
self
.tcx
,
ty
::
re_f
ree
(
ty
::
FreeRegion
{
scope_id
:
nid
,
bound_region
:
ty
::
br_a
non
(
id
)}),
ty
::
ReF
ree
(
ty
::
FreeRegion
{
scope_id
:
nid
,
bound_region
:
ty
::
BrA
non
(
id
)}),
self
.t_int
())
}
pub
fn
t_rptr_static
(
&
self
)
->
ty
::
t
{
ty
::
mk_imm_rptr
(
self
.tcx
,
ty
::
re_s
tatic
,
self
.t_int
())
ty
::
mk_imm_rptr
(
self
.tcx
,
ty
::
ReS
tatic
,
self
.t_int
())
}
pub
fn
lub
()
->
Lub
{
Lub
(
self
.infcx
.combine_fields
(
true
,
dummy_sp
()))
}
...
...
src/librustc/middle/typeck/mod.rs
浏览文件 @
195f1d77
...
...
@@ -317,19 +317,19 @@ pub fn require_same_types(
// a list of mapping from in-scope-region-names ("isr") to the
// corresponding ty::Region
pub
type
isr_alist
=
@
List
<
(
ty
::
bound_r
egion
,
ty
::
Region
)
>
;
pub
type
isr_alist
=
@
List
<
(
ty
::
BoundR
egion
,
ty
::
Region
)
>
;
trait
get_and_find_region
{
fn
get
(
&
self
,
br
:
ty
::
bound_r
egion
)
->
ty
::
Region
;
fn
find
(
&
self
,
br
:
ty
::
bound_r
egion
)
->
Option
<
ty
::
Region
>
;
fn
get
(
&
self
,
br
:
ty
::
BoundR
egion
)
->
ty
::
Region
;
fn
find
(
&
self
,
br
:
ty
::
BoundR
egion
)
->
Option
<
ty
::
Region
>
;
}
impl
get_and_find_region
for
isr_alist
{
fn
get
(
&
self
,
br
:
ty
::
bound_r
egion
)
->
ty
::
Region
{
fn
get
(
&
self
,
br
:
ty
::
BoundR
egion
)
->
ty
::
Region
{
self
.find
(
br
)
.unwrap
()
}
fn
find
(
&
self
,
br
:
ty
::
bound_r
egion
)
->
Option
<
ty
::
Region
>
{
fn
find
(
&
self
,
br
:
ty
::
BoundR
egion
)
->
Option
<
ty
::
Region
>
{
let
mut
ret
=
None
;
do
list
::
each
(
*
self
)
|
isr
|
{
let
(
isr_br
,
isr_r
)
=
*
isr
;
...
...
src/librustc/middle/typeck/rscope.rs
浏览文件 @
195f1d77
...
...
@@ -56,8 +56,8 @@ fn anon_regions(&self,
->
Option
<~
[
ty
::
Region
]
>
{
let
idx
=
*
self
.anon_bindings
;
*
self
.anon_bindings
+=
count
;
Some
(
vec
::
from_fn
(
count
,
|
i
|
ty
::
re_fn_b
ound
(
self
.binder_id
,
ty
::
br_a
non
(
idx
+
i
))))
Some
(
vec
::
from_fn
(
count
,
|
i
|
ty
::
ReLateB
ound
(
self
.binder_id
,
ty
::
BrA
non
(
idx
+
i
))))
}
}
...
...
@@ -65,5 +65,5 @@ pub fn bound_type_regions(defs: &[ty::RegionParameterDef])
->
OptVec
<
ty
::
Region
>
{
assert
!
(
defs
.iter
()
.all
(|
def
|
def
.def_id.crate
==
ast
::
LOCAL_CRATE
));
defs
.iter
()
.enumerate
()
.map
(
|(
i
,
def
)|
ty
::
re_type_b
ound
(
def
.def_id.node
,
i
,
def
.ident
))
.collect
()
|(
i
,
def
)|
ty
::
ReEarlyB
ound
(
def
.def_id.node
,
i
,
def
.ident
))
.collect
()
}
src/librustc/middle/typeck/variance.rs
浏览文件 @
195f1d77
...
...
@@ -613,20 +613,20 @@ fn add_constraints_from_region(&mut self,
region
:
ty
::
Region
,
variance
:
VarianceTermPtr
<
'self
>
)
{
match
region
{
ty
::
re_type_b
ound
(
param_id
,
_
,
_
)
=>
{
ty
::
ReEarlyB
ound
(
param_id
,
_
,
_
)
=>
{
let
index
=
self
.inferred_index
(
param_id
);
self
.add_constraint
(
index
,
variance
);
}
ty
::
re_s
tatic
=>
{
}
ty
::
ReS
tatic
=>
{
}
ty
::
re_fn_b
ound
(
*
)
=>
{
ty
::
ReLateB
ound
(
*
)
=>
{
// We do not infer variance for region parameters on
// methods or in fn types.
}
ty
::
re_free
(
*
)
|
ty
::
re_scope
(
*
)
|
ty
::
re_i
nfer
(
*
)
|
ty
::
re_e
mpty
=>
{
ty
::
ReFree
(
*
)
|
ty
::
ReScope
(
*
)
|
ty
::
ReI
nfer
(
*
)
|
ty
::
ReE
mpty
=>
{
// We don't expect to see anything but 'static or bound
// regions when visiting member types or method types.
self
.tcx
()
.sess
.bug
(
format!
(
"Unexpected region encountered in
\
...
...
src/librustc/util/ppaux.rs
浏览文件 @
195f1d77
...
...
@@ -11,11 +11,11 @@
use
metadata
::
encoder
;
use
middle
::
ty
::{
ReSkolemized
,
ReVar
};
use
middle
::
ty
::{
bound_region
,
br_anon
,
br_n
amed
};
use
middle
::
ty
::{
br_f
resh
,
ctxt
,
field
};
use
middle
::
ty
::{
BoundRegion
,
BrAnon
,
BrN
amed
};
use
middle
::
ty
::{
BrF
resh
,
ctxt
,
field
};
use
middle
::
ty
::{
mt
,
t
,
param_ty
};
use
middle
::
ty
::{
re_free
,
re_scope
,
re_infer
,
re_s
tatic
,
Region
,
re_e
mpty
};
use
middle
::
ty
::{
ReFree
,
ReScope
,
ReInfer
,
ReS
tatic
,
Region
,
ReE
mpty
};
use
middle
::
ty
::{
ty_bool
,
ty_char
,
ty_bot
,
ty_box
,
ty_struct
,
ty_enum
};
use
middle
::
ty
::{
ty_err
,
ty_estr
,
ty_evec
,
ty_float
,
ty_bare_fn
,
ty_closure
};
use
middle
::
ty
::{
ty_nil
,
ty_opaque_box
,
ty_opaque_closure_ptr
,
ty_param
};
...
...
@@ -71,7 +71,7 @@ pub fn explain_region(cx: ctxt, region: ty::Region) -> ~str {
pub
fn
explain_region_and_span
(
cx
:
ctxt
,
region
:
ty
::
Region
)
->
(
~
str
,
Option
<
Span
>
)
{
return
match
region
{
re_s
cope
(
node_id
)
=>
{
ReS
cope
(
node_id
)
=>
{
match
cx
.items
.find
(
&
node_id
)
{
Some
(
&
ast_map
::
node_block
(
ref
blk
))
=>
{
explain_span
(
cx
,
"block"
,
blk
.span
)
...
...
@@ -104,11 +104,11 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
}
}
re_f
ree
(
ref
fr
)
=>
{
ReF
ree
(
ref
fr
)
=>
{
let
prefix
=
match
fr
.bound_region
{
br_a
non
(
idx
)
=>
format!
(
"the anonymous lifetime
\\
#{} defined on"
,
BrA
non
(
idx
)
=>
format!
(
"the anonymous lifetime
\\
#{} defined on"
,
idx
+
1
),
br_f
resh
(
_
)
=>
format!
(
"an anonymous lifetime defined on"
),
BrF
resh
(
_
)
=>
format!
(
"an anonymous lifetime defined on"
),
_
=>
format!
(
"the lifetime {} as defined on"
,
bound_region_ptr_to_str
(
cx
,
fr
.bound_region
))
};
...
...
@@ -130,13 +130,13 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
}
}
re_s
tatic
=>
{
(
~
"the static lifetime"
,
None
)
}
ReS
tatic
=>
{
(
~
"the static lifetime"
,
None
)
}
re_e
mpty
=>
{
(
~
"the empty lifetime"
,
None
)
}
ReE
mpty
=>
{
(
~
"the empty lifetime"
,
None
)
}
// I believe these cases should not occur (except when debugging,
// perhaps)
ty
::
re_infer
(
_
)
|
ty
::
re_type_bound
(
*
)
|
ty
::
re_fn_b
ound
(
*
)
=>
{
ty
::
ReInfer
(
_
)
|
ty
::
ReEarlyBound
(
*
)
|
ty
::
ReLateB
ound
(
*
)
=>
{
(
format!
(
"lifetime {:?}"
,
region
),
None
)
}
};
...
...
@@ -150,13 +150,13 @@ fn explain_span(cx: ctxt, heading: &str, span: Span)
}
}
pub
fn
bound_region_ptr_to_str
(
cx
:
ctxt
,
br
:
bound_r
egion
)
->
~
str
{
pub
fn
bound_region_ptr_to_str
(
cx
:
ctxt
,
br
:
BoundR
egion
)
->
~
str
{
bound_region_to_str
(
cx
,
"&"
,
true
,
br
)
}
pub
fn
bound_region_to_str
(
cx
:
ctxt
,
prefix
:
&
str
,
space
:
bool
,
br
:
bound_r
egion
)
->
~
str
{
br
:
BoundR
egion
)
->
~
str
{
let
space_str
=
if
space
{
" "
}
else
{
""
};
if
cx
.sess
.verbose
()
{
...
...
@@ -164,14 +164,14 @@ pub fn bound_region_to_str(cx: ctxt,
}
match
br
{
br_n
amed
(
_
,
ident
)
=>
format!
(
"{}'{}{}"
,
prefix
,
BrN
amed
(
_
,
ident
)
=>
format!
(
"{}'{}{}"
,
prefix
,
cx
.sess
.str_of
(
ident
),
space_str
),
br_a
non
(
_
)
=>
prefix
.to_str
(),
br_f
resh
(
_
)
=>
prefix
.to_str
(),
BrA
non
(
_
)
=>
prefix
.to_str
(),
BrF
resh
(
_
)
=>
prefix
.to_str
(),
}
}
pub
fn
re_s
cope_id_to_str
(
cx
:
ctxt
,
node_id
:
ast
::
NodeId
)
->
~
str
{
pub
fn
ReS
cope_id_to_str
(
cx
:
ctxt
,
node_id
:
ast
::
NodeId
)
->
~
str
{
match
cx
.items
.find
(
&
node_id
)
{
Some
(
&
ast_map
::
node_block
(
ref
blk
))
=>
{
format!
(
"<block at {}>"
,
...
...
@@ -204,7 +204,7 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::NodeId) -> ~str {
format!
(
"<unknown-{}>"
,
node_id
)
}
_
=>
{
cx
.sess
.bug
(
format!
(
"
re_s
cope refers to {}"
,
format!
(
"
ReS
cope refers to {}"
,
ast_map
::
node_id_to_str
(
cx
.items
,
node_id
,
token
::
get_ident_interner
())))
}
}
...
...
@@ -229,16 +229,16 @@ pub fn region_to_str(cx: ctxt, prefix: &str, space: bool, region: Region) -> ~st
// to fit that into a short string. Hence the recommendation to use
// `explain_region()` or `note_and_explain_region()`.
match
region
{
ty
::
re_s
cope
(
_
)
=>
prefix
.to_str
(),
ty
::
re_type_b
ound
(
_
,
_
,
ident
)
=>
cx
.sess
.str_of
(
ident
)
.to_owned
(),
ty
::
re_fn_b
ound
(
_
,
br
)
=>
bound_region_to_str
(
cx
,
prefix
,
space
,
br
),
ty
::
re_f
ree
(
ref
fr
)
=>
bound_region_to_str
(
cx
,
prefix
,
space
,
fr
.bound_region
),
ty
::
re_i
nfer
(
ReSkolemized
(
_
,
br
))
=>
{
ty
::
ReS
cope
(
_
)
=>
prefix
.to_str
(),
ty
::
ReEarlyB
ound
(
_
,
_
,
ident
)
=>
cx
.sess
.str_of
(
ident
)
.to_owned
(),
ty
::
ReLateB
ound
(
_
,
br
)
=>
bound_region_to_str
(
cx
,
prefix
,
space
,
br
),
ty
::
ReF
ree
(
ref
fr
)
=>
bound_region_to_str
(
cx
,
prefix
,
space
,
fr
.bound_region
),
ty
::
ReI
nfer
(
ReSkolemized
(
_
,
br
))
=>
{
bound_region_to_str
(
cx
,
prefix
,
space
,
br
)
}
ty
::
re_i
nfer
(
ReVar
(
_
))
=>
prefix
.to_str
(),
ty
::
re_s
tatic
=>
format!
(
"{}'static{}"
,
prefix
,
space_str
),
ty
::
re_e
mpty
=>
format!
(
"{}'<empty>{}"
,
prefix
,
space_str
)
ty
::
ReI
nfer
(
ReVar
(
_
))
=>
prefix
.to_str
(),
ty
::
ReS
tatic
=>
format!
(
"{}'static{}"
,
prefix
,
space_str
),
ty
::
ReE
mpty
=>
format!
(
"{}'<empty>{}"
,
prefix
,
space_str
)
}
}
...
...
@@ -356,8 +356,8 @@ fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str {
};
match
(
cty
.sigil
,
cty
.region
)
{
(
ast
::
ManagedSigil
,
ty
::
re_s
tatic
)
|
(
ast
::
OwnedSigil
,
ty
::
re_s
tatic
)
=>
{}
(
ast
::
ManagedSigil
,
ty
::
ReS
tatic
)
|
(
ast
::
OwnedSigil
,
ty
::
ReS
tatic
)
=>
{}
(
_
,
region
)
=>
{
s
.push_str
(
region_to_str
(
cx
,
""
,
true
,
region
));
...
...
@@ -689,14 +689,14 @@ fn repr(&self, tcx: ctxt) -> ~str {
}
}
impl
Repr
for
ty
::
bound_r
egion
{
impl
Repr
for
ty
::
BoundR
egion
{
fn
repr
(
&
self
,
tcx
:
ctxt
)
->
~
str
{
match
*
self
{
ty
::
br_anon
(
id
)
=>
format!
(
"br_a
non({})"
,
id
),
ty
::
br_named
(
id
,
ident
)
=>
format!
(
"br_n
amed({}, {})"
,
ty
::
BrAnon
(
id
)
=>
format!
(
"BrA
non({})"
,
id
),
ty
::
BrNamed
(
id
,
ident
)
=>
format!
(
"BrN
amed({}, {})"
,
id
.repr
(
tcx
),
ident
.repr
(
tcx
)),
ty
::
br_fresh
(
id
)
=>
format!
(
"br_f
resh({})"
,
id
),
ty
::
BrFresh
(
id
)
=>
format!
(
"BrF
resh({})"
,
id
),
}
}
}
...
...
@@ -704,41 +704,41 @@ fn repr(&self, tcx: ctxt) -> ~str {
impl
Repr
for
ty
::
Region
{
fn
repr
(
&
self
,
tcx
:
ctxt
)
->
~
str
{
match
*
self
{
ty
::
re_type_b
ound
(
id
,
index
,
ident
)
=>
{
format!
(
"
re_type_b
ound({}, {}, {})"
,
ty
::
ReEarlyB
ound
(
id
,
index
,
ident
)
=>
{
format!
(
"
ReEarlyB
ound({}, {}, {})"
,
id
,
index
,
ident
.repr
(
tcx
))
}
ty
::
re_fn_b
ound
(
binder_id
,
ref
bound_region
)
=>
{
format!
(
"
re_fn_b
ound({}, {})"
,
ty
::
ReLateB
ound
(
binder_id
,
ref
bound_region
)
=>
{
format!
(
"
ReLateB
ound({}, {})"
,
binder_id
,
bound_region
.repr
(
tcx
))
}
ty
::
re_f
ree
(
ref
fr
)
=>
{
format!
(
"
re_f
ree({}, {})"
,
ty
::
ReF
ree
(
ref
fr
)
=>
{
format!
(
"
ReF
ree({}, {})"
,
fr
.scope_id
,
fr
.bound_region
.repr
(
tcx
))
}
ty
::
re_s
cope
(
id
)
=>
{
format!
(
"
re_s
cope({})"
,
id
)
ty
::
ReS
cope
(
id
)
=>
{
format!
(
"
ReS
cope({})"
,
id
)
}
ty
::
re_s
tatic
=>
{
format!
(
"
re_s
tatic"
)
ty
::
ReS
tatic
=>
{
format!
(
"
ReS
tatic"
)
}
ty
::
re_i
nfer
(
ReVar
(
ref
vid
))
=>
{
format!
(
"
re_i
nfer({})"
,
vid
.id
)
ty
::
ReI
nfer
(
ReVar
(
ref
vid
))
=>
{
format!
(
"
ReI
nfer({})"
,
vid
.id
)
}
ty
::
re_i
nfer
(
ReSkolemized
(
id
,
ref
bound_region
))
=>
{
ty
::
ReI
nfer
(
ReSkolemized
(
id
,
ref
bound_region
))
=>
{
format!
(
"re_skolemized({}, {})"
,
id
,
bound_region
.repr
(
tcx
))
}
ty
::
re_e
mpty
=>
{
format!
(
"
re_e
mpty"
)
ty
::
ReE
mpty
=>
{
format!
(
"
ReE
mpty"
)
}
}
}
...
...
src/libsyntax/ast.rs
浏览文件 @
195f1d77
...
...
@@ -254,8 +254,8 @@ pub enum Def {
#[deriving(Clone,
Eq,
IterBytes,
Encodable,
Decodable,
ToStr)]
pub
enum
DefRegion
{
DefStaticRegion
,
Def
Type
BoundRegion
(
/* index */
uint
,
/* lifetime decl */
NodeId
),
Def
Fn
BoundRegion
(
/* binder_id */
NodeId
,
/* depth */
uint
,
/* lifetime decl */
NodeId
),
Def
Early
BoundRegion
(
/* index */
uint
,
/* lifetime decl */
NodeId
),
Def
Late
BoundRegion
(
/* binder_id */
NodeId
,
/* depth */
uint
,
/* lifetime decl */
NodeId
),
DefFreeRegion
(
/* block scope */
NodeId
,
/* lifetime decl */
NodeId
),
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录