Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6df54628
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,发现更多精彩内容 >>
提交
6df54628
编写于
8月 05, 2023
作者:
O
ouz-a
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup misinformation regarding has_deref
上级
5cbfee54
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
17 deletion
+23
-17
compiler/rustc_codegen_ssa/src/mir/place.rs
compiler/rustc_codegen_ssa/src/mir/place.rs
+1
-1
compiler/rustc_const_eval/src/interpret/step.rs
compiler/rustc_const_eval/src/interpret/step.rs
+1
-1
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/mir/mod.rs
+17
-11
compiler/rustc_mir_dataflow/src/value_analysis.rs
compiler/rustc_mir_dataflow/src/value_analysis.rs
+1
-1
compiler/rustc_mir_transform/src/add_retag.rs
compiler/rustc_mir_transform/src/add_retag.rs
+1
-1
compiler/rustc_mir_transform/src/copy_prop.rs
compiler/rustc_mir_transform/src/copy_prop.rs
+1
-1
src/tools/clippy/clippy_lints/src/dereference.rs
src/tools/clippy/clippy_lints/src/dereference.rs
+1
-1
未找到文件。
compiler/rustc_codegen_ssa/src/mir/place.rs
浏览文件 @
6df54628
...
...
@@ -441,7 +441,7 @@ pub fn codegen_place(
LocalRef
::
Place
(
place
)
=>
place
,
LocalRef
::
UnsizedPlace
(
place
)
=>
bx
.load_operand
(
place
)
.deref
(
cx
),
LocalRef
::
Operand
(
..
)
=>
{
if
place_ref
.
has_deref
()
{
if
place_ref
.
is_indirect_first_projection
()
{
base
=
1
;
let
cg_base
=
self
.codegen_consume
(
bx
,
...
...
compiler/rustc_const_eval/src/interpret/step.rs
浏览文件 @
6df54628
...
...
@@ -248,7 +248,7 @@ pub fn eval_rvalue_into_place(
AddressOf
(
_
,
place
)
=>
{
// Figure out whether this is an addr_of of an already raw place.
let
place_base_raw
=
if
place
.
has_deref
()
{
let
place_base_raw
=
if
place
.
is_indirect_first_projection
()
{
let
ty
=
self
.frame
()
.body.local_decls
[
place
.local
]
.ty
;
ty
.is_unsafe_ptr
()
}
else
{
...
...
compiler/rustc_middle/src/mir/mod.rs
浏览文件 @
6df54628
...
...
@@ -1592,14 +1592,13 @@ pub fn is_indirect(&self) -> bool {
self
.projection
.iter
()
.any
(|
elem
|
elem
.is_indirect
())
}
/// If MirPhase >= Derefered and if projection contains Deref,
/// It's guaranteed to be in the first place
pub
fn
has_deref
(
&
self
)
->
bool
{
// To make sure this is not accidentally used in wrong mir phase
debug_assert!
(
self
.projection
.is_empty
()
||
!
self
.projection
[
1
..
]
.contains
(
&
PlaceElem
::
Deref
)
);
self
.projection
.first
()
==
Some
(
&
PlaceElem
::
Deref
)
/// Returns `true` if this `Place`'s first projection is `Deref`.
///
/// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later,
/// `Deref` projections can only occur as the first projection. In that case this method
/// is equivalent to `is_indirect`, but faster.
pub
fn
is_indirect_first_projection
(
&
self
)
->
bool
{
self
.as_ref
()
.is_indirect_first_projection
()
}
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or
...
...
@@ -1672,9 +1671,16 @@ pub fn is_indirect(&self) -> bool {
self
.projection
.iter
()
.any
(|
elem
|
elem
.is_indirect
())
}
/// If MirPhase >= Derefered and if projection contains Deref,
/// It's guaranteed to be in the first place
pub
fn
has_deref
(
&
self
)
->
bool
{
/// Returns `true` if this `Place`'s first projection is `Deref`.
///
/// This is useful because for MIR phases `AnalysisPhase::PostCleanup` and later,
/// `Deref` projections can only occur as the first projection. In that case this method
/// is equivalent to `is_indirect`, but faster.
pub
fn
is_indirect_first_projection
(
&
self
)
->
bool
{
// To make sure this is not accidentally used in wrong mir phase
debug_assert!
(
self
.projection
.is_empty
()
||
!
self
.projection
[
1
..
]
.contains
(
&
PlaceElem
::
Deref
)
);
self
.projection
.first
()
==
Some
(
&
PlaceElem
::
Deref
)
}
...
...
compiler/rustc_mir_dataflow/src/value_analysis.rs
浏览文件 @
6df54628
...
...
@@ -839,7 +839,7 @@ fn for_each_aliasing_place(
tail_elem
:
Option
<
TrackElem
>
,
f
:
&
mut
impl
FnMut
(
ValueIndex
),
)
{
if
place
.
has_deref
()
{
if
place
.
is_indirect_first_projection
()
{
// We do not track indirect places.
return
;
}
...
...
compiler/rustc_mir_transform/src/add_retag.rs
浏览文件 @
6df54628
...
...
@@ -60,7 +60,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let
basic_blocks
=
body
.basic_blocks
.as_mut
();
let
local_decls
=
&
body
.local_decls
;
let
needs_retag
=
|
place
:
&
Place
<
'tcx
>
|
{
!
place
.
has_deref
()
// we're not really interested in stores to "outside" locations, they are hard to keep track of anyway
!
place
.
is_indirect_first_projection
()
// we're not really interested in stores to "outside" locations, they are hard to keep track of anyway
&&
may_contain_reference
(
place
.ty
(
&*
local_decls
,
tcx
)
.ty
,
/*depth*/
3
,
tcx
)
&&
!
local_decls
[
place
.local
]
.is_deref_temp
()
};
...
...
compiler/rustc_mir_transform/src/copy_prop.rs
浏览文件 @
6df54628
...
...
@@ -154,7 +154,7 @@ fn visit_place(&mut self, place: &mut Place<'tcx>, ctxt: PlaceContext, loc: Loca
fn
visit_operand
(
&
mut
self
,
operand
:
&
mut
Operand
<
'tcx
>
,
loc
:
Location
)
{
if
let
Operand
::
Move
(
place
)
=
*
operand
// A move out of a projection of a copy is equivalent to a copy of the original projection.
&&
!
place
.
has_deref
()
&&
!
place
.
is_indirect_first_projection
()
&&
!
self
.fully_moved
.contains
(
place
.local
)
{
*
operand
=
Operand
::
Copy
(
place
);
...
...
src/tools/clippy/clippy_lints/src/dereference.rs
浏览文件 @
6df54628
...
...
@@ -1170,7 +1170,7 @@ fn referent_used_exactly_once<'tcx>(
&&
let
[
location
]
=
*
local_assignments
(
mir
,
local
)
.as_slice
()
&&
let
Some
(
statement
)
=
mir
.basic_blocks
[
location
.block
]
.statements
.get
(
location
.statement_index
)
&&
let
StatementKind
::
Assign
(
box
(
_
,
Rvalue
::
Ref
(
_
,
_
,
place
)))
=
statement
.kind
&&
!
place
.
has_deref
()
&&
!
place
.
is_indirect_first_projection
()
// Ensure not in a loop (https://github.com/rust-lang/rust-clippy/issues/9710)
&&
TriColorDepthFirstSearch
::
new
(
&
mir
.basic_blocks
)
.run_from
(
location
.block
,
&
mut
CycleDetector
)
.is_none
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录