Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c38da2e0
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
c38da2e0
编写于
9月 06, 2021
作者:
G
Gary Guo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce `Rvalue::ShallowInitBox`
上级
308dffd2
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
68 addition
and
11 deletion
+68
-11
compiler/rustc_borrowck/src/invalidation.rs
compiler/rustc_borrowck/src/invalidation.rs
+2
-1
compiler/rustc_borrowck/src/lib.rs
compiler/rustc_borrowck/src/lib.rs
+2
-1
compiler/rustc_borrowck/src/type_check/mod.rs
compiler/rustc_borrowck/src/type_check/mod.rs
+2
-7
compiler/rustc_codegen_cranelift/src/base.rs
compiler/rustc_codegen_cranelift/src/base.rs
+7
-0
compiler/rustc_codegen_ssa/src/mir/rvalue.rs
compiler/rustc_codegen_ssa/src/mir/rvalue.rs
+13
-0
compiler/rustc_const_eval/src/interpret/step.rs
compiler/rustc_const_eval/src/interpret/step.rs
+6
-0
compiler/rustc_const_eval/src/transform/check_consts/check.rs
...iler/rustc_const_eval/src/transform/check_consts/check.rs
+1
-0
compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs
...er/rustc_const_eval/src/transform/check_consts/qualifs.rs
+2
-1
compiler/rustc_const_eval/src/transform/promote_consts.rs
compiler/rustc_const_eval/src/transform/promote_consts.rs
+2
-0
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/mir/mod.rs
+10
-0
compiler/rustc_middle/src/mir/tcx.rs
compiler/rustc_middle/src/mir/tcx.rs
+4
-1
compiler/rustc_middle/src/mir/type_foldable.rs
compiler/rustc_middle/src/mir/type_foldable.rs
+5
-0
compiler/rustc_middle/src/mir/visit.rs
compiler/rustc_middle/src/mir/visit.rs
+5
-0
compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
+1
-0
compiler/rustc_mir_dataflow/src/move_paths/builder.rs
compiler/rustc_mir_dataflow/src/move_paths/builder.rs
+1
-0
compiler/rustc_mir_transform/src/const_prop.rs
compiler/rustc_mir_transform/src/const_prop.rs
+1
-0
compiler/rustc_mir_transform/src/dest_prop.rs
compiler/rustc_mir_transform/src/dest_prop.rs
+1
-0
compiler/rustc_mir_transform/src/separate_const_switch.rs
compiler/rustc_mir_transform/src/separate_const_switch.rs
+2
-0
src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
+1
-0
未找到文件。
compiler/rustc_borrowck/src/invalidation.rs
浏览文件 @
c38da2e0
...
@@ -316,7 +316,8 @@ fn consume_rvalue(&mut self, location: Location, rvalue: &Rvalue<'tcx>) {
...
@@ -316,7 +316,8 @@ fn consume_rvalue(&mut self, location: Location, rvalue: &Rvalue<'tcx>) {
Rvalue
::
Use
(
ref
operand
)
Rvalue
::
Use
(
ref
operand
)
|
Rvalue
::
Repeat
(
ref
operand
,
_
)
|
Rvalue
::
Repeat
(
ref
operand
,
_
)
|
Rvalue
::
UnaryOp
(
_
/*un_op*/
,
ref
operand
)
|
Rvalue
::
UnaryOp
(
_
/*un_op*/
,
ref
operand
)
|
Rvalue
::
Cast
(
_
/*cast_kind*/
,
ref
operand
,
_
/*ty*/
)
=>
{
|
Rvalue
::
Cast
(
_
/*cast_kind*/
,
ref
operand
,
_
/*ty*/
)
|
Rvalue
::
ShallowInitBox
(
ref
operand
,
_
/*ty*/
)
=>
{
self
.consume_operand
(
location
,
operand
)
self
.consume_operand
(
location
,
operand
)
}
}
...
...
compiler/rustc_borrowck/src/lib.rs
浏览文件 @
c38da2e0
...
@@ -1361,7 +1361,8 @@ fn consume_rvalue(
...
@@ -1361,7 +1361,8 @@ fn consume_rvalue(
Rvalue
::
Use
(
ref
operand
)
Rvalue
::
Use
(
ref
operand
)
|
Rvalue
::
Repeat
(
ref
operand
,
_
)
|
Rvalue
::
Repeat
(
ref
operand
,
_
)
|
Rvalue
::
UnaryOp
(
_
/*un_op*/
,
ref
operand
)
|
Rvalue
::
UnaryOp
(
_
/*un_op*/
,
ref
operand
)
|
Rvalue
::
Cast
(
_
/*cast_kind*/
,
ref
operand
,
_
/*ty*/
)
=>
{
|
Rvalue
::
Cast
(
_
/*cast_kind*/
,
ref
operand
,
_
/*ty*/
)
|
Rvalue
::
ShallowInitBox
(
ref
operand
,
_
/*ty*/
)
=>
{
self
.consume_operand
(
location
,
(
operand
,
span
),
flow_state
)
self
.consume_operand
(
location
,
(
operand
,
span
),
flow_state
)
}
}
...
...
compiler/rustc_borrowck/src/type_check/mod.rs
浏览文件 @
c38da2e0
...
@@ -2018,13 +2018,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
...
@@ -2018,13 +2018,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
}
}
}
}
Rvalue
::
NullaryOp
(
_
,
ty
)
=>
{
Rvalue
::
NullaryOp
(
_
,
ty
)
|
Rvalue
::
ShallowInitBox
(
_
,
ty
)
=>
{
// Even with unsized locals cannot box an unsized value.
if
self
.unsized_feature_enabled
()
{
let
span
=
body
.source_info
(
location
)
.span
;
self
.ensure_place_sized
(
ty
,
span
);
}
let
trait_ref
=
ty
::
TraitRef
{
let
trait_ref
=
ty
::
TraitRef
{
def_id
:
tcx
.require_lang_item
(
LangItem
::
Sized
,
Some
(
self
.last_span
)),
def_id
:
tcx
.require_lang_item
(
LangItem
::
Sized
,
Some
(
self
.last_span
)),
substs
:
tcx
.mk_substs_trait
(
ty
,
&
[]),
substs
:
tcx
.mk_substs_trait
(
ty
,
&
[]),
...
@@ -2357,6 +2351,7 @@ fn rvalue_user_ty(&self, rvalue: &Rvalue<'tcx>) -> Option<UserTypeAnnotationInde
...
@@ -2357,6 +2351,7 @@ fn rvalue_user_ty(&self, rvalue: &Rvalue<'tcx>) -> Option<UserTypeAnnotationInde
|
Rvalue
::
AddressOf
(
..
)
|
Rvalue
::
AddressOf
(
..
)
|
Rvalue
::
Len
(
..
)
|
Rvalue
::
Len
(
..
)
|
Rvalue
::
Cast
(
..
)
|
Rvalue
::
Cast
(
..
)
|
Rvalue
::
ShallowInitBox
(
..
)
|
Rvalue
::
BinaryOp
(
..
)
|
Rvalue
::
BinaryOp
(
..
)
|
Rvalue
::
CheckedBinaryOp
(
..
)
|
Rvalue
::
CheckedBinaryOp
(
..
)
|
Rvalue
::
NullaryOp
(
..
)
|
Rvalue
::
NullaryOp
(
..
)
...
...
compiler/rustc_codegen_cranelift/src/base.rs
浏览文件 @
c38da2e0
...
@@ -701,6 +701,13 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
...
@@ -701,6 +701,13 @@ fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
let
len
=
codegen_array_len
(
fx
,
place
);
let
len
=
codegen_array_len
(
fx
,
place
);
lval
.write_cvalue
(
fx
,
CValue
::
by_val
(
len
,
usize_layout
));
lval
.write_cvalue
(
fx
,
CValue
::
by_val
(
len
,
usize_layout
));
}
}
Rvalue
::
ShallowInitBox
(
ref
operand
,
content_ty
)
=>
{
let
content_ty
=
fx
.monomorphize
(
content_ty
);
let
box_layout
=
fx
.layout_of
(
fx
.tcx
.mk_box
(
content_ty
));
let
operand
=
codegen_operand
(
fx
,
operand
);
let
operand
=
operand
.load_scalar
(
fx
);
lval
.write_cvalue
(
fx
,
CValue
::
by_val
(
operand
,
box_layout
));
}
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
content_ty
)
=>
{
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
content_ty
)
=>
{
let
usize_type
=
fx
.clif_type
(
fx
.tcx.types.usize
)
.unwrap
();
let
usize_type
=
fx
.clif_type
(
fx
.tcx.types.usize
)
.unwrap
();
let
content_ty
=
fx
.monomorphize
(
content_ty
);
let
content_ty
=
fx
.monomorphize
(
content_ty
);
...
...
compiler/rustc_codegen_ssa/src/mir/rvalue.rs
浏览文件 @
c38da2e0
...
@@ -550,6 +550,18 @@ pub fn codegen_rvalue_operand(
...
@@ -550,6 +550,18 @@ pub fn codegen_rvalue_operand(
OperandRef
::
new_zst
(
&
mut
bx
,
self
.cx
.layout_of
(
self
.monomorphize
(
ty
)));
OperandRef
::
new_zst
(
&
mut
bx
,
self
.cx
.layout_of
(
self
.monomorphize
(
ty
)));
(
bx
,
operand
)
(
bx
,
operand
)
}
}
mir
::
Rvalue
::
ShallowInitBox
(
ref
operand
,
content_ty
)
=>
{
let
operand
=
self
.codegen_operand
(
&
mut
bx
,
operand
);
let
lloperand
=
operand
.immediate
();
let
content_ty
=
self
.monomorphize
(
content_ty
);
let
box_layout
=
bx
.cx
()
.layout_of
(
bx
.tcx
()
.mk_box
(
content_ty
));
let
llty_ptr
=
bx
.cx
()
.backend_type
(
box_layout
);
let
val
=
bx
.pointercast
(
lloperand
,
llty_ptr
);
let
operand
=
OperandRef
{
val
:
OperandValue
::
Immediate
(
val
),
layout
:
box_layout
};
(
bx
,
operand
)
}
}
}
}
}
...
@@ -763,6 +775,7 @@ pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) ->
...
@@ -763,6 +775,7 @@ pub fn rvalue_creates_operand(&self, rvalue: &mir::Rvalue<'tcx>, span: Span) ->
mir
::
Rvalue
::
AddressOf
(
..
)
|
mir
::
Rvalue
::
AddressOf
(
..
)
|
mir
::
Rvalue
::
Len
(
..
)
|
mir
::
Rvalue
::
Len
(
..
)
|
mir
::
Rvalue
::
Cast
(
..
)
|
// (*)
mir
::
Rvalue
::
Cast
(
..
)
|
// (*)
mir
::
Rvalue
::
ShallowInitBox
(
..
)
|
// (*)
mir
::
Rvalue
::
BinaryOp
(
..
)
|
mir
::
Rvalue
::
BinaryOp
(
..
)
|
mir
::
Rvalue
::
CheckedBinaryOp
(
..
)
|
mir
::
Rvalue
::
CheckedBinaryOp
(
..
)
|
mir
::
Rvalue
::
UnaryOp
(
..
)
|
mir
::
Rvalue
::
UnaryOp
(
..
)
|
...
...
compiler/rustc_const_eval/src/interpret/step.rs
浏览文件 @
c38da2e0
...
@@ -289,6 +289,12 @@ pub fn eval_rvalue_into_place(
...
@@ -289,6 +289,12 @@ pub fn eval_rvalue_into_place(
self
.write_scalar
(
Scalar
::
from_machine_usize
(
val
,
self
),
&
dest
)
?
;
self
.write_scalar
(
Scalar
::
from_machine_usize
(
val
,
self
),
&
dest
)
?
;
}
}
ShallowInitBox
(
ref
operand
,
_
)
=>
{
let
src
=
self
.eval_operand
(
operand
,
None
)
?
;
let
v
=
self
.read_immediate
(
&
src
)
?
;
self
.write_immediate
(
*
v
,
&
dest
)
?
;
}
Cast
(
cast_kind
,
ref
operand
,
cast_ty
)
=>
{
Cast
(
cast_kind
,
ref
operand
,
cast_ty
)
=>
{
let
src
=
self
.eval_operand
(
operand
,
None
)
?
;
let
src
=
self
.eval_operand
(
operand
,
None
)
?
;
let
cast_ty
=
self
.subst_from_current_frame_and_normalize_erasing_regions
(
cast_ty
);
let
cast_ty
=
self
.subst_from_current_frame_and_normalize_erasing_regions
(
cast_ty
);
...
...
compiler/rustc_const_eval/src/transform/check_consts/check.rs
浏览文件 @
c38da2e0
...
@@ -650,6 +650,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
...
@@ -650,6 +650,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
Rvalue
::
NullaryOp
(
NullOp
::
SizeOf
|
NullOp
::
AlignOf
,
_
)
=>
{}
Rvalue
::
NullaryOp
(
NullOp
::
SizeOf
|
NullOp
::
AlignOf
,
_
)
=>
{}
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
_
)
=>
self
.check_op
(
ops
::
HeapAllocation
),
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
_
)
=>
self
.check_op
(
ops
::
HeapAllocation
),
Rvalue
::
ShallowInitBox
(
_
,
_
)
=>
{}
Rvalue
::
UnaryOp
(
_
,
ref
operand
)
=>
{
Rvalue
::
UnaryOp
(
_
,
ref
operand
)
=>
{
let
ty
=
operand
.ty
(
self
.body
,
self
.tcx
);
let
ty
=
operand
.ty
(
self
.body
,
self
.tcx
);
...
...
compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs
浏览文件 @
c38da2e0
...
@@ -206,7 +206,8 @@ pub fn in_rvalue<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, rvalue: &Rvalue
...
@@ -206,7 +206,8 @@ pub fn in_rvalue<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, rvalue: &Rvalue
Rvalue
::
Use
(
operand
)
Rvalue
::
Use
(
operand
)
|
Rvalue
::
Repeat
(
operand
,
_
)
|
Rvalue
::
Repeat
(
operand
,
_
)
|
Rvalue
::
UnaryOp
(
_
,
operand
)
|
Rvalue
::
UnaryOp
(
_
,
operand
)
|
Rvalue
::
Cast
(
_
,
operand
,
_
)
=>
in_operand
::
<
Q
,
_
>
(
cx
,
in_local
,
operand
),
|
Rvalue
::
Cast
(
_
,
operand
,
_
)
|
Rvalue
::
ShallowInitBox
(
operand
,
_
)
=>
in_operand
::
<
Q
,
_
>
(
cx
,
in_local
,
operand
),
Rvalue
::
BinaryOp
(
_
,
box
(
lhs
,
rhs
))
|
Rvalue
::
CheckedBinaryOp
(
_
,
box
(
lhs
,
rhs
))
=>
{
Rvalue
::
BinaryOp
(
_
,
box
(
lhs
,
rhs
))
|
Rvalue
::
CheckedBinaryOp
(
_
,
box
(
lhs
,
rhs
))
=>
{
in_operand
::
<
Q
,
_
>
(
cx
,
in_local
,
lhs
)
||
in_operand
::
<
Q
,
_
>
(
cx
,
in_local
,
rhs
)
in_operand
::
<
Q
,
_
>
(
cx
,
in_local
,
lhs
)
||
in_operand
::
<
Q
,
_
>
(
cx
,
in_local
,
rhs
)
...
...
compiler/rustc_const_eval/src/transform/promote_consts.rs
浏览文件 @
c38da2e0
...
@@ -523,6 +523,8 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
...
@@ -523,6 +523,8 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
NullOp
::
AlignOf
=>
{}
NullOp
::
AlignOf
=>
{}
},
},
Rvalue
::
ShallowInitBox
(
_
,
_
)
=>
return
Err
(
Unpromotable
),
Rvalue
::
UnaryOp
(
op
,
operand
)
=>
{
Rvalue
::
UnaryOp
(
op
,
operand
)
=>
{
match
op
{
match
op
{
// These operations can never fail.
// These operations can never fail.
...
...
compiler/rustc_middle/src/mir/mod.rs
浏览文件 @
c38da2e0
...
@@ -2200,6 +2200,12 @@ pub enum Rvalue<'tcx> {
...
@@ -2200,6 +2200,12 @@ pub enum Rvalue<'tcx> {
/// that `Foo` has a destructor. These rvalues can be optimized
/// that `Foo` has a destructor. These rvalues can be optimized
/// away after type-checking and before lowering.
/// away after type-checking and before lowering.
Aggregate
(
Box
<
AggregateKind
<
'tcx
>>
,
Vec
<
Operand
<
'tcx
>>
),
Aggregate
(
Box
<
AggregateKind
<
'tcx
>>
,
Vec
<
Operand
<
'tcx
>>
),
/// Transmutes a `*mut u8` into shallow-initialized `Box<T>`.
///
/// This is different a normal transmute because dataflow analysis will treat the box
/// as initialized but its content as uninitialized.
ShallowInitBox
(
Operand
<
'tcx
>
,
Ty
<
'tcx
>
),
}
}
#[cfg(all(target_arch
=
"x86_64"
,
target_pointer_width
=
"64"
))]
#[cfg(all(target_arch
=
"x86_64"
,
target_pointer_width
=
"64"
))]
...
@@ -2450,6 +2456,10 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
...
@@ -2450,6 +2456,10 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
}),
}),
}
}
}
}
ShallowInitBox
(
ref
place
,
ref
ty
)
=>
{
write!
(
fmt
,
"ShallowInitBox({:?}, {:?})"
,
place
,
ty
)
}
}
}
}
}
}
}
...
...
compiler/rustc_middle/src/mir/tcx.rs
浏览文件 @
c38da2e0
...
@@ -206,6 +206,7 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
...
@@ -206,6 +206,7 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
tcx
.mk_generator
(
did
,
substs
,
movability
)
tcx
.mk_generator
(
did
,
substs
,
movability
)
}
}
},
},
Rvalue
::
ShallowInitBox
(
_
,
ty
)
=>
tcx
.mk_box
(
ty
),
}
}
}
}
...
@@ -214,7 +215,9 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
...
@@ -214,7 +215,9 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'tcx>
/// whether its only shallowly initialized (`Rvalue::Box`).
/// whether its only shallowly initialized (`Rvalue::Box`).
pub
fn
initialization_state
(
&
self
)
->
RvalueInitializationState
{
pub
fn
initialization_state
(
&
self
)
->
RvalueInitializationState
{
match
*
self
{
match
*
self
{
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
_
)
=>
RvalueInitializationState
::
Shallow
,
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
_
)
|
Rvalue
::
ShallowInitBox
(
_
,
_
)
=>
{
RvalueInitializationState
::
Shallow
}
_
=>
RvalueInitializationState
::
Deep
,
_
=>
RvalueInitializationState
::
Deep
,
}
}
}
}
...
...
compiler/rustc_middle/src/mir/type_foldable.rs
浏览文件 @
c38da2e0
...
@@ -210,6 +210,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
...
@@ -210,6 +210,7 @@ fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
});
});
Aggregate
(
kind
,
fields
.fold_with
(
folder
))
Aggregate
(
kind
,
fields
.fold_with
(
folder
))
}
}
ShallowInitBox
(
op
,
ty
)
=>
ShallowInitBox
(
op
.fold_with
(
folder
),
ty
.fold_with
(
folder
)),
}
}
}
}
...
@@ -255,6 +256,10 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow
...
@@ -255,6 +256,10 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow
}
}
fields
.visit_with
(
visitor
)
fields
.visit_with
(
visitor
)
}
}
ShallowInitBox
(
ref
op
,
ty
)
=>
{
op
.visit_with
(
visitor
)
?
;
ty
.visit_with
(
visitor
)
}
}
}
}
}
}
}
...
...
compiler/rustc_middle/src/mir/visit.rs
浏览文件 @
c38da2e0
...
@@ -753,6 +753,11 @@ fn super_rvalue(&mut self,
...
@@ -753,6 +753,11 @@ fn super_rvalue(&mut self,
self
.visit_operand
(
operand
,
location
);
self
.visit_operand
(
operand
,
location
);
}
}
}
}
Rvalue
::
ShallowInitBox
(
operand
,
ty
)
=>
{
self
.visit_operand
(
operand
,
location
);
self
.visit_ty
(
ty
,
TyContext
::
Location
(
location
));
}
}
}
}
}
...
...
compiler/rustc_mir_dataflow/src/impls/borrowed_locals.rs
浏览文件 @
c38da2e0
...
@@ -169,6 +169,7 @@ fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: Location) {
...
@@ -169,6 +169,7 @@ fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: Location) {
}
}
mir
::
Rvalue
::
Cast
(
..
)
mir
::
Rvalue
::
Cast
(
..
)
|
mir
::
Rvalue
::
ShallowInitBox
(
..
)
|
mir
::
Rvalue
::
Use
(
..
)
|
mir
::
Rvalue
::
Use
(
..
)
|
mir
::
Rvalue
::
ThreadLocalRef
(
..
)
|
mir
::
Rvalue
::
ThreadLocalRef
(
..
)
|
mir
::
Rvalue
::
Repeat
(
..
)
|
mir
::
Rvalue
::
Repeat
(
..
)
...
...
compiler/rustc_mir_dataflow/src/move_paths/builder.rs
浏览文件 @
c38da2e0
...
@@ -327,6 +327,7 @@ fn gather_rvalue(&mut self, rvalue: &Rvalue<'tcx>) {
...
@@ -327,6 +327,7 @@ fn gather_rvalue(&mut self, rvalue: &Rvalue<'tcx>) {
Rvalue
::
Use
(
ref
operand
)
Rvalue
::
Use
(
ref
operand
)
|
Rvalue
::
Repeat
(
ref
operand
,
_
)
|
Rvalue
::
Repeat
(
ref
operand
,
_
)
|
Rvalue
::
Cast
(
_
,
ref
operand
,
_
)
|
Rvalue
::
Cast
(
_
,
ref
operand
,
_
)
|
Rvalue
::
ShallowInitBox
(
ref
operand
,
_
)
|
Rvalue
::
UnaryOp
(
_
,
ref
operand
)
=>
self
.gather_operand
(
operand
),
|
Rvalue
::
UnaryOp
(
_
,
ref
operand
)
=>
self
.gather_operand
(
operand
),
Rvalue
::
BinaryOp
(
ref
_
binop
,
box
(
ref
lhs
,
ref
rhs
))
Rvalue
::
BinaryOp
(
ref
_
binop
,
box
(
ref
lhs
,
ref
rhs
))
|
Rvalue
::
CheckedBinaryOp
(
ref
_
binop
,
box
(
ref
lhs
,
ref
rhs
))
=>
{
|
Rvalue
::
CheckedBinaryOp
(
ref
_
binop
,
box
(
ref
lhs
,
ref
rhs
))
=>
{
...
...
compiler/rustc_mir_transform/src/const_prop.rs
浏览文件 @
c38da2e0
...
@@ -723,6 +723,7 @@ fn const_prop(
...
@@ -723,6 +723,7 @@ fn const_prop(
|
Rvalue
::
Repeat
(
..
)
|
Rvalue
::
Repeat
(
..
)
|
Rvalue
::
Len
(
..
)
|
Rvalue
::
Len
(
..
)
|
Rvalue
::
Cast
(
..
)
|
Rvalue
::
Cast
(
..
)
|
Rvalue
::
ShallowInitBox
(
..
)
|
Rvalue
::
Discriminant
(
..
)
|
Rvalue
::
Discriminant
(
..
)
|
Rvalue
::
NullaryOp
(
..
)
=>
{}
|
Rvalue
::
NullaryOp
(
..
)
=>
{}
}
}
...
...
compiler/rustc_mir_transform/src/dest_prop.rs
浏览文件 @
c38da2e0
...
@@ -967,6 +967,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
...
@@ -967,6 +967,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
}
}
Rvalue
::
Cast
(
..
)
Rvalue
::
Cast
(
..
)
|
Rvalue
::
ShallowInitBox
(
..
)
|
Rvalue
::
Use
(
..
)
|
Rvalue
::
Use
(
..
)
|
Rvalue
::
Repeat
(
..
)
|
Rvalue
::
Repeat
(
..
)
|
Rvalue
::
Len
(
..
)
|
Rvalue
::
Len
(
..
)
...
...
compiler/rustc_mir_transform/src/separate_const_switch.rs
浏览文件 @
c38da2e0
...
@@ -204,6 +204,7 @@ fn is_likely_const<'tcx>(mut tracked_place: Place<'tcx>, block: &BasicBlockData<
...
@@ -204,6 +204,7 @@ fn is_likely_const<'tcx>(mut tracked_place: Place<'tcx>, block: &BasicBlockData<
|
Rvalue
::
AddressOf
(
_
,
_
)
|
Rvalue
::
AddressOf
(
_
,
_
)
|
Rvalue
::
Cast
(
_
,
Operand
::
Constant
(
_
),
_
)
|
Rvalue
::
Cast
(
_
,
Operand
::
Constant
(
_
),
_
)
|
Rvalue
::
NullaryOp
(
_
,
_
)
|
Rvalue
::
NullaryOp
(
_
,
_
)
|
Rvalue
::
ShallowInitBox
(
_
,
_
)
|
Rvalue
::
UnaryOp
(
_
,
Operand
::
Constant
(
_
))
=>
return
true
,
|
Rvalue
::
UnaryOp
(
_
,
Operand
::
Constant
(
_
))
=>
return
true
,
// These rvalues make things ambiguous
// These rvalues make things ambiguous
...
@@ -301,6 +302,7 @@ fn find_determining_place<'tcx>(
...
@@ -301,6 +302,7 @@ fn find_determining_place<'tcx>(
|
Rvalue
::
ThreadLocalRef
(
_
)
|
Rvalue
::
ThreadLocalRef
(
_
)
|
Rvalue
::
AddressOf
(
_
,
_
)
|
Rvalue
::
AddressOf
(
_
,
_
)
|
Rvalue
::
NullaryOp
(
_
,
_
)
|
Rvalue
::
NullaryOp
(
_
,
_
)
|
Rvalue
::
ShallowInitBox
(
_
,
_
)
|
Rvalue
::
UnaryOp
(
_
,
Operand
::
Constant
(
_
))
|
Rvalue
::
UnaryOp
(
_
,
Operand
::
Constant
(
_
))
|
Rvalue
::
Cast
(
_
,
Operand
::
Constant
(
_
),
_
)
|
Rvalue
::
Cast
(
_
,
Operand
::
Constant
(
_
),
_
)
=>
return
None
,
=>
return
None
,
...
...
src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
浏览文件 @
c38da2e0
...
@@ -194,6 +194,7 @@ fn check_rvalue(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, rvalue: &Rv
...
@@ -194,6 +194,7 @@ fn check_rvalue(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, rvalue: &Rv
},
},
Rvalue
::
NullaryOp
(
NullOp
::
SizeOf
|
NullOp
::
AlignOf
,
_
)
=>
Ok
(()),
Rvalue
::
NullaryOp
(
NullOp
::
SizeOf
|
NullOp
::
AlignOf
,
_
)
=>
Ok
(()),
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
_
)
=>
Err
((
span
,
"heap allocations are not allowed in const fn"
.into
())),
Rvalue
::
NullaryOp
(
NullOp
::
Box
,
_
)
=>
Err
((
span
,
"heap allocations are not allowed in const fn"
.into
())),
Rvalue
::
ShallowInitBox
(
_
,
_
)
=>
Ok
(()),
Rvalue
::
UnaryOp
(
_
,
operand
)
=>
{
Rvalue
::
UnaryOp
(
_
,
operand
)
=>
{
let
ty
=
operand
.ty
(
body
,
tcx
);
let
ty
=
operand
.ty
(
body
,
tcx
);
if
ty
.is_integral
()
||
ty
.is_bool
()
{
if
ty
.is_integral
()
||
ty
.is_bool
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录