Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
5cfa713a
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,发现更多精彩内容 >>
提交
5cfa713a
编写于
4月 29, 2015
作者:
T
Tamir Duberstein
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use `empty()` instead of a special const
上级
252b5444
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
11 addition
and
14 deletion
+11
-14
src/librustc/middle/check_const.rs
src/librustc/middle/check_const.rs
+3
-5
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+4
-3
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+1
-2
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/consts.rs
+1
-1
src/libsyntax/parse/parser.rs
src/libsyntax/parse/parser.rs
+2
-3
未找到文件。
src/librustc/middle/check_const.rs
浏览文件 @
5cfa713a
...
...
@@ -45,8 +45,6 @@
bitflags!
{
#[derive(RustcEncodable,
RustcDecodable)]
flags
ConstQualif
:
u8
{
// Const rvalue which can be placed behind a reference.
const
PURE_CONST
=
0
,
// Inner mutability (can not be placed behind a reference) or behind
// &mut in a non-global expression. Can be copied from static memory.
const
MUTABLE_MEM
=
1
<<
0
,
...
...
@@ -104,7 +102,7 @@ fn with_mode<F, R>(&mut self, mode: Mode, f: F) -> R where
{
let
(
old_mode
,
old_qualif
)
=
(
self
.mode
,
self
.qualif
);
self
.mode
=
mode
;
self
.qualif
=
ConstQualif
::
PURE_CONST
;
self
.qualif
=
ConstQualif
::
empty
()
;
let
r
=
f
(
self
);
self
.mode
=
old_mode
;
self
.qualif
=
old_qualif
;
...
...
@@ -128,7 +126,7 @@ fn global_expr(&mut self, mode: Mode, expr: &ast::Expr) -> ConstQualif {
Entry
::
Occupied
(
entry
)
=>
return
*
entry
.get
(),
Entry
::
Vacant
(
entry
)
=>
{
// Prevent infinite recursion on re-entry.
entry
.insert
(
ConstQualif
::
PURE_CONST
);
entry
.insert
(
ConstQualif
::
empty
()
);
}
}
self
.with_mode
(
mode
,
|
this
|
{
...
...
@@ -273,7 +271,7 @@ fn visit_pat(&mut self, p: &ast::Pat) {
fn
visit_expr
(
&
mut
self
,
ex
:
&
ast
::
Expr
)
{
let
mut
outer
=
self
.qualif
;
self
.qualif
=
ConstQualif
::
PURE_CONST
;
self
.qualif
=
ConstQualif
::
empty
()
;
let
node_ty
=
ty
::
node_id_to_type
(
self
.tcx
,
ex
.id
);
check_expr
(
self
,
ex
,
node_ty
);
...
...
src/librustc/middle/mem_categorization.rs
浏览文件 @
5cfa713a
...
...
@@ -850,9 +850,10 @@ pub fn cat_rvalue_node(&self,
// Compute maximum lifetime of this rvalue. This is 'static if
// we can promote to a constant, otherwise equal to enclosing temp
// lifetime.
let
re
=
match
qualif
&
check_const
::
ConstQualif
::
NON_STATIC_BORROWS
{
check_const
::
ConstQualif
::
PURE_CONST
=>
ty
::
ReStatic
,
_
=>
self
.temporary_scope
(
id
),
let
re
=
if
qualif
.intersects
(
check_const
::
ConstQualif
::
NON_STATIC_BORROWS
)
{
self
.temporary_scope
(
id
)
}
else
{
ty
::
ReStatic
};
let
ret
=
self
.cat_rvalue
(
id
,
span
,
re
,
expr_ty
);
debug!
(
"cat_rvalue_node ret {}"
,
ret
.repr
(
self
.tcx
()));
...
...
src/librustc/middle/ty.rs
浏览文件 @
5cfa713a
...
...
@@ -849,7 +849,6 @@ pub fn free_region_map(&self, id: NodeId) -> FreeRegionMap {
// recursing over the type itself.
bitflags!
{
flags
TypeFlags
:
u32
{
const
NO_TYPE_FLAGS
=
0
,
const
HAS_PARAMS
=
1
<<
0
,
const
HAS_SELF
=
1
<<
1
,
const
HAS_TY_INFER
=
1
<<
2
,
...
...
@@ -2925,7 +2924,7 @@ struct FlagComputation {
impl
FlagComputation
{
fn
new
()
->
FlagComputation
{
FlagComputation
{
flags
:
TypeFlags
::
NO_TYPE_FLAGS
,
depth
:
0
}
FlagComputation
{
flags
:
TypeFlags
::
empty
()
,
depth
:
0
}
}
fn
for_sty
(
st
:
&
sty
)
->
FlagComputation
{
...
...
src/librustc_trans/trans/consts.rs
浏览文件 @
5cfa713a
...
...
@@ -186,7 +186,7 @@ fn get_const_val(ccx: &CrateContext,
ref_expr
:
&
ast
::
Expr
)
->
ValueRef
{
let
expr
=
get_const_expr
(
ccx
,
def_id
,
ref_expr
);
let
empty_substs
=
ccx
.tcx
()
.mk_substs
(
Substs
::
trans_empty
());
get_const_expr_as_global
(
ccx
,
expr
,
check_const
::
ConstQualif
::
PURE_CONST
,
empty_substs
)
get_const_expr_as_global
(
ccx
,
expr
,
check_const
::
ConstQualif
::
empty
()
,
empty_substs
)
}
pub
fn
get_const_expr_as_global
<
'a
,
'tcx
>
(
ccx
:
&
CrateContext
<
'a
,
'tcx
>
,
...
...
src/libsyntax/parse/parser.rs
浏览文件 @
5cfa713a
...
...
@@ -88,7 +88,6 @@
bitflags!
{
flags
Restrictions
:
u8
{
const
UNRESTRICTED
=
0
,
const
RESTRICTION_STMT_EXPR
=
1
<<
0
,
const
RESTRICTION_NO_STRUCT_LITERAL
=
1
<<
1
,
}
...
...
@@ -339,7 +338,7 @@ pub fn new(sess: &'a ParseSess,
buffer_start
:
0
,
buffer_end
:
0
,
tokens_consumed
:
0
,
restrictions
:
Restrictions
::
UNRESTRICTED
,
restrictions
:
Restrictions
::
empty
()
,
quote_depth
:
0
,
obsolete_set
:
HashSet
::
new
(),
mod_path_stack
:
Vec
::
new
(),
...
...
@@ -2991,7 +2990,7 @@ pub fn parse_arm_nopanic(&mut self) -> PResult<Arm> {
/// Parse an expression
pub
fn
parse_expr_nopanic
(
&
mut
self
)
->
PResult
<
P
<
Expr
>>
{
return
self
.parse_expr_res
(
Restrictions
::
UNRESTRICTED
);
self
.parse_expr_res
(
Restrictions
::
empty
())
}
/// Parse an expression, subject to the given restrictions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录