Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
57ebd28f
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,发现更多精彩内容 >>
提交
57ebd28f
编写于
9月 03, 2017
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: use ConstVal::Unevaluated instead of mir::Literal::Item.
上级
74349fa2
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
33 addition
and
50 deletion
+33
-50
src/librustc/ich/impls_mir.rs
src/librustc/ich/impls_mir.rs
+0
-4
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+5
-13
src/librustc/mir/visit.rs
src/librustc/mir/visit.rs
+0
-5
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/expr.rs
+5
-3
src/librustc_mir/transform/qualify_consts.rs
src/librustc_mir/transform/qualify_consts.rs
+6
-3
src/librustc_passes/mir_stats.rs
src/librustc_passes/mir_stats.rs
+0
-1
src/librustc_trans/collector.rs
src/librustc_trans/collector.rs
+5
-11
src/librustc_trans/mir/constant.rs
src/librustc_trans/mir/constant.rs
+12
-10
未找到文件。
src/librustc/ich/impls_mir.rs
浏览文件 @
57ebd28f
...
...
@@ -493,10 +493,6 @@ fn hash_stable<W: StableHasherResult>(&self,
hasher
:
&
mut
StableHasher
<
W
>
)
{
mem
::
discriminant
(
self
)
.hash_stable
(
hcx
,
hasher
);
match
*
self
{
mir
::
Literal
::
Item
{
def_id
,
substs
}
=>
{
def_id
.hash_stable
(
hcx
,
hasher
);
substs
.hash_stable
(
hcx
,
hasher
);
}
mir
::
Literal
::
Value
{
ref
value
}
=>
{
value
.hash_stable
(
hcx
,
hasher
);
}
...
...
src/librustc/mir/mod.rs
浏览文件 @
57ebd28f
...
...
@@ -1479,10 +1479,6 @@ pub struct Constant<'tcx> {
#[derive(Clone,
PartialEq,
Eq,
Hash,
RustcEncodable,
RustcDecodable)]
pub
enum
Literal
<
'tcx
>
{
Item
{
def_id
:
DefId
,
substs
:
&
'tcx
Substs
<
'tcx
>
,
},
Value
{
value
:
&
'tcx
ty
::
Const
<
'tcx
>
,
},
...
...
@@ -1502,9 +1498,6 @@ impl<'tcx> Debug for Literal<'tcx> {
fn
fmt
(
&
self
,
fmt
:
&
mut
Formatter
)
->
fmt
::
Result
{
use
self
::
Literal
::
*
;
match
*
self
{
Item
{
def_id
,
substs
}
=>
{
ppaux
::
parameterized
(
fmt
,
substs
,
def_id
,
&
[])
}
Value
{
value
}
=>
{
write!
(
fmt
,
"const "
)
?
;
fmt_const_val
(
fmt
,
&
value
.val
)
...
...
@@ -2002,17 +1995,16 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
impl
<
'tcx
>
TypeFoldable
<
'tcx
>
for
Literal
<
'tcx
>
{
fn
super_fold_with
<
'gcx
:
'tcx
,
F
:
TypeFolder
<
'gcx
,
'tcx
>>
(
&
self
,
folder
:
&
mut
F
)
->
Self
{
match
*
self
{
Literal
::
Item
{
def_id
,
substs
}
=>
Literal
::
Item
{
def_id
,
substs
:
substs
.fold_with
(
folder
)
Literal
::
Value
{
value
}
=>
Literal
::
Value
{
value
:
value
.fold_with
(
folder
)
},
_
=>
self
.clone
()
Literal
::
Promoted
{
index
}
=>
Literal
::
Promoted
{
index
}
}
}
fn
super_visit_with
<
V
:
TypeVisitor
<
'tcx
>>
(
&
self
,
visitor
:
&
mut
V
)
->
bool
{
match
*
self
{
Literal
::
Item
{
substs
,
..
}
=>
substs
.visit_with
(
visitor
),
_
=>
false
Literal
::
Value
{
value
}
=>
value
.visit_with
(
visitor
),
Literal
::
Promoted
{
..
}
=>
false
}
}
}
src/librustc/mir/visit.rs
浏览文件 @
57ebd28f
...
...
@@ -724,11 +724,6 @@ fn super_literal(&mut self,
literal
:
&
$
(
$mutability
)
*
Literal
<
'tcx
>
,
location
:
Location
)
{
match
*
literal
{
Literal
::
Item
{
ref
$
(
$mutability
)
*
def_id
,
ref
$
(
$mutability
)
*
substs
}
=>
{
self
.visit_def_id
(
def_id
,
location
);
self
.visit_substs
(
substs
,
location
);
}
Literal
::
Value
{
ref
$
(
$mutability
)
*
value
}
=>
{
self
.visit_const
(
value
,
location
);
}
...
...
src/librustc_mir/hair/cx/expr.rs
浏览文件 @
57ebd28f
...
...
@@ -643,9 +643,11 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
Def
::
Const
(
def_id
)
|
Def
::
AssociatedConst
(
def_id
)
=>
ExprKind
::
Literal
{
literal
:
Literal
::
Item
{
def_id
,
substs
,
literal
:
Literal
::
Value
{
value
:
cx
.tcx
.mk_const
(
ty
::
Const
{
val
:
ConstVal
::
Unevaluated
(
def_id
,
substs
),
ty
:
cx
.tables
()
.node_id_to_type
(
expr
.hir_id
)
}),
},
},
...
...
src/librustc_mir/transform/qualify_consts.rs
浏览文件 @
57ebd28f
...
...
@@ -20,6 +20,7 @@
use
rustc
::
hir
;
use
rustc
::
hir
::
map
as
hir_map
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
middle
::
const_val
::
ConstVal
;
use
rustc
::
traits
::{
self
,
Reveal
};
use
rustc
::
ty
::{
self
,
TyCtxt
,
Ty
,
TypeFoldable
};
use
rustc
::
ty
::
cast
::
CastTy
;
...
...
@@ -622,10 +623,12 @@ fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
}
}
Operand
::
Constant
(
ref
constant
)
=>
{
if
let
Literal
::
Item
{
def_id
,
substs
:
_
}
=
constant
.literal
{
if
let
Literal
::
Value
{
value
:
&
ty
::
Const
{
val
:
ConstVal
::
Unevaluated
(
def_id
,
_
),
ty
}
}
=
constant
.literal
{
// Don't peek inside trait associated constants.
if
self
.tcx
.trait_of_item
(
def_id
)
.is_some
()
{
self
.add_type
(
constant
.
ty
);
self
.add_type
(
ty
);
}
else
{
let
(
bits
,
_
)
=
self
.tcx
.at
(
constant
.span
)
.mir_const_qualif
(
def_id
);
...
...
@@ -635,7 +638,7 @@ fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
// Just in case the type is more specific than
// the definition, e.g. impl associated const
// with type parameters, take it into account.
self
.qualif
.restrict
(
constant
.
ty
,
self
.tcx
,
self
.param_env
);
self
.qualif
.restrict
(
ty
,
self
.tcx
,
self
.param_env
);
}
// Let `const fn` transitively have destructors,
...
...
src/librustc_passes/mir_stats.rs
浏览文件 @
57ebd28f
...
...
@@ -235,7 +235,6 @@ fn visit_literal(&mut self,
location
:
Location
)
{
self
.record
(
"Literal"
,
literal
);
self
.record
(
match
*
literal
{
Literal
::
Item
{
..
}
=>
"Literal::Item"
,
Literal
::
Value
{
..
}
=>
"Literal::Value"
,
Literal
::
Promoted
{
..
}
=>
"Literal::Promoted"
,
},
literal
);
...
...
src/librustc_trans/collector.rs
浏览文件 @
57ebd28f
...
...
@@ -193,6 +193,7 @@
use
rustc
::
hir
::
map
as
hir_map
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
middle
::
const_val
::
ConstVal
;
use
rustc
::
middle
::
lang_items
::{
ExchangeMallocFnLangItem
};
use
rustc
::
traits
;
use
rustc
::
ty
::
subst
::
Substs
;
...
...
@@ -564,24 +565,17 @@ fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: Location) {
self
.super_rvalue
(
rvalue
,
location
);
}
fn
visit_const
ant
(
&
mut
self
,
constant
:
&
mir
::
Constan
t
<
'tcx
>
,
location
:
Location
)
{
debug!
(
"visiting const
ant
{:?} @ {:?}"
,
*
constant
,
location
);
fn
visit_const
(
&
mut
self
,
constant
:
&&
'tcx
ty
::
Cons
t
<
'tcx
>
,
location
:
Location
)
{
debug!
(
"visiting const {:?} @ {:?}"
,
*
constant
,
location
);
if
let
ty
::
TyFnDef
(
..
)
=
constant
.ty.sty
{
// function definitions are zero-sized, and only generate
// IR when they are called/reified.
self
.super_constant
(
constant
,
location
);
return
}
if
let
mir
::
Literal
::
Item
{
def_id
,
substs
}
=
constant
.literal
{
if
let
ConstVal
::
Unevaluated
(
def_id
,
substs
)
=
constant
.val
{
let
substs
=
self
.scx
.tcx
()
.trans_apply_param_substs
(
self
.param_substs
,
&
substs
);
let
instance
=
monomorphize
::
resolve
(
self
.scx
,
def_id
,
substs
);
collect_neighbours
(
self
.scx
,
instance
,
true
,
self
.output
);
}
self
.super_const
ant
(
constant
,
location
);
self
.super_const
(
constant
);
}
fn
visit_terminator_kind
(
&
mut
self
,
...
...
src/librustc_trans/mir/constant.rs
浏览文件 @
57ebd28f
...
...
@@ -510,16 +510,17 @@ fn const_operand(&self, operand: &mir::Operand<'tcx>, span: Span)
mir
::
Operand
::
Constant
(
ref
constant
)
=>
{
let
ty
=
self
.monomorphize
(
&
constant
.ty
);
match
constant
.literal
.clone
()
{
mir
::
Literal
::
Item
{
def_id
,
substs
}
=>
{
let
substs
=
self
.monomorphize
(
&
substs
);
MirConstContext
::
trans_def
(
self
.ccx
,
def_id
,
substs
,
IndexVec
::
new
())
}
mir
::
Literal
::
Promoted
{
index
}
=>
{
let
mir
=
&
self
.mir.promoted
[
index
];
MirConstContext
::
new
(
self
.ccx
,
mir
,
self
.substs
,
IndexVec
::
new
())
.trans
()
}
mir
::
Literal
::
Value
{
value
}
=>
{
Ok
(
Const
::
from_constval
(
self
.ccx
,
&
value
.val
,
ty
))
if
let
ConstVal
::
Unevaluated
(
def_id
,
substs
)
=
value
.val
{
let
substs
=
self
.monomorphize
(
&
substs
);
MirConstContext
::
trans_def
(
self
.ccx
,
def_id
,
substs
,
IndexVec
::
new
())
}
else
{
Ok
(
Const
::
from_constval
(
self
.ccx
,
&
value
.val
,
ty
))
}
}
}
}
...
...
@@ -960,16 +961,17 @@ pub fn trans_constant(&mut self,
debug!
(
"trans_constant({:?})"
,
constant
);
let
ty
=
self
.monomorphize
(
&
constant
.ty
);
let
result
=
match
constant
.literal
.clone
()
{
mir
::
Literal
::
Item
{
def_id
,
substs
}
=>
{
let
substs
=
self
.monomorphize
(
&
substs
);
MirConstContext
::
trans_def
(
bcx
.ccx
,
def_id
,
substs
,
IndexVec
::
new
())
}
mir
::
Literal
::
Promoted
{
index
}
=>
{
let
mir
=
&
self
.mir.promoted
[
index
];
MirConstContext
::
new
(
bcx
.ccx
,
mir
,
self
.param_substs
,
IndexVec
::
new
())
.trans
()
}
mir
::
Literal
::
Value
{
value
}
=>
{
Ok
(
Const
::
from_constval
(
bcx
.ccx
,
&
value
.val
,
ty
))
if
let
ConstVal
::
Unevaluated
(
def_id
,
substs
)
=
value
.val
{
let
substs
=
self
.monomorphize
(
&
substs
);
MirConstContext
::
trans_def
(
bcx
.ccx
,
def_id
,
substs
,
IndexVec
::
new
())
}
else
{
Ok
(
Const
::
from_constval
(
bcx
.ccx
,
&
value
.val
,
ty
))
}
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录