Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d58cb934
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,发现更多精彩内容 >>
提交
d58cb934
编写于
4月 30, 2019
作者:
M
Mazdak Farrokhzad
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename hir::ExprKind::Use to ::DropTemps and improve docs.
上级
862a8784
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
32 addition
and
26 deletion
+32
-26
src/librustc/cfg/construct.rs
src/librustc/cfg/construct.rs
+1
-1
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+1
-1
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+11
-7
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+8
-6
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+1
-1
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/expr_use_visitor.rs
+1
-1
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+3
-3
src/librustc/middle/mem_categorization.rs
src/librustc/middle/mem_categorization.rs
+1
-1
src/librustc/middle/region.rs
src/librustc/middle/region.rs
+2
-2
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/expr.rs
+1
-1
src/librustc_passes/rvalue_promotion.rs
src/librustc_passes/rvalue_promotion.rs
+1
-1
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-1
未找到文件。
src/librustc/cfg/construct.rs
浏览文件 @
d58cb934
...
...
@@ -369,7 +369,7 @@ fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex {
hir
::
ExprKind
::
AddrOf
(
_
,
ref
e
)
|
hir
::
ExprKind
::
Cast
(
ref
e
,
_
)
|
hir
::
ExprKind
::
Type
(
ref
e
,
_
)
|
hir
::
ExprKind
::
Use
(
ref
e
)
|
hir
::
ExprKind
::
DropTemps
(
ref
e
)
|
hir
::
ExprKind
::
Unary
(
_
,
ref
e
)
|
hir
::
ExprKind
::
Field
(
ref
e
,
_
)
|
hir
::
ExprKind
::
Yield
(
ref
e
)
|
...
...
src/librustc/hir/intravisit.rs
浏览文件 @
d58cb934
...
...
@@ -1029,7 +1029,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
visitor
.visit_expr
(
subexpression
);
visitor
.visit_ty
(
typ
)
}
ExprKind
::
Use
(
ref
subexpression
)
=>
{
ExprKind
::
DropTemps
(
ref
subexpression
)
=>
{
visitor
.visit_expr
(
subexpression
);
}
ExprKind
::
If
(
ref
head_expression
,
ref
if_block
,
ref
optional_else
)
=>
{
...
...
src/librustc/hir/lowering.rs
浏览文件 @
d58cb934
...
...
@@ -4671,7 +4671,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
// The construct was introduced in #21984.
// FIXME(60253): Is this still necessary?
// Also, add the attributes to the outer returned expr node.
return
self
.expr_
use
(
head_sp
,
match_expr
,
e
.attrs
.clone
())
return
self
.expr_
drop_temps
(
head_sp
,
match_expr
,
e
.attrs
.clone
())
}
// Desugar `ExprKind::Try`
...
...
@@ -5030,15 +5030,19 @@ fn expr_std_path(
)
}
/// Wrap the given `expr` in
`hir::ExprKind::Use
`.
/// Wrap the given `expr` in
a terminating scope using `hir::ExprKind::DropTemps
`.
///
/// In terms of drop order, it has the same effect as
/// wrapping `expr` in `{ let _t = $expr; _t }` but
/// should provide better compile-time performance.
/// In terms of drop order, it has the same effect as wrapping `expr` in
/// `{ let _t = $expr; _t }` but should provide better compile-time performance.
///
/// The drop order can be important in e.g. `if expr { .. }`.
fn
expr_use
(
&
mut
self
,
span
:
Span
,
expr
:
P
<
hir
::
Expr
>
,
attrs
:
ThinVec
<
Attribute
>
)
->
hir
::
Expr
{
self
.expr
(
span
,
hir
::
ExprKind
::
Use
(
expr
),
attrs
)
fn
expr_drop_temps
(
&
mut
self
,
span
:
Span
,
expr
:
P
<
hir
::
Expr
>
,
attrs
:
ThinVec
<
Attribute
>
)
->
hir
::
Expr
{
self
.expr
(
span
,
hir
::
ExprKind
::
DropTemps
(
expr
),
attrs
)
}
fn
expr_match
(
...
...
src/librustc/hir/mod.rs
浏览文件 @
d58cb934
...
...
@@ -1366,7 +1366,7 @@ pub fn precedence(&self) -> ExprPrecedence {
ExprKind
::
Unary
(
..
)
=>
ExprPrecedence
::
Unary
,
ExprKind
::
Lit
(
_
)
=>
ExprPrecedence
::
Lit
,
ExprKind
::
Type
(
..
)
|
ExprKind
::
Cast
(
..
)
=>
ExprPrecedence
::
Cast
,
ExprKind
::
Use
(
ref
expr
,
..
)
=>
expr
.precedence
(),
ExprKind
::
DropTemps
(
ref
expr
,
..
)
=>
expr
.precedence
(),
ExprKind
::
If
(
..
)
=>
ExprPrecedence
::
If
,
ExprKind
::
While
(
..
)
=>
ExprPrecedence
::
While
,
ExprKind
::
Loop
(
..
)
=>
ExprPrecedence
::
Loop
,
...
...
@@ -1438,7 +1438,7 @@ pub fn is_place_expr(&self) -> bool {
ExprKind
::
Binary
(
..
)
|
ExprKind
::
Yield
(
..
)
|
ExprKind
::
Cast
(
..
)
|
ExprKind
::
Use
(
..
)
|
ExprKind
::
DropTemps
(
..
)
|
ExprKind
::
Err
=>
{
false
}
...
...
@@ -1488,10 +1488,12 @@ pub enum ExprKind {
Cast
(
P
<
Expr
>
,
P
<
Ty
>
),
/// A type reference (e.g., `Foo`).
Type
(
P
<
Expr
>
,
P
<
Ty
>
),
/// Semantically equivalent to `{ let _t = expr; _t }`.
/// Maps directly to `hair::ExprKind::Use`.
/// Only exists to tweak the drop order in HIR.
Use
(
P
<
Expr
>
),
/// Wraps the expression in a terminating scope.
/// This makes it semantically equivalent to `{ let _t = expr; _t }`.
///
/// This construct only exists to tweak the drop order in HIR lowering.
/// An example of that is the desugaring of `for` loops.
DropTemps
(
P
<
Expr
>
),
/// An `if` block, with an optional else block.
///
/// I.e., `if <expr> { <expr> } else { <expr> }`.
...
...
src/librustc/hir/print.rs
浏览文件 @
d58cb934
...
...
@@ -1388,7 +1388,7 @@ pub fn print_expr(&mut self, expr: &hir::Expr) -> io::Result<()> {
self
.word_space
(
":"
)
?
;
self
.print_type
(
&
ty
)
?
;
}
hir
::
ExprKind
::
Use
(
ref
init
)
=>
{
hir
::
ExprKind
::
DropTemps
(
ref
init
)
=>
{
// Print `{`:
self
.cbox
(
indent_unit
)
?
;
self
.ibox
(
0
)
?
;
...
...
src/librustc/middle/expr_use_visitor.rs
浏览文件 @
d58cb934
...
...
@@ -520,7 +520,7 @@ pub fn walk_expr(&mut self, expr: &hir::Expr) {
self
.consume_expr
(
&
base
);
}
hir
::
ExprKind
::
Use
(
ref
expr
)
=>
{
hir
::
ExprKind
::
DropTemps
(
ref
expr
)
=>
{
self
.consume_expr
(
&
expr
);
}
...
...
src/librustc/middle/liveness.rs
浏览文件 @
d58cb934
...
...
@@ -521,7 +521,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
hir
::
ExprKind
::
Binary
(
..
)
|
hir
::
ExprKind
::
AddrOf
(
..
)
|
hir
::
ExprKind
::
Cast
(
..
)
|
hir
::
ExprKind
::
Use
(
..
)
|
hir
::
ExprKind
::
DropTemps
(
..
)
|
hir
::
ExprKind
::
Unary
(
..
)
|
hir
::
ExprKind
::
Break
(
..
)
|
hir
::
ExprKind
::
Continue
(
_
)
|
...
...
@@ -1222,7 +1222,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
hir
::
ExprKind
::
AddrOf
(
_
,
ref
e
)
|
hir
::
ExprKind
::
Cast
(
ref
e
,
_
)
|
hir
::
ExprKind
::
Type
(
ref
e
,
_
)
|
hir
::
ExprKind
::
Use
(
ref
e
)
|
hir
::
ExprKind
::
DropTemps
(
ref
e
)
|
hir
::
ExprKind
::
Unary
(
_
,
ref
e
)
|
hir
::
ExprKind
::
Yield
(
ref
e
)
|
hir
::
ExprKind
::
Repeat
(
ref
e
,
_
)
=>
{
...
...
@@ -1526,7 +1526,7 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
hir
::
ExprKind
::
Match
(
..
)
|
hir
::
ExprKind
::
While
(
..
)
|
hir
::
ExprKind
::
Loop
(
..
)
|
hir
::
ExprKind
::
Index
(
..
)
|
hir
::
ExprKind
::
Field
(
..
)
|
hir
::
ExprKind
::
Array
(
..
)
|
hir
::
ExprKind
::
Tup
(
..
)
|
hir
::
ExprKind
::
Binary
(
..
)
|
hir
::
ExprKind
::
Cast
(
..
)
|
hir
::
ExprKind
::
Use
(
..
)
|
hir
::
ExprKind
::
Unary
(
..
)
|
hir
::
ExprKind
::
Cast
(
..
)
|
hir
::
ExprKind
::
DropTemps
(
..
)
|
hir
::
ExprKind
::
Unary
(
..
)
|
hir
::
ExprKind
::
Ret
(
..
)
|
hir
::
ExprKind
::
Break
(
..
)
|
hir
::
ExprKind
::
Continue
(
..
)
|
hir
::
ExprKind
::
Lit
(
_
)
|
hir
::
ExprKind
::
Block
(
..
)
|
hir
::
ExprKind
::
AddrOf
(
..
)
|
hir
::
ExprKind
::
Struct
(
..
)
|
hir
::
ExprKind
::
Repeat
(
..
)
|
...
...
src/librustc/middle/mem_categorization.rs
浏览文件 @
d58cb934
...
...
@@ -677,7 +677,7 @@ pub fn cat_expr_unadjusted(&self, expr: &hir::Expr) -> McResult<cmt_<'tcx>> {
hir
::
ExprKind
::
Assign
(
..
)
|
hir
::
ExprKind
::
AssignOp
(
..
)
|
hir
::
ExprKind
::
Closure
(
..
)
|
hir
::
ExprKind
::
Ret
(
..
)
|
hir
::
ExprKind
::
Unary
(
..
)
|
hir
::
ExprKind
::
Yield
(
..
)
|
hir
::
ExprKind
::
MethodCall
(
..
)
|
hir
::
ExprKind
::
Cast
(
..
)
|
hir
::
ExprKind
::
Use
(
..
)
|
hir
::
ExprKind
::
MethodCall
(
..
)
|
hir
::
ExprKind
::
Cast
(
..
)
|
hir
::
ExprKind
::
DropTemps
(
..
)
|
hir
::
ExprKind
::
Array
(
..
)
|
hir
::
ExprKind
::
Tup
(
..
)
|
hir
::
ExprKind
::
If
(
..
)
|
hir
::
ExprKind
::
Binary
(
..
)
|
hir
::
ExprKind
::
While
(
..
)
|
hir
::
ExprKind
::
Block
(
..
)
|
hir
::
ExprKind
::
Loop
(
..
)
|
hir
::
ExprKind
::
Match
(
..
)
|
...
...
src/librustc/middle/region.rs
浏览文件 @
d58cb934
...
...
@@ -908,8 +908,8 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
visitor
.cx.var_parent
=
visitor
.cx.parent
;
}
hir
::
ExprKind
::
Use
(
ref
expr
)
=>
{
// `
Use
(expr)` does not denote a conditional scope.
hir
::
ExprKind
::
DropTemps
(
ref
expr
)
=>
{
// `
DropTemps
(expr)` does not denote a conditional scope.
// Rather, we want to achieve the same behavior as `{ let _t = expr; _t }`.
terminating
(
expr
.hir_id.local_id
);
}
...
...
src/librustc_mir/hair/cx/expr.rs
浏览文件 @
d58cb934
...
...
@@ -759,7 +759,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
}
}
}
hir
::
ExprKind
::
Use
(
ref
source
)
=>
{
hir
::
ExprKind
::
DropTemps
(
ref
source
)
=>
{
ExprKind
::
Use
{
source
:
source
.to_ref
()
}
}
hir
::
ExprKind
::
Box
(
ref
value
)
=>
{
...
...
src/librustc_passes/rvalue_promotion.rs
浏览文件 @
d58cb934
...
...
@@ -437,7 +437,7 @@ fn check_expr_kind<'a, 'tcx>(
hir
::
ExprKind
::
AddrOf
(
_
,
ref
expr
)
|
hir
::
ExprKind
::
Repeat
(
ref
expr
,
_
)
|
hir
::
ExprKind
::
Type
(
ref
expr
,
_
)
|
hir
::
ExprKind
::
Use
(
ref
expr
)
=>
{
hir
::
ExprKind
::
DropTemps
(
ref
expr
)
=>
{
v
.check_expr
(
&
expr
)
}
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
d58cb934
...
...
@@ -4538,7 +4538,7 @@ fn check_expr_kind(
self
.check_expr_eq_type
(
&
e
,
ty
);
ty
}
ExprKind
::
Use
(
ref
e
)
=>
{
ExprKind
::
DropTemps
(
ref
e
)
=>
{
self
.check_expr_with_expectation
(
e
,
expected
)
}
ExprKind
::
Array
(
ref
args
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录