Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
bcec7a58
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,发现更多精彩内容 >>
提交
bcec7a58
编写于
6月 01, 2016
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: add ReErased to be used by trait selection, MIR and trans.
上级
f97c4115
变更
28
隐藏空白更改
内联
并排
Showing
28 changed file
with
92 addition
and
71 deletion
+92
-71
src/librustc/infer/combine.rs
src/librustc/infer/combine.rs
+4
-2
src/librustc/infer/error_reporting.rs
src/librustc/infer/error_reporting.rs
+4
-1
src/librustc/infer/freshen.rs
src/librustc/infer/freshen.rs
+5
-4
src/librustc/infer/region_inference/mod.rs
src/librustc/infer/region_inference/mod.rs
+5
-3
src/librustc/ty/flags.rs
src/librustc/ty/flags.rs
+1
-1
src/librustc/ty/fold.rs
src/librustc/ty/fold.rs
+6
-6
src/librustc/ty/sty.rs
src/librustc/ty/sty.rs
+3
-0
src/librustc/ty/subst.rs
src/librustc/ty/subst.rs
+1
-1
src/librustc/ty/util.rs
src/librustc/ty/util.rs
+1
-1
src/librustc/util/ppaux.rs
src/librustc/util/ppaux.rs
+31
-23
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_borrowck/borrowck/gather_loans/mod.rs
+2
-1
src/librustc_metadata/tydecode.rs
src/librustc_metadata/tydecode.rs
+3
-6
src/librustc_metadata/tyencode.rs
src/librustc_metadata/tyencode.rs
+3
-0
src/librustc_trans/_match.rs
src/librustc_trans/_match.rs
+1
-1
src/librustc_trans/callee.rs
src/librustc_trans/callee.rs
+1
-1
src/librustc_trans/closure.rs
src/librustc_trans/closure.rs
+3
-3
src/librustc_trans/consts.rs
src/librustc_trans/consts.rs
+1
-1
src/librustc_trans/context.rs
src/librustc_trans/context.rs
+1
-1
src/librustc_trans/expr.rs
src/librustc_trans/expr.rs
+1
-1
src/librustc_trans/meth.rs
src/librustc_trans/meth.rs
+1
-1
src/librustc_trans/mir/constant.rs
src/librustc_trans/mir/constant.rs
+1
-1
src/librustc_trans/mir/rvalue.rs
src/librustc_trans/mir/rvalue.rs
+1
-1
src/librustc_trans/monomorphize.rs
src/librustc_trans/monomorphize.rs
+1
-1
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/probe.rs
+3
-3
src/librustc_typeck/variance/constraints.rs
src/librustc_typeck/variance/constraints.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+2
-1
src/test/compile-fail/non-interger-atomic.rs
src/test/compile-fail/non-interger-atomic.rs
+4
-4
src/test/run-pass/issue-21058.rs
src/test/run-pass/issue-21058.rs
+1
-1
未找到文件。
src/librustc/infer/combine.rs
浏览文件 @
bcec7a58
...
@@ -337,8 +337,10 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
...
@@ -337,8 +337,10 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
fn
fold_region
(
&
mut
self
,
r
:
ty
::
Region
)
->
ty
::
Region
{
fn
fold_region
(
&
mut
self
,
r
:
ty
::
Region
)
->
ty
::
Region
{
match
r
{
match
r
{
// Never make variables for regions bound within the type itself.
// Never make variables for regions bound within the type itself,
ty
::
ReLateBound
(
..
)
=>
{
return
r
;
}
// nor for erased regions.
ty
::
ReLateBound
(
..
)
|
ty
::
ReErased
=>
{
return
r
;
}
// Early-bound regions should really have been substituted away before
// Early-bound regions should really have been substituted away before
// we get to this point.
// we get to this point.
...
...
src/librustc/infer/error_reporting.rs
浏览文件 @
bcec7a58
...
@@ -216,7 +216,10 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
...
@@ -216,7 +216,10 @@ fn explain_span<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
//
//
// We shouldn't really be having unification failures with ReVar
// We shouldn't really be having unification failures with ReVar
// and ReLateBound though.
// and ReLateBound though.
ty
::
ReSkolemized
(
..
)
|
ty
::
ReVar
(
_
)
|
ty
::
ReLateBound
(
..
)
=>
{
ty
::
ReSkolemized
(
..
)
|
ty
::
ReVar
(
_
)
|
ty
::
ReLateBound
(
..
)
|
ty
::
ReErased
=>
{
(
format!
(
"lifetime {:?}"
,
region
),
None
)
(
format!
(
"lifetime {:?}"
,
region
),
None
)
}
}
};
};
...
...
src/librustc/infer/freshen.rs
浏览文件 @
bcec7a58
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
//! error messages or in any other form. Freshening is only really useful as an internal detail.
//! error messages or in any other form. Freshening is only really useful as an internal detail.
//!
//!
//! __An important detail concerning regions.__ The freshener also replaces *all* regions with
//! __An important detail concerning regions.__ The freshener also replaces *all* regions with
//! '
static
. The reason behind this is that, in general, we do not take region relationships into
//! '
erased
. The reason behind this is that, in general, we do not take region relationships into
//! account when making type-overloaded decisions. This is important because of the design of the
//! account when making type-overloaded decisions. This is important because of the design of the
//! region inferencer, which is not based on unification but rather on accumulating and then
//! region inferencer, which is not based on unification but rather on accumulating and then
//! solving a set of constraints. In contrast, the type inferencer assigns a value to each type
//! solving a set of constraints. In contrast, the type inferencer assigns a value to each type
...
@@ -96,9 +96,10 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
...
@@ -96,9 +96,10 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
ty
::
ReScope
(
_
)
|
ty
::
ReScope
(
_
)
|
ty
::
ReVar
(
_
)
|
ty
::
ReVar
(
_
)
|
ty
::
ReSkolemized
(
..
)
|
ty
::
ReSkolemized
(
..
)
|
ty
::
ReEmpty
=>
{
ty
::
ReEmpty
|
// replace all free regions with 'static
ty
::
ReErased
=>
{
ty
::
ReStatic
// replace all free regions with 'erased
ty
::
ReErased
}
}
}
}
}
}
...
...
src/librustc/infer/region_inference/mod.rs
浏览文件 @
bcec7a58
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
use
middle
::
free_region
::
FreeRegionMap
;
use
middle
::
free_region
::
FreeRegionMap
;
use
ty
::{
self
,
Ty
,
TyCtxt
};
use
ty
::{
self
,
Ty
,
TyCtxt
};
use
ty
::{
BoundRegion
,
Region
,
RegionVid
};
use
ty
::{
BoundRegion
,
Region
,
RegionVid
};
use
ty
::{
ReEmpty
,
ReStatic
,
ReFree
,
ReEarlyBound
};
use
ty
::{
ReEmpty
,
ReStatic
,
ReFree
,
ReEarlyBound
,
ReErased
};
use
ty
::{
ReLateBound
,
ReScope
,
ReVar
,
ReSkolemized
,
BrFresh
};
use
ty
::{
ReLateBound
,
ReScope
,
ReVar
,
ReSkolemized
,
BrFresh
};
use
std
::
cell
::{
Cell
,
RefCell
};
use
std
::
cell
::{
Cell
,
RefCell
};
...
@@ -918,8 +918,10 @@ fn lub_concrete_regions(&self, free_regions: &FreeRegionMap, a: Region, b: Regio
...
@@ -918,8 +918,10 @@ fn lub_concrete_regions(&self, free_regions: &FreeRegionMap, a: Region, b: Regio
(
ReLateBound
(
..
),
_
)
|
(
ReLateBound
(
..
),
_
)
|
(
_
,
ReLateBound
(
..
))
|
(
_
,
ReLateBound
(
..
))
|
(
ReEarlyBound
(
..
),
_
)
|
(
ReEarlyBound
(
..
),
_
)
|
(
_
,
ReEarlyBound
(
..
))
=>
{
(
_
,
ReEarlyBound
(
..
))
|
bug!
(
"cannot relate bound region: LUB({:?}, {:?})"
,
a
,
b
);
(
ReErased
,
_
)
|
(
_
,
ReErased
)
=>
{
bug!
(
"cannot relate region: LUB({:?}, {:?})"
,
a
,
b
);
}
}
(
ReStatic
,
_
)
|
(
_
,
ReStatic
)
=>
{
(
ReStatic
,
_
)
|
(
_
,
ReStatic
)
=>
{
...
...
src/librustc/ty/flags.rs
浏览文件 @
bcec7a58
...
@@ -187,7 +187,7 @@ fn add_region(&mut self, r: ty::Region) {
...
@@ -187,7 +187,7 @@ fn add_region(&mut self, r: ty::Region) {
}
}
ty
::
ReLateBound
(
debruijn
,
_
)
=>
{
self
.add_depth
(
debruijn
.depth
);
}
ty
::
ReLateBound
(
debruijn
,
_
)
=>
{
self
.add_depth
(
debruijn
.depth
);
}
ty
::
ReEarlyBound
(
..
)
=>
{
self
.add_flags
(
TypeFlags
::
HAS_RE_EARLY_BOUND
);
}
ty
::
ReEarlyBound
(
..
)
=>
{
self
.add_flags
(
TypeFlags
::
HAS_RE_EARLY_BOUND
);
}
ty
::
ReStatic
=>
{}
ty
::
ReStatic
|
ty
::
ReErased
=>
{}
_
=>
{
self
.add_flags
(
TypeFlags
::
HAS_FREE_REGIONS
);
}
_
=>
{
self
.add_flags
(
TypeFlags
::
HAS_FREE_REGIONS
);
}
}
}
...
...
src/librustc/ty/fold.rs
浏览文件 @
bcec7a58
...
@@ -421,12 +421,12 @@ fn collect_late_bound_regions<T>(&self, value: &Binder<T>, just_constraint: bool
...
@@ -421,12 +421,12 @@ fn collect_late_bound_regions<T>(&self, value: &Binder<T>, just_constraint: bool
collector
.regions
collector
.regions
}
}
/// Replace any late-bound regions bound in `value` with `'
static
`. Useful in trans but also
/// Replace any late-bound regions bound in `value` with `'
erased
`. Useful in trans but also
/// method lookup and a few other places where precise region relationships are not required.
/// method lookup and a few other places where precise region relationships are not required.
pub
fn
erase_late_bound_regions
<
T
>
(
self
,
value
:
&
Binder
<
T
>
)
->
T
pub
fn
erase_late_bound_regions
<
T
>
(
self
,
value
:
&
Binder
<
T
>
)
->
T
where
T
:
TypeFoldable
<
'tcx
>
where
T
:
TypeFoldable
<
'tcx
>
{
{
self
.replace_late_bound_regions
(
value
,
|
_
|
ty
::
Re
Static
)
.0
self
.replace_late_bound_regions
(
value
,
|
_
|
ty
::
Re
Erased
)
.0
}
}
/// Rewrite any late-bound regions so that they are anonymous. Region numbers are
/// Rewrite any late-bound regions so that they are anonymous. Region numbers are
...
@@ -547,15 +547,15 @@ fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
...
@@ -547,15 +547,15 @@ fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
fn
fold_region
(
&
mut
self
,
r
:
ty
::
Region
)
->
ty
::
Region
{
fn
fold_region
(
&
mut
self
,
r
:
ty
::
Region
)
->
ty
::
Region
{
// because late-bound regions affect subtyping, we can't
// because late-bound regions affect subtyping, we can't
// erase the bound/free distinction, but we can replace
// erase the bound/free distinction, but we can replace
// all free regions with '
static
.
// all free regions with '
erased
.
//
//
// Note that we *CAN* replace early-bound regions -- the
// Note that we *CAN* replace early-bound regions -- the
// type system never "sees" those, they get substituted
// type system never "sees" those, they get substituted
// away. In trans, they will always be erased to '
static
// away. In trans, they will always be erased to '
erased
// whenever a substitution occurs.
// whenever a substitution occurs.
match
r
{
match
r
{
ty
::
ReLateBound
(
..
)
=>
r
,
ty
::
ReLateBound
(
..
)
=>
r
,
_
=>
ty
::
Re
Static
_
=>
ty
::
Re
Erased
}
}
}
}
}
}
...
@@ -651,7 +651,7 @@ fn visit_region(&mut self, r: ty::Region) -> bool {
...
@@ -651,7 +651,7 @@ fn visit_region(&mut self, r: ty::Region) -> bool {
// does this represent a region that cannot be named
// does this represent a region that cannot be named
// in a global way? used in fulfillment caching.
// in a global way? used in fulfillment caching.
match
r
{
match
r
{
ty
::
ReStatic
|
ty
::
ReEmpty
=>
{}
ty
::
ReStatic
|
ty
::
ReEmpty
|
ty
::
ReErased
=>
{}
_
=>
return
true
,
_
=>
return
true
,
}
}
}
}
...
...
src/librustc/ty/sty.rs
浏览文件 @
bcec7a58
...
@@ -705,6 +705,9 @@ pub enum Region {
...
@@ -705,6 +705,9 @@ pub enum Region {
/// The only way to get an instance of ReEmpty is to have a region
/// The only way to get an instance of ReEmpty is to have a region
/// variable with no constraints.
/// variable with no constraints.
ReEmpty
,
ReEmpty
,
/// Erased region, used by trait selection, in MIR and during trans.
ReErased
,
}
}
#[derive(Copy,
Clone,
PartialEq,
Eq,
Hash,
RustcEncodable,
RustcDecodable,
Debug)]
#[derive(Copy,
Clone,
PartialEq,
Eq,
Hash,
RustcEncodable,
RustcDecodable,
Debug)]
...
...
src/librustc/ty/subst.rs
浏览文件 @
bcec7a58
...
@@ -89,7 +89,7 @@ pub fn with_self_ty(&self, self_ty: Ty<'tcx>) -> Substs<'tcx> {
...
@@ -89,7 +89,7 @@ pub fn with_self_ty(&self, self_ty: Ty<'tcx>) -> Substs<'tcx> {
pub
fn
erase_regions
(
self
)
->
Substs
<
'tcx
>
{
pub
fn
erase_regions
(
self
)
->
Substs
<
'tcx
>
{
let
Substs
{
types
,
regions
}
=
self
;
let
Substs
{
types
,
regions
}
=
self
;
let
regions
=
regions
.map
(|
_
|
ty
::
Re
Static
);
let
regions
=
regions
.map
(|
_
|
ty
::
Re
Erased
);
Substs
{
types
:
types
,
regions
:
regions
}
Substs
{
types
:
types
,
regions
:
regions
}
}
}
...
...
src/librustc/ty/util.rs
浏览文件 @
bcec7a58
...
@@ -348,7 +348,7 @@ fn helper<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
...
@@ -348,7 +348,7 @@ fn helper<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
let
region
=
|
state
:
&
mut
SipHasher
,
r
:
ty
::
Region
|
{
let
region
=
|
state
:
&
mut
SipHasher
,
r
:
ty
::
Region
|
{
match
r
{
match
r
{
ty
::
ReStatic
=>
{}
ty
::
ReStatic
|
ty
::
ReErased
=>
{}
ty
::
ReLateBound
(
db
,
ty
::
BrAnon
(
i
))
=>
{
ty
::
ReLateBound
(
db
,
ty
::
BrAnon
(
i
))
=>
{
db
.hash
(
state
);
db
.hash
(
state
);
i
.hash
(
state
);
i
.hash
(
state
);
...
...
src/librustc/util/ppaux.rs
浏览文件 @
bcec7a58
...
@@ -148,28 +148,36 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
...
@@ -148,28 +148,36 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
write!
(
f
,
"{}"
,
cont
)
write!
(
f
,
"{}"
,
cont
)
}
}
};
};
let
print_region
=
|
f
:
&
mut
fmt
::
Formatter
,
region
:
&
ty
::
Region
|
->
_
{
if
verbose
{
let
print_regions
=
|
f
:
&
mut
fmt
::
Formatter
,
start
:
&
str
,
regions
:
&
[
ty
::
Region
]|
{
write!
(
f
,
"{:?}"
,
region
)
// Don't print any regions if they're all erased.
}
else
{
if
regions
.iter
()
.all
(|
r
|
*
r
==
ty
::
ReErased
)
{
let
s
=
region
.to_string
();
return
Ok
(());
if
s
.is_empty
()
{
}
// This happens when the value of the region
// parameter is not easily serialized. This may be
for
region
in
regions
{
// because the user omitted it in the first place,
start_or_continue
(
f
,
start
,
", "
)
?
;
// or because it refers to some block in the code,
if
verbose
{
// etc. I'm not sure how best to serialize this.
write!
(
f
,
"{:?}"
,
region
)
?
;
write!
(
f
,
"'_"
)
}
else
{
}
else
{
write!
(
f
,
"{}"
,
s
)
let
s
=
region
.to_string
();
if
s
.is_empty
()
{
// This happens when the value of the region
// parameter is not easily serialized. This may be
// because the user omitted it in the first place,
// or because it refers to some block in the code,
// etc. I'm not sure how best to serialize this.
write!
(
f
,
"'_"
)
?
;
}
else
{
write!
(
f
,
"{}"
,
s
)
?
;
}
}
}
}
}
Ok
(())
};
};
for
region
in
substs
.regions
.get_slice
(
subst
::
TypeSpace
)
{
print_regions
(
f
,
"<"
,
substs
.regions
.get_slice
(
subst
::
TypeSpace
))
?
;
start_or_continue
(
f
,
"<"
,
", "
)
?
;
print_region
(
f
,
region
)
?
;
}
let
num_supplied_defaults
=
if
verbose
{
let
num_supplied_defaults
=
if
verbose
{
0
0
...
@@ -211,10 +219,7 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
...
@@ -211,10 +219,7 @@ pub fn parameterized<GG>(f: &mut fmt::Formatter,
write!
(
f
,
"::{}"
,
item_name
)
?
;
write!
(
f
,
"::{}"
,
item_name
)
?
;
}
}
for
region
in
substs
.regions
.get_slice
(
subst
::
FnSpace
)
{
print_regions
(
f
,
"::<"
,
substs
.regions
.get_slice
(
subst
::
FnSpace
))
?
;
start_or_continue
(
f
,
"::<"
,
", "
)
?
;
print_region
(
f
,
region
)
?
;
}
// FIXME: consider being smart with defaults here too
// FIXME: consider being smart with defaults here too
for
ty
in
substs
.types
.get_slice
(
subst
::
FnSpace
)
{
for
ty
in
substs
.types
.get_slice
(
subst
::
FnSpace
)
{
...
@@ -536,7 +541,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...
@@ -536,7 +541,9 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!
(
f
,
"ReSkolemized({}, {:?})"
,
id
.index
,
bound_region
)
write!
(
f
,
"ReSkolemized({}, {:?})"
,
id
.index
,
bound_region
)
}
}
ty
::
ReEmpty
=>
write!
(
f
,
"ReEmpty"
)
ty
::
ReEmpty
=>
write!
(
f
,
"ReEmpty"
),
ty
::
ReErased
=>
write!
(
f
,
"ReErased"
)
}
}
}
}
}
}
...
@@ -600,7 +607,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...
@@ -600,7 +607,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!
(
f
,
"{}"
,
br
)
write!
(
f
,
"{}"
,
br
)
}
}
ty
::
ReScope
(
_
)
|
ty
::
ReScope
(
_
)
|
ty
::
ReVar
(
_
)
=>
Ok
(()),
ty
::
ReVar
(
_
)
|
ty
::
ReErased
=>
Ok
(()),
ty
::
ReStatic
=>
write!
(
f
,
"'static"
),
ty
::
ReStatic
=>
write!
(
f
,
"'static"
),
ty
::
ReEmpty
=>
write!
(
f
,
"'<empty>"
),
ty
::
ReEmpty
=>
write!
(
f
,
"'<empty>"
),
}
}
...
...
src/librustc_borrowck/borrowck/gather_loans/mod.rs
浏览文件 @
bcec7a58
...
@@ -369,7 +369,8 @@ fn guarantee_valid(&mut self,
...
@@ -369,7 +369,8 @@ fn guarantee_valid(&mut self,
ty
::
ReLateBound
(
..
)
|
ty
::
ReLateBound
(
..
)
|
ty
::
ReEarlyBound
(
..
)
|
ty
::
ReEarlyBound
(
..
)
|
ty
::
ReVar
(
..
)
|
ty
::
ReVar
(
..
)
|
ty
::
ReSkolemized
(
..
)
=>
{
ty
::
ReSkolemized
(
..
)
|
ty
::
ReErased
=>
{
span_bug!
(
span_bug!
(
cmt
.span
,
cmt
.span
,
"invalid borrow lifetime: {:?}"
,
"invalid borrow lifetime: {:?}"
,
...
...
src/librustc_metadata/tydecode.rs
浏览文件 @
bcec7a58
...
@@ -221,12 +221,9 @@ pub fn parse_region(&mut self) -> ty::Region {
...
@@ -221,12 +221,9 @@ pub fn parse_region(&mut self) -> ty::Region {
assert_eq!
(
self
.next
(),
'|'
);
assert_eq!
(
self
.next
(),
'|'
);
ty
::
ReScope
(
scope
)
ty
::
ReScope
(
scope
)
}
}
't'
=>
{
't'
=>
ty
::
ReStatic
,
ty
::
ReStatic
'e'
=>
ty
::
ReEmpty
,
}
'E'
=>
ty
::
ReErased
,
'e'
=>
{
ty
::
ReStatic
}
_
=>
bug!
(
"parse_region: bad input"
)
_
=>
bug!
(
"parse_region: bad input"
)
}
}
}
}
...
...
src/librustc_metadata/tyencode.rs
浏览文件 @
bcec7a58
...
@@ -283,6 +283,9 @@ pub fn enc_region(w: &mut Cursor<Vec<u8>>, cx: &ctxt, r: ty::Region) {
...
@@ -283,6 +283,9 @@ pub fn enc_region(w: &mut Cursor<Vec<u8>>, cx: &ctxt, r: ty::Region) {
ty
::
ReEmpty
=>
{
ty
::
ReEmpty
=>
{
write!
(
w
,
"e"
);
write!
(
w
,
"e"
);
}
}
ty
::
ReErased
=>
{
write!
(
w
,
"E"
);
}
ty
::
ReVar
(
_
)
|
ty
::
ReSkolemized
(
..
)
=>
{
ty
::
ReVar
(
_
)
|
ty
::
ReSkolemized
(
..
)
=>
{
// these should not crop up after typeck
// these should not crop up after typeck
bug!
(
"cannot encode region variables"
);
bug!
(
"cannot encode region variables"
);
...
...
src/librustc_trans/_match.rs
浏览文件 @
bcec7a58
...
@@ -731,7 +731,7 @@ fn bind_subslice_pat(bcx: Block,
...
@@ -731,7 +731,7 @@ fn bind_subslice_pat(bcx: Block,
let
slice_begin
=
InBoundsGEP
(
bcx
,
base
,
&
[
C_uint
(
bcx
.ccx
(),
offset_left
)]);
let
slice_begin
=
InBoundsGEP
(
bcx
,
base
,
&
[
C_uint
(
bcx
.ccx
(),
offset_left
)]);
let
slice_len_offset
=
C_uint
(
bcx
.ccx
(),
offset_left
+
offset_right
);
let
slice_len_offset
=
C_uint
(
bcx
.ccx
(),
offset_left
+
offset_right
);
let
slice_len
=
Sub
(
bcx
,
len
,
slice_len_offset
,
DebugLoc
::
None
);
let
slice_len
=
Sub
(
bcx
,
len
,
slice_len_offset
,
DebugLoc
::
None
);
let
slice_ty
=
bcx
.tcx
()
.mk_imm_ref
(
bcx
.tcx
()
.mk_region
(
ty
::
Re
Static
),
let
slice_ty
=
bcx
.tcx
()
.mk_imm_ref
(
bcx
.tcx
()
.mk_region
(
ty
::
Re
Erased
),
bcx
.tcx
()
.mk_slice
(
unit_ty
));
bcx
.tcx
()
.mk_slice
(
unit_ty
));
let
scratch
=
rvalue_scratch_datum
(
bcx
,
slice_ty
,
""
);
let
scratch
=
rvalue_scratch_datum
(
bcx
,
slice_ty
,
""
);
Store
(
bcx
,
slice_begin
,
expr
::
get_dataptr
(
bcx
,
scratch
.val
));
Store
(
bcx
,
slice_begin
,
expr
::
get_dataptr
(
bcx
,
scratch
.val
));
...
...
src/librustc_trans/callee.rs
浏览文件 @
bcec7a58
...
@@ -328,7 +328,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
...
@@ -328,7 +328,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
};
};
let
bare_fn_ty_maybe_ref
=
if
is_by_ref
{
let
bare_fn_ty_maybe_ref
=
if
is_by_ref
{
tcx
.mk_imm_ref
(
tcx
.mk_region
(
ty
::
Re
Static
),
bare_fn_ty
)
tcx
.mk_imm_ref
(
tcx
.mk_region
(
ty
::
Re
Erased
),
bare_fn_ty
)
}
else
{
}
else
{
bare_fn_ty
bare_fn_ty
};
};
...
...
src/librustc_trans/closure.rs
浏览文件 @
bcec7a58
...
@@ -123,10 +123,10 @@ fn get_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
...
@@ -123,10 +123,10 @@ fn get_self_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
->
Ty
<
'tcx
>
{
->
Ty
<
'tcx
>
{
match
tcx
.closure_kind
(
closure_id
)
{
match
tcx
.closure_kind
(
closure_id
)
{
ty
::
ClosureKind
::
Fn
=>
{
ty
::
ClosureKind
::
Fn
=>
{
tcx
.mk_imm_ref
(
tcx
.mk_region
(
ty
::
Re
Static
),
fn_ty
)
tcx
.mk_imm_ref
(
tcx
.mk_region
(
ty
::
Re
Erased
),
fn_ty
)
}
}
ty
::
ClosureKind
::
FnMut
=>
{
ty
::
ClosureKind
::
FnMut
=>
{
tcx
.mk_mut_ref
(
tcx
.mk_region
(
ty
::
Re
Static
),
fn_ty
)
tcx
.mk_mut_ref
(
tcx
.mk_region
(
ty
::
Re
Erased
),
fn_ty
)
}
}
ty
::
ClosureKind
::
FnOnce
=>
fn_ty
,
ty
::
ClosureKind
::
FnOnce
=>
fn_ty
,
}
}
...
@@ -344,7 +344,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
...
@@ -344,7 +344,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>(
// Find a version of the closure type. Substitute static for the
// Find a version of the closure type. Substitute static for the
// region since it doesn't really matter.
// region since it doesn't really matter.
let
closure_ty
=
tcx
.mk_closure_from_closure_substs
(
closure_def_id
,
substs
);
let
closure_ty
=
tcx
.mk_closure_from_closure_substs
(
closure_def_id
,
substs
);
let
ref_closure_ty
=
tcx
.mk_imm_ref
(
tcx
.mk_region
(
ty
::
Re
Static
),
closure_ty
);
let
ref_closure_ty
=
tcx
.mk_imm_ref
(
tcx
.mk_region
(
ty
::
Re
Erased
),
closure_ty
);
// Make a version with the type of by-ref closure.
// Make a version with the type of by-ref closure.
let
ty
::
ClosureTy
{
unsafety
,
abi
,
mut
sig
}
=
let
ty
::
ClosureTy
{
unsafety
,
abi
,
mut
sig
}
=
...
...
src/librustc_trans/consts.rs
浏览文件 @
bcec7a58
...
@@ -382,7 +382,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
...
@@ -382,7 +382,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Don't copy data to do a deref+ref
// Don't copy data to do a deref+ref
// (i.e., skip the last auto-deref).
// (i.e., skip the last auto-deref).
llconst
=
addr_of
(
cx
,
llconst
,
type_of
::
align_of
(
cx
,
ty
),
"autoref"
);
llconst
=
addr_of
(
cx
,
llconst
,
type_of
::
align_of
(
cx
,
ty
),
"autoref"
);
ty
=
cx
.tcx
()
.mk_imm_ref
(
cx
.tcx
()
.mk_region
(
ty
::
Re
Static
),
ty
);
ty
=
cx
.tcx
()
.mk_imm_ref
(
cx
.tcx
()
.mk_region
(
ty
::
Re
Erased
),
ty
);
}
}
}
else
if
adj
.autoderefs
>
0
{
}
else
if
adj
.autoderefs
>
0
{
let
(
dv
,
dt
)
=
const_deref
(
cx
,
llconst
,
ty
);
let
(
dv
,
dt
)
=
const_deref
(
cx
,
llconst
,
ty
);
...
...
src/librustc_trans/context.rs
浏览文件 @
bcec7a58
...
@@ -495,7 +495,7 @@ pub fn empty_substs_for_scheme(&self, scheme: &ty::TypeScheme<'tcx>)
...
@@ -495,7 +495,7 @@ pub fn empty_substs_for_scheme(&self, scheme: &ty::TypeScheme<'tcx>)
assert
!
(
scheme
.generics.types
.is_empty
());
assert
!
(
scheme
.generics.types
.is_empty
());
self
.tcx
()
.mk_substs
(
self
.tcx
()
.mk_substs
(
Substs
::
new
(
VecPerParamSpace
::
empty
(),
Substs
::
new
(
VecPerParamSpace
::
empty
(),
scheme
.generics.regions
.map
(|
_
|
ty
::
Re
Static
)))
scheme
.generics.regions
.map
(|
_
|
ty
::
Re
Erased
)))
}
}
pub
fn
symbol_hasher
(
&
self
)
->
&
RefCell
<
Sha256
>
{
pub
fn
symbol_hasher
(
&
self
)
->
&
RefCell
<
Sha256
>
{
...
...
src/librustc_trans/expr.rs
浏览文件 @
bcec7a58
...
@@ -1978,7 +1978,7 @@ fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
...
@@ -1978,7 +1978,7 @@ fn auto_ref<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// Compute final type. Note that we are loose with the region and
// Compute final type. Note that we are loose with the region and
// mutability, since those things don't matter in trans.
// mutability, since those things don't matter in trans.
let
referent_ty
=
lv_datum
.ty
;
let
referent_ty
=
lv_datum
.ty
;
let
ptr_ty
=
bcx
.tcx
()
.mk_imm_ref
(
bcx
.tcx
()
.mk_region
(
ty
::
Re
Static
),
referent_ty
);
let
ptr_ty
=
bcx
.tcx
()
.mk_imm_ref
(
bcx
.tcx
()
.mk_region
(
ty
::
Re
Erased
),
referent_ty
);
// Construct the resulting datum. The right datum to return here would be an Lvalue datum,
// Construct the resulting datum. The right datum to return here would be an Lvalue datum,
// because there is cleanup scheduled and the datum doesn't own the data, but for thin pointers
// because there is cleanup scheduled and the datum doesn't own the data, but for thin pointers
...
...
src/librustc_trans/meth.rs
浏览文件 @
bcec7a58
...
@@ -271,7 +271,7 @@ pub fn get_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
...
@@ -271,7 +271,7 @@ pub fn get_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// the method may have some early-bound lifetimes, add
// the method may have some early-bound lifetimes, add
// regions for those
// regions for those
let
num_dummy_regions
=
trait_method_type
.generics.regions
.len
(
FnSpace
);
let
num_dummy_regions
=
trait_method_type
.generics.regions
.len
(
FnSpace
);
let
dummy_regions
=
vec!
[
ty
::
Re
Static
;
num_dummy_regions
];
let
dummy_regions
=
vec!
[
ty
::
Re
Erased
;
num_dummy_regions
];
let
method_substs
=
substs
.clone
()
let
method_substs
=
substs
.clone
()
.with_method
(
vec!
[],
dummy_regions
);
.with_method
(
vec!
[],
dummy_regions
);
let
method_substs
=
tcx
.mk_substs
(
method_substs
);
let
method_substs
=
tcx
.mk_substs
(
method_substs
);
...
...
src/librustc_trans/mir/constant.rs
浏览文件 @
bcec7a58
...
@@ -667,7 +667,7 @@ fn const_rvalue(&self, rvalue: &mir::Rvalue<'tcx>,
...
@@ -667,7 +667,7 @@ fn const_rvalue(&self, rvalue: &mir::Rvalue<'tcx>,
let
tr_lvalue
=
self
.const_lvalue
(
lvalue
,
span
)
?
;
let
tr_lvalue
=
self
.const_lvalue
(
lvalue
,
span
)
?
;
let
ty
=
tr_lvalue
.ty
;
let
ty
=
tr_lvalue
.ty
;
let
ref_ty
=
tcx
.mk_ref
(
tcx
.mk_region
(
ty
::
Re
Static
),
let
ref_ty
=
tcx
.mk_ref
(
tcx
.mk_region
(
ty
::
Re
Erased
),
ty
::
TypeAndMut
{
ty
:
ty
,
mutbl
:
bk
.to_mutbl_lossy
()
});
ty
::
TypeAndMut
{
ty
:
ty
,
mutbl
:
bk
.to_mutbl_lossy
()
});
let
base
=
match
tr_lvalue
.base
{
let
base
=
match
tr_lvalue
.base
{
...
...
src/librustc_trans/mir/rvalue.rs
浏览文件 @
bcec7a58
...
@@ -371,7 +371,7 @@ pub fn trans_rvalue_operand(&mut self,
...
@@ -371,7 +371,7 @@ pub fn trans_rvalue_operand(&mut self,
let
ty
=
tr_lvalue
.ty
.to_ty
(
bcx
.tcx
());
let
ty
=
tr_lvalue
.ty
.to_ty
(
bcx
.tcx
());
let
ref_ty
=
bcx
.tcx
()
.mk_ref
(
let
ref_ty
=
bcx
.tcx
()
.mk_ref
(
bcx
.tcx
()
.mk_region
(
ty
::
Re
Static
),
bcx
.tcx
()
.mk_region
(
ty
::
Re
Erased
),
ty
::
TypeAndMut
{
ty
:
ty
,
mutbl
:
bk
.to_mutbl_lossy
()
}
ty
::
TypeAndMut
{
ty
:
ty
,
mutbl
:
bk
.to_mutbl_lossy
()
}
);
);
...
...
src/librustc_trans/monomorphize.rs
浏览文件 @
bcec7a58
...
@@ -180,7 +180,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
...
@@ -180,7 +180,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
impl
<
'tcx
>
Instance
<
'tcx
>
{
impl
<
'tcx
>
Instance
<
'tcx
>
{
pub
fn
new
(
def_id
:
DefId
,
substs
:
&
'tcx
Substs
<
'tcx
>
)
pub
fn
new
(
def_id
:
DefId
,
substs
:
&
'tcx
Substs
<
'tcx
>
)
->
Instance
<
'tcx
>
{
->
Instance
<
'tcx
>
{
assert
!
(
substs
.regions
.iter
()
.all
(|
&
r
|
r
==
ty
::
Re
Static
));
assert
!
(
substs
.regions
.iter
()
.all
(|
&
r
|
r
==
ty
::
Re
Erased
));
Instance
{
def
:
def_id
,
substs
:
substs
}
Instance
{
def
:
def_id
,
substs
:
substs
}
}
}
pub
fn
mono
<
'a
>
(
scx
:
&
SharedCrateContext
<
'a
,
'tcx
>
,
def_id
:
DefId
)
->
Instance
<
'tcx
>
{
pub
fn
mono
<
'a
>
(
scx
:
&
SharedCrateContext
<
'a
,
'tcx
>
,
def_id
:
DefId
)
->
Instance
<
'tcx
>
{
...
...
src/librustc_typeck/check/method/probe.rs
浏览文件 @
bcec7a58
...
@@ -976,7 +976,7 @@ fn pick_autorefd_method(&mut self,
...
@@ -976,7 +976,7 @@ fn pick_autorefd_method(&mut self,
// In general, during probing we erase regions. See
// In general, during probing we erase regions. See
// `impl_self_ty()` for an explanation.
// `impl_self_ty()` for an explanation.
let
region
=
tcx
.mk_region
(
ty
::
Re
Static
);
let
region
=
tcx
.mk_region
(
ty
::
Re
Erased
);
// Search through mutabilities in order to find one where pick works:
// Search through mutabilities in order to find one where pick works:
[
hir
::
MutImmutable
,
hir
::
MutMutable
]
.iter
()
.filter_map
(|
&
m
|
{
[
hir
::
MutImmutable
,
hir
::
MutMutable
]
.iter
()
.filter_map
(|
&
m
|
{
...
@@ -1240,7 +1240,7 @@ fn xform_method_self_ty(&self,
...
@@ -1240,7 +1240,7 @@ fn xform_method_self_ty(&self,
let
method_regions
=
let
method_regions
=
method
.generics.regions
.get_slice
(
subst
::
FnSpace
)
method
.generics.regions
.get_slice
(
subst
::
FnSpace
)
.iter
()
.iter
()
.map
(|
_
|
ty
::
Re
Static
)
.map
(|
_
|
ty
::
Re
Erased
)
.collect
();
.collect
();
placeholder
=
(
*
substs
)
.clone
()
.with_method
(
Vec
::
new
(),
method_regions
);
placeholder
=
(
*
substs
)
.clone
()
.with_method
(
Vec
::
new
(),
method_regions
);
...
@@ -1276,7 +1276,7 @@ fn impl_ty_and_substs(&self,
...
@@ -1276,7 +1276,7 @@ fn impl_ty_and_substs(&self,
let
region_placeholders
=
let
region_placeholders
=
impl_pty
.generics.regions
.map
(
impl_pty
.generics.regions
.map
(
|
_
|
ty
::
Re
Static
);
// see erase_late_bound_regions() for an expl of why 'static
|
_
|
ty
::
Re
Erased
);
// see erase_late_bound_regions() for an expl of why 'erased
let
substs
=
subst
::
Substs
::
new
(
type_vars
,
region_placeholders
);
let
substs
=
subst
::
Substs
::
new
(
type_vars
,
region_placeholders
);
(
impl_pty
.ty
,
substs
)
(
impl_pty
.ty
,
substs
)
...
...
src/librustc_typeck/variance/constraints.rs
浏览文件 @
bcec7a58
...
@@ -520,7 +520,7 @@ fn add_constraints_from_region(&mut self,
...
@@ -520,7 +520,7 @@ fn add_constraints_from_region(&mut self,
}
}
ty
::
ReFree
(
..
)
|
ty
::
ReScope
(
..
)
|
ty
::
ReVar
(
..
)
|
ty
::
ReFree
(
..
)
|
ty
::
ReScope
(
..
)
|
ty
::
ReVar
(
..
)
|
ty
::
ReSkolemized
(
..
)
|
ty
::
ReEmpty
=>
{
ty
::
ReSkolemized
(
..
)
|
ty
::
ReEmpty
|
ty
::
ReErased
=>
{
// We don't expect to see anything but 'static or bound
// We don't expect to see anything but 'static or bound
// regions when visiting member types or method types.
// regions when visiting member types or method types.
bug!
(
"unexpected region encountered in variance
\
bug!
(
"unexpected region encountered in variance
\
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
bcec7a58
...
@@ -827,7 +827,8 @@ fn clean(&self, cx: &DocContext) -> Option<Lifetime> {
...
@@ -827,7 +827,8 @@ fn clean(&self, cx: &DocContext) -> Option<Lifetime> {
ty
::
ReScope
(
..
)
|
ty
::
ReScope
(
..
)
|
ty
::
ReVar
(
..
)
|
ty
::
ReVar
(
..
)
|
ty
::
ReSkolemized
(
..
)
|
ty
::
ReSkolemized
(
..
)
|
ty
::
ReEmpty
=>
None
ty
::
ReEmpty
|
ty
::
ReErased
=>
None
}
}
}
}
}
}
...
...
src/test/compile-fail/non-interger-atomic.rs
浏览文件 @
bcec7a58
...
@@ -60,22 +60,22 @@ unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) {
...
@@ -60,22 +60,22 @@ unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) {
unsafe
fn
test_Bar_load
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
unsafe
fn
test_Bar_load
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
intrinsics
::
atomic_load
(
p
);
intrinsics
::
atomic_load
(
p
);
//~^ ERROR expected basic integer type, found `&
'static std::ops::Fn() + 'static
`
//~^ ERROR expected basic integer type, found `&
std::ops::Fn()
`
}
}
unsafe
fn
test_Bar_store
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
unsafe
fn
test_Bar_store
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
intrinsics
::
atomic_store
(
p
,
v
);
intrinsics
::
atomic_store
(
p
,
v
);
//~^ ERROR expected basic integer type, found `&
'static std::ops::Fn() + 'static
`
//~^ ERROR expected basic integer type, found `&
std::ops::Fn()
`
}
}
unsafe
fn
test_Bar_xchg
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
unsafe
fn
test_Bar_xchg
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
intrinsics
::
atomic_xchg
(
p
,
v
);
intrinsics
::
atomic_xchg
(
p
,
v
);
//~^ ERROR expected basic integer type, found `&
'static std::ops::Fn() + 'static
`
//~^ ERROR expected basic integer type, found `&
std::ops::Fn()
`
}
}
unsafe
fn
test_Bar_cxchg
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
unsafe
fn
test_Bar_cxchg
(
p
:
&
mut
Bar
,
v
:
Bar
)
{
intrinsics
::
atomic_cxchg
(
p
,
v
,
v
);
intrinsics
::
atomic_cxchg
(
p
,
v
,
v
);
//~^ ERROR expected basic integer type, found `&
'static std::ops::Fn() + 'static
`
//~^ ERROR expected basic integer type, found `&
std::ops::Fn()
`
}
}
unsafe
fn
test_Quux_load
(
p
:
&
mut
Quux
,
v
:
Quux
)
{
unsafe
fn
test_Quux_load
(
p
:
&
mut
Quux
,
v
:
Quux
)
{
...
...
src/test/run-pass/issue-21058.rs
浏览文件 @
bcec7a58
...
@@ -26,5 +26,5 @@ fn main() {
...
@@ -26,5 +26,5 @@ fn main() {
std
::
intrinsics
::
type_name
::
<
NT
>
(),
std
::
intrinsics
::
type_name
::
<
NT
>
(),
// DST
// DST
std
::
intrinsics
::
type_name
::
<
DST
>
()
std
::
intrinsics
::
type_name
::
<
DST
>
()
)},
(
"[u8]"
,
"str"
,
"std::marker::Send
+ 'static
"
,
"NT"
,
"DST"
));
)},
(
"[u8]"
,
"str"
,
"std::marker::Send"
,
"NT"
,
"DST"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录