Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
eace240e
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,发现更多精彩内容 >>
提交
eace240e
编写于
2月 14, 2021
作者:
H
Henry Boisdequin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use option<PlaceRef<'tcx>> to clean up mir code a little
上级
1279b3b9
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
13 deletion
+12
-13
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/mir/mod.rs
+2
-4
compiler/rustc_mir/src/transform/check_consts/validation.rs
compiler/rustc_mir/src/transform/check_consts/validation.rs
+10
-9
未找到文件。
compiler/rustc_middle/src/mir/mod.rs
浏览文件 @
eace240e
...
...
@@ -962,8 +962,7 @@ pub fn can_be_made_mutable(&self) -> bool {
opt_ty_info
:
_
,
opt_match_place
:
_
,
pat_span
:
_
,
})
|
BindingForm
::
ImplicitSelf
(
ImplicitSelfKind
::
Imm
),
})
|
BindingForm
::
ImplicitSelf
(
ImplicitSelfKind
::
Imm
),
)))
)
}
...
...
@@ -980,8 +979,7 @@ pub fn is_nonref_binding(&self) -> bool {
opt_ty_info
:
_
,
opt_match_place
:
_
,
pat_span
:
_
,
})
|
BindingForm
::
ImplicitSelf
(
_
),
})
|
BindingForm
::
ImplicitSelf
(
_
),
)))
)
}
...
...
compiler/rustc_mir/src/transform/check_consts/validation.rs
浏览文件 @
eace240e
...
...
@@ -492,7 +492,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
// Special-case reborrows to be more like a copy of a reference.
match
*
rvalue
{
Rvalue
::
Ref
(
_
,
kind
,
place
)
=>
{
if
let
Some
(
reborrowed_proj
)
=
place_as_reborrow
(
self
.tcx
,
self
.body
,
place
)
{
if
let
Some
(
place_ref
)
=
place_as_reborrow
(
self
.tcx
,
self
.body
,
place
)
{
let
ctx
=
match
kind
{
BorrowKind
::
Shared
=>
{
PlaceContext
::
NonMutatingUse
(
NonMutatingUseContext
::
SharedBorrow
)
...
...
@@ -508,12 +508,12 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
}
};
self
.visit_local
(
&
place
.local
,
ctx
,
location
);
self
.visit_projection
(
place
.local
,
reborrowed_proj
,
ctx
,
location
);
self
.visit_projection
(
place
.local
,
place_ref
.projection
,
ctx
,
location
);
return
;
}
}
Rvalue
::
AddressOf
(
mutbl
,
place
)
=>
{
if
let
Some
(
reborrowed_proj
)
=
place_as_reborrow
(
self
.tcx
,
self
.body
,
place
)
{
if
let
Some
(
place_ref
)
=
place_as_reborrow
(
self
.tcx
,
self
.body
,
place
)
{
let
ctx
=
match
mutbl
{
Mutability
::
Not
=>
{
PlaceContext
::
NonMutatingUse
(
NonMutatingUseContext
::
AddressOf
)
...
...
@@ -521,7 +521,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
Mutability
::
Mut
=>
PlaceContext
::
MutatingUse
(
MutatingUseContext
::
AddressOf
),
};
self
.visit_local
(
&
place
.local
,
ctx
,
location
);
self
.visit_projection
(
place
.local
,
reborrowed_proj
,
ctx
,
location
);
self
.visit_projection
(
place
.local
,
place_ref
.projection
,
ctx
,
location
);
return
;
}
}
...
...
@@ -1016,7 +1016,7 @@ fn place_as_reborrow(
tcx
:
TyCtxt
<
'tcx
>
,
body
:
&
Body
<
'tcx
>
,
place
:
Place
<
'tcx
>
,
)
->
Option
<
&
'a
[
PlaceElem
<
'tcx
>
]
>
{
)
->
Option
<
PlaceRef
<
'tcx
>
>
{
match
place
.as_ref
()
.last_projection
()
{
Some
((
place_base
,
ProjectionElem
::
Deref
))
=>
{
// A borrow of a `static` also looks like `&(*_1)` in the MIR, but `_1` is a `const`
...
...
@@ -1025,13 +1025,14 @@ fn place_as_reborrow(
None
}
else
{
// Ensure the type being derefed is a reference and not a raw pointer.
//
// This is sufficient to prevent an access to a `static mut` from being marked as a
// reborrow, even if the check above were to disappear.
let
inner_ty
=
place_base
.ty
(
body
,
tcx
)
.ty
;
match
inner_ty
.kind
()
{
ty
::
Ref
(
..
)
=>
Some
(
place_base
.projection
),
_
=>
None
,
if
let
ty
::
Ref
(
..
)
=
inner_ty
.kind
()
{
return
Some
(
place_base
);
}
else
{
return
None
;
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录