Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
a5baea64
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,发现更多精彩内容 >>
提交
a5baea64
编写于
8月 24, 2018
作者:
R
Ralf Jung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
terminator/drop.rs is just one fn... merge it together with the other terminator stuff
上级
aa645f30
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
66 deletion
+46
-66
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/interpret/terminator.rs
+46
-3
src/librustc_mir/interpret/terminator/drop.rs
src/librustc_mir/interpret/terminator/drop.rs
+0
-63
未找到文件。
src/librustc_mir/interpret/terminator
/mod
.rs
→
src/librustc_mir/interpret/terminator.rs
浏览文件 @
a5baea64
...
...
@@ -16,11 +16,9 @@
use
rustc
::
mir
::
interpret
::{
EvalResult
,
Scalar
};
use
super
::{
EvalContext
,
Machine
,
Value
,
OpTy
,
Place
,
PlaceTy
,
ValTy
,
Operand
,
StackPopCleanup
EvalContext
,
Machine
,
Value
,
OpTy
,
Place
,
PlaceTy
,
PlaceExtra
,
ValTy
,
Operand
,
StackPopCleanup
};
mod
drop
;
impl
<
'a
,
'mir
,
'tcx
,
M
:
Machine
<
'mir
,
'tcx
>>
EvalContext
<
'a
,
'mir
,
'tcx
,
M
>
{
#[inline]
pub
fn
goto_block
(
&
mut
self
,
target
:
Option
<
mir
::
BasicBlock
>
)
->
EvalResult
<
'tcx
>
{
...
...
@@ -442,4 +440,49 @@ fn eval_fn_call(
}
}
}
fn
drop_in_place
(
&
mut
self
,
place
:
PlaceTy
<
'tcx
>
,
instance
:
ty
::
Instance
<
'tcx
>
,
span
:
Span
,
target
:
mir
::
BasicBlock
,
)
->
EvalResult
<
'tcx
>
{
trace!
(
"drop_in_place: {:?},
\n
{:?}, {:?}"
,
*
place
,
place
.layout.ty
,
instance
);
// We take the address of the object. This may well be unaligned, which is fine
// for us here. However, unaligned accesses will probably make the actual drop
// implementation fail -- a problem shared by rustc.
let
place
=
self
.force_allocation
(
place
)
?
;
let
(
instance
,
place
)
=
match
place
.layout.ty.sty
{
ty
::
Dynamic
(
..
)
=>
{
// Dropping a trait object.
let
vtable
=
match
place
.extra
{
PlaceExtra
::
Vtable
(
vtable
)
=>
vtable
,
_
=>
bug!
(
"Expected vtable when dropping {:#?}"
,
place
),
};
let
place
=
self
.unpack_unsized_mplace
(
place
)
?
;
let
instance
=
self
.read_drop_type_from_vtable
(
vtable
)
?
;
(
instance
,
place
)
}
_
=>
(
instance
,
place
),
};
let
arg
=
OpTy
{
op
:
Operand
::
Immediate
(
place
.to_ref
(
&
self
)),
layout
:
self
.layout_of
(
self
.tcx
.mk_mut_ptr
(
place
.layout.ty
))
?
,
};
let
ty
=
self
.tcx
.mk_tup
((
&
[]
as
&
[
ty
::
Ty
<
'tcx
>
])
.iter
());
// return type is ()
let
dest
=
PlaceTy
::
null
(
&
self
,
self
.layout_of
(
ty
)
?
);
self
.eval_fn_call
(
instance
,
&
[
arg
],
Some
(
dest
),
Some
(
target
),
span
,
None
,
)
}
}
src/librustc_mir/interpret/terminator/drop.rs
已删除
100644 → 0
浏览文件 @
aa645f30
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use
rustc
::
mir
::
BasicBlock
;
use
rustc
::
ty
::{
self
,
layout
::
LayoutOf
};
use
syntax
::
source_map
::
Span
;
use
rustc
::
mir
::
interpret
::
EvalResult
;
use
interpret
::{
Machine
,
EvalContext
,
PlaceTy
,
PlaceExtra
,
OpTy
,
Operand
};
impl
<
'a
,
'mir
,
'tcx
,
M
:
Machine
<
'mir
,
'tcx
>>
EvalContext
<
'a
,
'mir
,
'tcx
,
M
>
{
pub
(
crate
)
fn
drop_in_place
(
&
mut
self
,
place
:
PlaceTy
<
'tcx
>
,
instance
:
ty
::
Instance
<
'tcx
>
,
span
:
Span
,
target
:
BasicBlock
,
)
->
EvalResult
<
'tcx
>
{
trace!
(
"drop_in_place: {:?},
\n
{:?}, {:?}"
,
*
place
,
place
.layout.ty
,
instance
);
// We take the address of the object. This may well be unaligned, which is fine for us
// here. However, unaligned accesses will probably make the actual drop implementation fail
// -- a problem shared by rustc.
let
place
=
self
.force_allocation
(
place
)
?
;
let
(
instance
,
place
)
=
match
place
.layout.ty.sty
{
ty
::
Dynamic
(
..
)
=>
{
// Dropping a trait object.
let
vtable
=
match
place
.extra
{
PlaceExtra
::
Vtable
(
vtable
)
=>
vtable
,
_
=>
bug!
(
"Expected vtable when dropping {:#?}"
,
place
),
};
let
place
=
self
.unpack_unsized_mplace
(
place
)
?
;
let
instance
=
self
.read_drop_type_from_vtable
(
vtable
)
?
;
(
instance
,
place
)
}
_
=>
(
instance
,
place
),
};
let
arg
=
OpTy
{
op
:
Operand
::
Immediate
(
place
.to_ref
(
&
self
)),
layout
:
self
.layout_of
(
self
.tcx
.mk_mut_ptr
(
place
.layout.ty
))
?
,
};
let
ty
=
self
.tcx
.mk_tup
((
&
[]
as
&
[
ty
::
Ty
<
'tcx
>
])
.iter
());
// return type is ()
let
dest
=
PlaceTy
::
null
(
&
self
,
self
.layout_of
(
ty
)
?
);
self
.eval_fn_call
(
instance
,
&
[
arg
],
Some
(
dest
),
Some
(
target
),
span
,
None
,
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录