Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
08364a4c
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
08364a4c
编写于
8月 26, 2014
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimise a particularly clown shoes example of DST codegen
上级
52ef4625
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
12 deletion
+34
-12
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/expr.rs
+34
-12
未找到文件。
src/librustc/middle/trans/expr.rs
浏览文件 @
08364a4c
...
...
@@ -193,24 +193,46 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>,
datum
=
unpack_datum!
(
bcx
,
add_env
(
bcx
,
expr
,
datum
));
}
AutoDerefRef
(
ref
adj
)
=>
{
// Extracting a value from a box counts as a deref, but if we are
// just converting Box<[T, ..n]> to Box<[T]> we aren't really doing
// a deref (and wouldn't if we could treat Box like a normal struct).
let
autoderefs
=
match
adj
.autoref
{
Some
(
ty
::
AutoUnsizeUniq
(
..
))
=>
adj
.autoderefs
-
1
,
_
=>
adj
.autoderefs
let
(
autoderefs
,
use_autoref
)
=
match
adj
.autoref
{
// Extracting a value from a box counts as a deref, but if we are
// just converting Box<[T, ..n]> to Box<[T]> we aren't really doing
// a deref (and wouldn't if we could treat Box like a normal struct).
Some
(
ty
::
AutoUnsizeUniq
(
..
))
=>
(
adj
.autoderefs
-
1
,
true
),
// We are a bit paranoid about adjustments and thus might have a re-
// borrow here which merely derefs and then refs again (it might have
// a different region or mutability, but we don't care here. It might
// also be just in case we need to unsize. But if there are no nested
// adjustments then it should be a no-op).
Some
(
ty
::
AutoPtr
(
_
,
_
,
None
))
if
adj
.autoderefs
==
1
=>
{
match
ty
::
get
(
datum
.ty
)
.sty
{
// Don't skip a conversion from Box<T> to &T, etc.
ty
::
ty_rptr
(
..
)
=>
{
let
method_call
=
MethodCall
::
autoderef
(
expr
.id
,
adj
.autoderefs
-
1
);
let
method
=
bcx
.tcx
()
.method_map
.borrow
()
.find
(
&
method_call
)
.is_some
();
if
method
{
// Don't skip an overloaded deref.
(
adj
.autoderefs
,
true
)
}
else
{
(
adj
.autoderefs
-
1
,
false
)
}
}
_
=>
(
adj
.autoderefs
,
true
),
}
}
_
=>
(
adj
.autoderefs
,
true
)
};
if
autoderefs
>
0
{
let
lval
=
unpack_datum!
(
bcx
,
datum
.to_lvalue_datum
(
bcx
,
"auto_deref"
,
expr
.id
));
// Schedule cleanup.
let
lval
=
unpack_datum!
(
bcx
,
datum
.to_lvalue_datum
(
bcx
,
"auto_deref"
,
expr
.id
));
datum
=
unpack_datum!
(
bcx
,
deref_multiple
(
bcx
,
expr
,
lval
.to_expr_datum
(),
autoderefs
));
}
match
adj
.autoref
{
Some
(
ref
a
)
=>
{
// (You might think there is a more elegant way to do this than a
// use_autoref bool, but then you remember that the borrow checker exists).
match
(
use_autoref
,
&
adj
.autoref
)
{
(
true
,
&
Some
(
ref
a
))
=>
{
datum
=
unpack_datum!
(
bcx
,
apply_autoref
(
a
,
bcx
,
expr
,
...
...
@@ -221,7 +243,7 @@ fn apply_adjustments<'a>(bcx: &'a Block<'a>,
}
}
debug!
(
"after adjustments, datum={}"
,
datum
.to_string
(
bcx
.ccx
()));
return
DatumBlock
{
bcx
:
bcx
,
datum
:
datum
}
;
return
DatumBlock
::
new
(
bcx
,
datum
)
;
fn
apply_autoref
<
'a
>
(
autoref
:
&
ty
::
AutoRef
,
bcx
:
&
'a
Block
<
'a
>
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录