Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
810dbf77
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,发现更多精彩内容 >>
提交
810dbf77
编写于
5月 23, 2020
作者:
B
Bastian Kauschke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
take mir::PlaceElem by value
上级
da57cedd
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
58 addition
and
58 deletion
+58
-58
src/librustc_codegen_ssa/mir/analyze.rs
src/librustc_codegen_ssa/mir/analyze.rs
+2
-2
src/librustc_codegen_ssa/mir/place.rs
src/librustc_codegen_ssa/mir/place.rs
+7
-7
src/librustc_middle/mir/tcx.rs
src/librustc_middle/mir/tcx.rs
+3
-3
src/librustc_middle/mir/visit.rs
src/librustc_middle/mir/visit.rs
+8
-8
src/librustc_mir/borrow_check/places_conflict.rs
src/librustc_mir/borrow_check/places_conflict.rs
+9
-9
src/librustc_mir/borrow_check/renumber.rs
src/librustc_mir/borrow_check/renumber.rs
+4
-4
src/librustc_mir/borrow_check/type_check/mod.rs
src/librustc_mir/borrow_check/type_check/mod.rs
+3
-3
src/librustc_mir/dataflow/drop_flag_effects.rs
src/librustc_mir/dataflow/drop_flag_effects.rs
+2
-2
src/librustc_mir/dataflow/move_paths/builder.rs
src/librustc_mir/dataflow/move_paths/builder.rs
+3
-3
src/librustc_mir/interpret/operand.rs
src/librustc_mir/interpret/operand.rs
+3
-3
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/place.rs
+4
-4
src/librustc_mir/transform/check_consts/qualifs.rs
src/librustc_mir/transform/check_consts/qualifs.rs
+2
-2
src/librustc_mir/transform/check_consts/validation.rs
src/librustc_mir/transform/check_consts/validation.rs
+1
-1
src/librustc_mir/transform/elaborate_drops.rs
src/librustc_mir/transform/elaborate_drops.rs
+5
-5
src/librustc_mir/transform/promote_consts.rs
src/librustc_mir/transform/promote_consts.rs
+2
-2
未找到文件。
src/librustc_codegen_ssa/mir/analyze.rs
浏览文件 @
810dbf77
...
...
@@ -104,7 +104,7 @@ fn process_place(
)
{
let
cx
=
self
.fx.cx
;
if
let
[
proj_base
@
..
,
elem
]
=
place_ref
.projection
{
if
let
&
[
ref
proj_base
@
..
,
elem
]
=
place_ref
.projection
{
let
mut
base_context
=
if
context
.is_mutating_use
()
{
PlaceContext
::
MutatingUse
(
MutatingUseContext
::
Projection
)
}
else
{
...
...
@@ -186,7 +186,7 @@ fn process_place(
// now that we have moved to the "slice of projections" representation.
if
let
mir
::
ProjectionElem
::
Index
(
local
)
=
elem
{
self
.visit_local
(
local
,
&
local
,
PlaceContext
::
NonMutatingUse
(
NonMutatingUseContext
::
Copy
),
location
,
);
...
...
src/librustc_codegen_ssa/mir/place.rs
浏览文件 @
810dbf77
...
...
@@ -429,7 +429,7 @@ pub fn codegen_place(
self
.codegen_consume
(
bx
,
mir
::
PlaceRef
{
local
,
projection
:
proj_base
})
.deref
(
bx
.cx
())
}
mir
::
PlaceRef
{
local
,
projection
:
[
proj_base
@
..
,
elem
]
}
=>
{
mir
::
PlaceRef
{
local
,
projection
:
&
[
ref
proj_base
@
..
,
elem
]
}
=>
{
// FIXME turn this recursion into iteration
let
cg_base
=
self
.codegen_place
(
bx
,
mir
::
PlaceRef
{
local
,
projection
:
proj_base
});
...
...
@@ -440,7 +440,7 @@ pub fn codegen_place(
cg_base
.project_field
(
bx
,
field
.index
())
}
mir
::
ProjectionElem
::
Index
(
index
)
=>
{
let
index
=
&
mir
::
Operand
::
Copy
(
mir
::
Place
::
from
(
*
index
));
let
index
=
&
mir
::
Operand
::
Copy
(
mir
::
Place
::
from
(
index
));
let
index
=
self
.codegen_operand
(
bx
,
index
);
let
llindex
=
index
.immediate
();
cg_base
.project_index
(
bx
,
llindex
)
...
...
@@ -450,7 +450,7 @@ pub fn codegen_place(
from_end
:
false
,
min_length
:
_
,
}
=>
{
let
lloffset
=
bx
.cx
()
.const_usize
(
*
offset
as
u64
);
let
lloffset
=
bx
.cx
()
.const_usize
(
offset
as
u64
);
cg_base
.project_index
(
bx
,
lloffset
)
}
mir
::
ProjectionElem
::
ConstantIndex
{
...
...
@@ -458,14 +458,14 @@ pub fn codegen_place(
from_end
:
true
,
min_length
:
_
,
}
=>
{
let
lloffset
=
bx
.cx
()
.const_usize
(
*
offset
as
u64
);
let
lloffset
=
bx
.cx
()
.const_usize
(
offset
as
u64
);
let
lllen
=
cg_base
.len
(
bx
.cx
());
let
llindex
=
bx
.sub
(
lllen
,
lloffset
);
cg_base
.project_index
(
bx
,
llindex
)
}
mir
::
ProjectionElem
::
Subslice
{
from
,
to
,
from_end
}
=>
{
let
mut
subslice
=
cg_base
.project_index
(
bx
,
bx
.cx
()
.const_usize
(
*
from
as
u64
));
cg_base
.project_index
(
bx
,
bx
.cx
()
.const_usize
(
from
as
u64
));
let
projected_ty
=
PlaceTy
::
from_ty
(
cg_base
.layout.ty
)
.projection_ty
(
tcx
,
elem
)
.ty
;
subslice
.layout
=
bx
.cx
()
.layout_of
(
self
.monomorphize
(
&
projected_ty
));
...
...
@@ -474,7 +474,7 @@ pub fn codegen_place(
assert
!
(
from_end
,
"slice subslices should be `from_end`"
);
subslice
.llextra
=
Some
(
bx
.sub
(
cg_base
.llextra
.unwrap
(),
bx
.cx
()
.const_usize
((
*
from
as
u64
)
+
(
*
to
as
u64
)),
bx
.cx
()
.const_usize
((
from
as
u64
)
+
(
to
as
u64
)),
));
}
...
...
@@ -487,7 +487,7 @@ pub fn codegen_place(
subslice
}
mir
::
ProjectionElem
::
Downcast
(
_
,
v
)
=>
cg_base
.project_downcast
(
bx
,
*
v
),
mir
::
ProjectionElem
::
Downcast
(
_
,
v
)
=>
cg_base
.project_downcast
(
bx
,
v
),
}
}
};
...
...
src/librustc_middle/mir/tcx.rs
浏览文件 @
810dbf77
...
...
@@ -56,8 +56,8 @@ pub fn field_ty(self, tcx: TyCtxt<'tcx>, f: &Field) -> Ty<'tcx> {
/// Convenience wrapper around `projection_ty_core` for
/// `PlaceElem`, where we can just use the `Ty` that is already
/// stored inline on field projection elems.
pub
fn
projection_ty
(
self
,
tcx
:
TyCtxt
<
'tcx
>
,
elem
:
&
PlaceElem
<
'tcx
>
)
->
PlaceTy
<
'tcx
>
{
self
.projection_ty_core
(
tcx
,
ty
::
ParamEnv
::
empty
(),
elem
,
|
_
,
_
,
ty
|
ty
)
pub
fn
projection_ty
(
self
,
tcx
:
TyCtxt
<
'tcx
>
,
elem
:
PlaceElem
<
'tcx
>
)
->
PlaceTy
<
'tcx
>
{
self
.projection_ty_core
(
tcx
,
ty
::
ParamEnv
::
empty
(),
&
elem
,
|
_
,
_
,
ty
|
ty
)
}
/// `place_ty.projection_ty_core(tcx, elem, |...| { ... })`
...
...
@@ -124,7 +124,7 @@ pub fn ty_from<D>(
{
projection
.iter
()
.fold
(
PlaceTy
::
from_ty
(
local_decls
.local_decls
()[
local
]
.ty
),
|
place_ty
,
elem
|
{
.fold
(
PlaceTy
::
from_ty
(
local_decls
.local_decls
()[
local
]
.ty
),
|
place_ty
,
&
elem
|
{
place_ty
.projection_ty
(
tcx
,
elem
)
})
}
...
...
src/librustc_middle/mir/visit.rs
浏览文件 @
810dbf77
...
...
@@ -903,7 +903,7 @@ fn process_projection(
let
mut
projection
=
Cow
::
Borrowed
(
projection
);
for
i
in
0
..
projection
.len
()
{
if
let
Some
(
elem
)
=
projection
.get
(
i
)
{
if
let
Some
(
&
elem
)
=
projection
.get
(
i
)
{
if
let
Some
(
elem
)
=
self
.process_projection_elem
(
elem
,
location
)
{
// This converts the borrowed projection into `Cow::Owned(_)` and returns a
// clone of the projection so we can mutate and reintern later.
...
...
@@ -921,19 +921,19 @@ fn process_projection(
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
elem
:
PlaceElem
<
'tcx
>
,
location
:
Location
,
)
->
Option
<
PlaceElem
<
'tcx
>>
{
match
elem
{
PlaceElem
::
Index
(
local
)
=>
{
let
mut
new_local
=
*
local
;
let
mut
new_local
=
local
;
self
.visit_local
(
&
mut
new_local
,
PlaceContext
::
NonMutatingUse
(
NonMutatingUseContext
::
Copy
),
location
,
);
if
new_local
==
*
local
{
None
}
else
{
Some
(
PlaceElem
::
Index
(
new_local
))
}
if
new_local
==
local
{
None
}
else
{
Some
(
PlaceElem
::
Index
(
new_local
))
}
}
PlaceElem
::
Deref
|
PlaceElem
::
Field
(
..
)
...
...
@@ -959,7 +959,7 @@ fn visit_projection_elem(
&
mut
self
,
local
:
Local
,
proj_base
:
&
[
PlaceElem
<
'tcx
>
],
elem
:
&
PlaceElem
<
'tcx
>
,
elem
:
PlaceElem
<
'tcx
>
,
context
:
PlaceContext
,
location
:
Location
,
)
{
...
...
@@ -990,7 +990,7 @@ fn super_projection(
location
:
Location
,
)
{
let
mut
cursor
=
projection
;
while
let
[
proj_base
@
..
,
elem
]
=
cursor
{
while
let
&
[
ref
proj_base
@
..
,
elem
]
=
cursor
{
cursor
=
proj_base
;
self
.visit_projection_elem
(
local
,
cursor
,
elem
,
context
,
location
);
}
...
...
@@ -1000,7 +1000,7 @@ fn super_projection_elem(
&
mut
self
,
_
local
:
Local
,
_
proj_base
:
&
[
PlaceElem
<
'tcx
>
],
elem
:
&
PlaceElem
<
'tcx
>
,
elem
:
PlaceElem
<
'tcx
>
,
_
context
:
PlaceContext
,
location
:
Location
,
)
{
...
...
@@ -1010,7 +1010,7 @@ fn super_projection_elem(
}
ProjectionElem
::
Index
(
local
)
=>
{
self
.visit_local
(
local
,
&
local
,
PlaceContext
::
NonMutatingUse
(
NonMutatingUseContext
::
Copy
),
location
,
);
...
...
src/librustc_mir/borrow_check/places_conflict.rs
浏览文件 @
810dbf77
...
...
@@ -138,7 +138,7 @@ fn place_components_conflict<'tcx>(
}
// loop invariant: borrow_c is always either equal to access_c or disjoint from it.
for
(
i
,
(
borrow_c
,
access_c
))
in
for
(
i
,
(
borrow_c
,
&
access_c
))
in
borrow_place
.projection
.iter
()
.zip
(
access_place
.projection
.iter
())
.enumerate
()
{
debug!
(
"borrow_conflicts_with_place: borrow_c = {:?}"
,
borrow_c
);
...
...
@@ -163,8 +163,8 @@ fn place_components_conflict<'tcx>(
body
,
borrow_local
,
borrow_proj_base
,
&
borrow_c
,
&
access_c
,
borrow_c
,
access_c
,
bias
,
)
{
Overlap
::
Arbitrary
=>
{
...
...
@@ -313,8 +313,8 @@ fn place_projection_conflict<'tcx>(
body
:
&
Body
<
'tcx
>
,
pi1_local
:
Local
,
pi1_proj_base
:
&
[
PlaceElem
<
'tcx
>
],
pi1_elem
:
&
PlaceElem
<
'tcx
>
,
pi2_elem
:
&
PlaceElem
<
'tcx
>
,
pi1_elem
:
PlaceElem
<
'tcx
>
,
pi2_elem
:
PlaceElem
<
'tcx
>
,
bias
:
PlaceConflictBias
,
)
->
Overlap
{
match
(
pi1_elem
,
pi2_elem
)
{
...
...
@@ -420,24 +420,24 @@ fn place_projection_conflict<'tcx>(
}
}
(
&
ProjectionElem
::
ConstantIndex
{
ProjectionElem
::
ConstantIndex
{
offset
:
offset_from_begin
,
min_length
:
min_length1
,
from_end
:
false
,
},
&
ProjectionElem
::
ConstantIndex
{
ProjectionElem
::
ConstantIndex
{
offset
:
offset_from_end
,
min_length
:
min_length2
,
from_end
:
true
,
},
)
|
(
&
ProjectionElem
::
ConstantIndex
{
ProjectionElem
::
ConstantIndex
{
offset
:
offset_from_end
,
min_length
:
min_length1
,
from_end
:
true
,
},
&
ProjectionElem
::
ConstantIndex
{
ProjectionElem
::
ConstantIndex
{
offset
:
offset_from_begin
,
min_length
:
min_length2
,
from_end
:
false
,
...
...
src/librustc_mir/borrow_check/renumber.rs
浏览文件 @
810dbf77
...
...
@@ -66,14 +66,14 @@ fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
fn
process_projection_elem
(
&
mut
self
,
elem
:
&
PlaceElem
<
'tcx
>
,
elem
:
PlaceElem
<
'tcx
>
,
_
:
Location
,
)
->
Option
<
PlaceElem
<
'tcx
>>
{
if
let
PlaceElem
::
Field
(
field
,
ty
)
=
elem
{
let
new_ty
=
self
.renumber_regions
(
ty
);
let
new_ty
=
self
.renumber_regions
(
&
ty
);
if
new_ty
!=
*
ty
{
return
Some
(
PlaceElem
::
Field
(
*
field
,
new_ty
));
if
new_ty
!=
ty
{
return
Some
(
PlaceElem
::
Field
(
field
,
new_ty
));
}
}
...
...
src/librustc_mir/borrow_check/type_check/mod.rs
浏览文件 @
810dbf77
...
...
@@ -497,7 +497,7 @@ fn sanitize_place(
return
PlaceTy
::
from_ty
(
self
.tcx
()
.types.err
);
}
}
place_ty
=
self
.sanitize_projection
(
place_ty
,
&
elem
,
place
,
location
)
place_ty
=
self
.sanitize_projection
(
place_ty
,
elem
,
place
,
location
)
}
if
let
PlaceContext
::
NonMutatingUse
(
NonMutatingUseContext
::
Copy
)
=
context
{
...
...
@@ -611,14 +611,14 @@ fn sanitize_promoted(&mut self, promoted_body: &'b Body<'tcx>, location: Locatio
fn
sanitize_projection
(
&
mut
self
,
base
:
PlaceTy
<
'tcx
>
,
pi
:
&
PlaceElem
<
'tcx
>
,
pi
:
PlaceElem
<
'tcx
>
,
place
:
&
Place
<
'tcx
>
,
location
:
Location
,
)
->
PlaceTy
<
'tcx
>
{
debug!
(
"sanitize_projection: {:?} {:?} {:?}"
,
base
,
pi
,
place
);
let
tcx
=
self
.tcx
();
let
base_ty
=
base
.ty
;
match
*
pi
{
match
pi
{
ProjectionElem
::
Deref
=>
{
let
deref_ty
=
base_ty
.builtin_deref
(
true
);
PlaceTy
::
from_ty
(
deref_ty
.map
(|
t
|
t
.ty
)
.unwrap_or_else
(||
{
...
...
src/librustc_mir/dataflow/drop_flag_effects.rs
浏览文件 @
810dbf77
...
...
@@ -12,12 +12,12 @@ pub fn move_path_children_matching<'tcx, F>(
mut
cond
:
F
,
)
->
Option
<
MovePathIndex
>
where
F
:
FnMut
(
&
mir
::
PlaceElem
<
'tcx
>
)
->
bool
,
F
:
FnMut
(
mir
::
PlaceElem
<
'tcx
>
)
->
bool
,
{
let
mut
next_child
=
move_data
.move_paths
[
path
]
.first_child
;
while
let
Some
(
child_index
)
=
next_child
{
let
move_path_children
=
&
move_data
.move_paths
[
child_index
];
if
let
Some
(
elem
)
=
move_path_children
.place.projection
.last
()
{
if
let
Some
(
&
elem
)
=
move_path_children
.place.projection
.last
()
{
if
cond
(
elem
)
{
return
Some
(
child_index
);
}
...
...
src/librustc_mir/dataflow/move_paths/builder.rs
浏览文件 @
810dbf77
...
...
@@ -158,7 +158,7 @@ fn move_path_for(&mut self, place: Place<'tcx>) -> Result<MovePathIndex, MoveErr
};
if
union_path
.is_none
()
{
base
=
self
.add_move_path
(
base
,
&
elem
,
|
tcx
|
Place
{
base
=
self
.add_move_path
(
base
,
elem
,
|
tcx
|
Place
{
local
:
place
.local
,
projection
:
tcx
.intern_place_elems
(
&
place
.projection
[
..
i
+
1
]),
});
...
...
@@ -176,7 +176,7 @@ fn move_path_for(&mut self, place: Place<'tcx>) -> Result<MovePathIndex, MoveErr
fn
add_move_path
(
&
mut
self
,
base
:
MovePathIndex
,
elem
:
&
PlaceElem
<
'tcx
>
,
elem
:
PlaceElem
<
'tcx
>
,
mk_place
:
impl
FnOnce
(
TyCtxt
<
'tcx
>
)
->
Place
<
'tcx
>
,
)
->
MovePathIndex
{
let
MoveDataBuilder
{
...
...
@@ -485,7 +485,7 @@ fn gather_move(&mut self, place: Place<'tcx>) {
let
elem
=
ProjectionElem
::
ConstantIndex
{
offset
,
min_length
:
len
,
from_end
:
false
};
let
path
=
self
.add_move_path
(
base_path
,
&
elem
,
|
tcx
|
tcx
.mk_place_elem
(
base_place
,
elem
));
self
.add_move_path
(
base_path
,
elem
,
|
tcx
|
tcx
.mk_place_elem
(
base_place
,
elem
));
self
.record_move
(
place
,
path
);
}
}
else
{
...
...
src/librustc_mir/interpret/operand.rs
浏览文件 @
810dbf77
...
...
@@ -400,10 +400,10 @@ pub fn operand_downcast(
pub
fn
operand_projection
(
&
self
,
base
:
OpTy
<
'tcx
,
M
::
PointerTag
>
,
proj_elem
:
&
mir
::
PlaceElem
<
'tcx
>
,
proj_elem
:
mir
::
PlaceElem
<
'tcx
>
,
)
->
InterpResult
<
'tcx
,
OpTy
<
'tcx
,
M
::
PointerTag
>>
{
use
rustc_middle
::
mir
::
ProjectionElem
::
*
;
Ok
(
match
*
proj_elem
{
Ok
(
match
proj_elem
{
Field
(
field
,
_
)
=>
self
.operand_field
(
base
,
field
.index
())
?
,
Downcast
(
_
,
variant
)
=>
self
.operand_downcast
(
base
,
variant
)
?
,
Deref
=>
self
.deref_operand
(
base
)
?
.into
(),
...
...
@@ -466,7 +466,7 @@ pub fn eval_place_to_op(
let
op
=
place
.projection
.iter
()
.try_fold
(
base_op
,
|
op
,
elem
|
self
.operand_projection
(
op
,
&
elem
))
?
;
.try_fold
(
base_op
,
|
op
,
elem
|
self
.operand_projection
(
op
,
elem
))
?
;
trace!
(
"eval_place_to_op: got {:?}"
,
*
op
);
Ok
(
op
)
...
...
src/librustc_mir/interpret/place.rs
浏览文件 @
810dbf77
...
...
@@ -517,10 +517,10 @@ pub(super) fn mplace_downcast(
pub
(
super
)
fn
mplace_projection
(
&
self
,
base
:
MPlaceTy
<
'tcx
,
M
::
PointerTag
>
,
proj_elem
:
&
mir
::
PlaceElem
<
'tcx
>
,
proj_elem
:
mir
::
PlaceElem
<
'tcx
>
,
)
->
InterpResult
<
'tcx
,
MPlaceTy
<
'tcx
,
M
::
PointerTag
>>
{
use
rustc_middle
::
mir
::
ProjectionElem
::
*
;
Ok
(
match
*
proj_elem
{
Ok
(
match
proj_elem
{
Field
(
field
,
_
)
=>
self
.mplace_field
(
base
,
field
.index
())
?
,
Downcast
(
_
,
variant
)
=>
self
.mplace_downcast
(
base
,
variant
)
?
,
Deref
=>
self
.deref_operand
(
base
.into
())
?
,
...
...
@@ -605,10 +605,10 @@ pub fn place_downcast(
pub
fn
place_projection
(
&
mut
self
,
base
:
PlaceTy
<
'tcx
,
M
::
PointerTag
>
,
proj_elem
:
&
mir
::
ProjectionElem
<
mir
::
Local
,
Ty
<
'tcx
>>
,
&
proj_elem
:
&
mir
::
ProjectionElem
<
mir
::
Local
,
Ty
<
'tcx
>>
,
)
->
InterpResult
<
'tcx
,
PlaceTy
<
'tcx
,
M
::
PointerTag
>>
{
use
rustc_middle
::
mir
::
ProjectionElem
::
*
;
Ok
(
match
*
proj_elem
{
Ok
(
match
proj_elem
{
Field
(
field
,
_
)
=>
self
.place_field
(
base
,
field
.index
())
?
,
Downcast
(
_
,
variant
)
=>
self
.place_downcast
(
base
,
variant
)
?
,
Deref
=>
self
.deref_operand
(
self
.place_to_op
(
base
)
?
)
?
.into
(),
...
...
src/librustc_mir/transform/check_consts/qualifs.rs
浏览文件 @
810dbf77
...
...
@@ -206,8 +206,8 @@ pub fn in_place<Q, F>(cx: &ConstCx<'_, 'tcx>, in_local: &mut F, place: PlaceRef<
F
:
FnMut
(
Local
)
->
bool
,
{
let
mut
projection
=
place
.projection
;
while
let
[
ref
proj_base
@
..
,
proj_elem
]
=
projection
{
match
*
proj_elem
{
while
let
&
[
ref
proj_base
@
..
,
proj_elem
]
=
projection
{
match
proj_elem
{
ProjectionElem
::
Index
(
index
)
if
in_local
(
index
)
=>
return
true
,
ProjectionElem
::
Deref
...
...
src/librustc_mir/transform/check_consts/validation.rs
浏览文件 @
810dbf77
...
...
@@ -432,7 +432,7 @@ fn visit_projection_elem(
&
mut
self
,
place_local
:
Local
,
proj_base
:
&
[
PlaceElem
<
'tcx
>
],
elem
:
&
PlaceElem
<
'tcx
>
,
elem
:
PlaceElem
<
'tcx
>
,
context
:
PlaceContext
,
location
:
Location
,
)
{
...
...
src/librustc_mir/transform/elaborate_drops.rs
浏览文件 @
810dbf77
...
...
@@ -213,7 +213,7 @@ fn clear_drop_flag(&mut self, loc: Location, path: Self::Path, mode: DropFlagMod
fn
field_subpath
(
&
self
,
path
:
Self
::
Path
,
field
:
Field
)
->
Option
<
Self
::
Path
>
{
dataflow
::
move_path_children_matching
(
self
.ctxt
.move_data
(),
path
,
|
e
|
match
e
{
ProjectionElem
::
Field
(
idx
,
_
)
=>
*
idx
==
field
,
ProjectionElem
::
Field
(
idx
,
_
)
=>
idx
==
field
,
_
=>
false
,
})
}
...
...
@@ -221,9 +221,9 @@ fn field_subpath(&self, path: Self::Path, field: Field) -> Option<Self::Path> {
fn
array_subpath
(
&
self
,
path
:
Self
::
Path
,
index
:
u32
,
size
:
u32
)
->
Option
<
Self
::
Path
>
{
dataflow
::
move_path_children_matching
(
self
.ctxt
.move_data
(),
path
,
|
e
|
match
e
{
ProjectionElem
::
ConstantIndex
{
offset
,
min_length
,
from_end
}
=>
{
debug_assert!
(
size
==
*
min_length
,
"min_length should be exact for arrays"
);
debug_assert!
(
size
==
min_length
,
"min_length should be exact for arrays"
);
assert
!
(
!
from_end
,
"from_end should not be used for array element ConstantIndex"
);
*
offset
==
index
offset
==
index
}
_
=>
false
,
})
...
...
@@ -231,13 +231,13 @@ fn array_subpath(&self, path: Self::Path, index: u32, size: u32) -> Option<Self:
fn
deref_subpath
(
&
self
,
path
:
Self
::
Path
)
->
Option
<
Self
::
Path
>
{
dataflow
::
move_path_children_matching
(
self
.ctxt
.move_data
(),
path
,
|
e
|
{
*
e
==
ProjectionElem
::
Deref
e
==
ProjectionElem
::
Deref
})
}
fn
downcast_subpath
(
&
self
,
path
:
Self
::
Path
,
variant
:
VariantIdx
)
->
Option
<
Self
::
Path
>
{
dataflow
::
move_path_children_matching
(
self
.ctxt
.move_data
(),
path
,
|
e
|
match
e
{
ProjectionElem
::
Downcast
(
_
,
idx
)
=>
*
idx
==
variant
,
ProjectionElem
::
Downcast
(
_
,
idx
)
=>
idx
==
variant
,
_
=>
false
,
})
}
...
...
src/librustc_mir/transform/promote_consts.rs
浏览文件 @
810dbf77
...
...
@@ -340,7 +340,7 @@ fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
// `let _: &'static _ = &(Cell::new(1), 2).1;`
let
mut
place_projection
=
&
place
.projection
[
..
];
// FIXME(eddyb) use a forward loop instead of a reverse one.
while
let
[
proj_base
@
..
,
elem
]
=
place_projection
{
while
let
&
[
ref
proj_base
@
..
,
elem
]
=
place_projection
{
// FIXME(eddyb) this is probably excessive, with
// the exception of `union` member accesses.
let
ty
=
...
...
@@ -676,7 +676,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
if
has_mut_interior
{
let
mut
place_projection
=
place
.projection
;
// FIXME(eddyb) use a forward loop instead of a reverse one.
while
let
[
proj_base
@
..
,
elem
]
=
place_projection
{
while
let
&
[
ref
proj_base
@
..
,
elem
]
=
place_projection
{
// FIXME(eddyb) this is probably excessive, with
// the exception of `union` member accesses.
let
ty
=
Place
::
ty_from
(
place
.local
,
proj_base
,
self
.body
,
self
.tcx
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录