Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cd049ef9
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,发现更多精彩内容 >>
提交
cd049ef9
编写于
3月 06, 2021
作者:
L
LeSeulArtichaut
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove useless references/dereferences
上级
c2c43228
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
148 addition
and
168 deletion
+148
-168
compiler/rustc_mir_build/src/build/block.rs
compiler/rustc_mir_build/src/build/block.rs
+16
-23
compiler/rustc_mir_build/src/build/expr/as_constant.rs
compiler/rustc_mir_build/src/build/expr/as_constant.rs
+8
-8
compiler/rustc_mir_build/src/build/expr/as_operand.rs
compiler/rustc_mir_build/src/build/expr/as_operand.rs
+8
-8
compiler/rustc_mir_build/src/build/expr/as_place.rs
compiler/rustc_mir_build/src/build/expr/as_place.rs
+18
-20
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+23
-25
compiler/rustc_mir_build/src/build/expr/as_temp.rs
compiler/rustc_mir_build/src/build/expr/as_temp.rs
+2
-2
compiler/rustc_mir_build/src/build/expr/into.rs
compiler/rustc_mir_build/src/build/expr/into.rs
+46
-49
compiler/rustc_mir_build/src/build/expr/stmt.rs
compiler/rustc_mir_build/src/build/expr/stmt.rs
+14
-20
compiler/rustc_mir_build/src/build/matches/mod.rs
compiler/rustc_mir_build/src/build/matches/mod.rs
+1
-1
compiler/rustc_mir_build/src/build/mod.rs
compiler/rustc_mir_build/src/build/mod.rs
+1
-1
compiler/rustc_mir_build/src/thir/cx/block.rs
compiler/rustc_mir_build/src/thir/cx/block.rs
+3
-3
compiler/rustc_mir_build/src/thir/cx/expr.rs
compiler/rustc_mir_build/src/thir/cx/expr.rs
+8
-8
未找到文件。
compiler/rustc_mir_build/src/build/block.rs
浏览文件 @
cd049ef9
...
...
@@ -23,29 +23,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
expr
,
targeted_by_break
,
safety_mode
,
}
=
ast_block
;
}
=
*
ast_block
;
self
.in_opt_scope
(
opt_destruction_scope
.map
(|
de
|
(
de
,
source_info
)),
move
|
this
|
{
this
.in_scope
((
*
region_scope
,
source_info
),
LintLevel
::
Inherited
,
move
|
this
|
{
if
*
targeted_by_break
{
this
.in_breakable_scope
(
None
,
destination
,
*
span
,
|
this
|
{
this
.in_scope
((
region_scope
,
source_info
),
LintLevel
::
Inherited
,
move
|
this
|
{
if
targeted_by_break
{
this
.in_breakable_scope
(
None
,
destination
,
span
,
|
this
|
{
Some
(
this
.ast_block_stmts
(
destination
,
block
,
*
span
,
&
stmts
,
expr
.as_deref
()
,
*
safety_mode
,
span
,
stmts
,
expr
,
safety_mode
,
))
})
}
else
{
this
.ast_block_stmts
(
destination
,
block
,
*
span
,
&
stmts
,
expr
.as_deref
(),
*
safety_mode
,
)
this
.ast_block_stmts
(
destination
,
block
,
span
,
stmts
,
expr
,
safety_mode
)
}
})
})
...
...
@@ -87,15 +80,15 @@ fn ast_block_stmts(
let
source_info
=
this
.source_info
(
span
);
for
Stmt
{
kind
,
opt_destruction_scope
}
in
stmts
{
match
kind
{
StmtKind
::
Expr
{
scope
,
expr
}
=>
{
&
StmtKind
::
Expr
{
scope
,
expr
}
=>
{
this
.block_context
.push
(
BlockFrame
::
Statement
{
ignores_expr_result
:
true
});
unpack!
(
block
=
this
.in_opt_scope
(
opt_destruction_scope
.map
(|
de
|
(
de
,
source_info
)),
|
this
|
{
let
si
=
(
*
scope
,
source_info
);
let
si
=
(
scope
,
source_info
);
this
.in_scope
(
si
,
LintLevel
::
Inherited
,
|
this
|
{
this
.stmt_expr
(
block
,
&
expr
,
Some
(
*
scope
))
this
.stmt_expr
(
block
,
expr
,
Some
(
scope
))
})
}
)
...
...
@@ -110,7 +103,7 @@ fn ast_block_stmts(
let_scope_stack
.push
(
remainder_scope
);
// Declare the bindings, which may create a source scope.
let
remainder_span
=
remainder_scope
.span
(
this
.tcx
,
&
this
.region_scope_tree
);
let
remainder_span
=
remainder_scope
.span
(
this
.tcx
,
this
.region_scope_tree
);
let
visibility_scope
=
Some
(
this
.new_source_scope
(
remainder_span
,
LintLevel
::
Inherited
,
None
));
...
...
@@ -128,11 +121,11 @@ fn ast_block_stmts(
this
.declare_bindings
(
visibility_scope
,
remainder_span
,
&
pattern
,
pattern
,
ArmHasGuard
(
false
),
Some
((
None
,
initializer_span
)),
);
this
.expr_into_pattern
(
block
,
pattern
.clone
(),
&
init
)
this
.expr_into_pattern
(
block
,
pattern
.clone
(),
init
)
})
}
)
...
...
@@ -143,7 +136,7 @@ fn ast_block_stmts(
this
.declare_bindings
(
visibility_scope
,
remainder_span
,
&
pattern
,
pattern
,
ArmHasGuard
(
false
),
None
,
);
...
...
compiler/rustc_mir_build/src/build/expr/as_constant.rs
浏览文件 @
cd049ef9
...
...
@@ -10,25 +10,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// `expr` is a valid compile-time constant!
crate
fn
as_constant
(
&
mut
self
,
expr
:
&
Expr
<
'_
,
'tcx
>
)
->
Constant
<
'tcx
>
{
let
this
=
self
;
let
Expr
{
ty
,
temp_lifetime
:
_
,
span
,
kind
}
=
expr
;
let
Expr
{
ty
,
temp_lifetime
:
_
,
span
,
ref
kind
}
=
*
expr
;
match
kind
{
ExprKind
::
Scope
{
region_scope
:
_
,
lint_level
:
_
,
value
}
=>
this
.as_constant
(
&
value
),
ExprKind
::
Scope
{
region_scope
:
_
,
lint_level
:
_
,
value
}
=>
this
.as_constant
(
value
),
ExprKind
::
Literal
{
literal
,
user_ty
,
const_id
:
_
}
=>
{
let
user_ty
=
user_ty
.map
(|
user_ty
|
{
this
.canonical_user_type_annotations
.push
(
CanonicalUserTypeAnnotation
{
span
:
*
span
,
span
,
user_ty
,
inferred_ty
:
ty
,
})
});
assert_eq!
(
literal
.ty
,
*
ty
);
Constant
{
span
:
*
span
,
user_ty
,
literal
}
assert_eq!
(
literal
.ty
,
ty
);
Constant
{
span
,
user_ty
,
literal
}
}
ExprKind
::
StaticRef
{
literal
,
..
}
=>
Constant
{
span
:
*
span
,
user_ty
:
None
,
literal
},
ExprKind
::
StaticRef
{
literal
,
..
}
=>
Constant
{
span
,
user_ty
:
None
,
literal
},
ExprKind
::
ConstBlock
{
value
}
=>
{
Constant
{
span
:
*
span
,
user_ty
:
None
,
literal
:
value
}
Constant
{
span
:
span
,
user_ty
:
None
,
literal
:
value
}
}
_
=>
span_bug!
(
*
span
,
"expression is not a valid constant {:?}"
,
kind
),
_
=>
span_bug!
(
span
,
"expression is not a valid constant {:?}"
,
kind
),
}
}
}
compiler/rustc_mir_build/src/build/expr/as_operand.rs
浏览文件 @
cd049ef9
...
...
@@ -98,11 +98,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
debug!
(
"as_operand(block={:?}, expr={:?})"
,
block
,
expr
);
let
this
=
self
;
if
let
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=
&
expr
.kind
{
if
let
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=
expr
.kind
{
let
source_info
=
this
.source_info
(
expr
.span
);
let
region_scope
=
(
*
region_scope
,
source_info
);
let
region_scope
=
(
region_scope
,
source_info
);
return
this
.in_scope
(
region_scope
,
*
lint_level
,
|
this
|
this
.as_operand
(
block
,
scope
,
&
value
));
.in_scope
(
region_scope
,
lint_level
,
|
this
|
this
.as_operand
(
block
,
scope
,
value
));
}
let
category
=
Category
::
of
(
&
expr
.kind
)
.unwrap
();
...
...
@@ -128,11 +128,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
debug!
(
"as_call_operand(block={:?}, expr={:?})"
,
block
,
expr
);
let
this
=
self
;
if
let
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=
&
expr
.kind
{
if
let
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=
expr
.kind
{
let
source_info
=
this
.source_info
(
expr
.span
);
let
region_scope
=
(
*
region_scope
,
source_info
);
return
this
.in_scope
(
region_scope
,
*
lint_level
,
|
this
|
{
this
.as_call_operand
(
block
,
scope
,
&
value
)
let
region_scope
=
(
region_scope
,
source_info
);
return
this
.in_scope
(
region_scope
,
lint_level
,
|
this
|
{
this
.as_call_operand
(
block
,
scope
,
value
)
});
}
...
...
@@ -149,7 +149,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// As described above, detect the case where we are passing a value of unsized
// type, and that value is coming from the deref of a box.
if
let
ExprKind
::
Deref
{
ref
arg
}
=
expr
.kind
{
if
let
ExprKind
::
Deref
{
arg
}
=
expr
.kind
{
// Generate let tmp0 = arg0
let
operand
=
unpack!
(
block
=
this
.as_temp
(
block
,
scope
,
arg
,
Mutability
::
Mut
));
...
...
compiler/rustc_mir_build/src/build/expr/as_place.rs
浏览文件 @
cd049ef9
...
...
@@ -406,28 +406,26 @@ fn expr_as_place(
let
this
=
self
;
let
expr_span
=
expr
.span
;
let
source_info
=
this
.source_info
(
expr_span
);
match
&
expr
.kind
{
match
expr
.kind
{
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=>
{
this
.in_scope
((
*
region_scope
,
source_info
),
*
lint_level
,
|
this
|
{
this
.expr_as_place
(
block
,
&
value
,
mutability
,
fake_borrow_temps
)
this
.in_scope
((
region_scope
,
source_info
),
lint_level
,
|
this
|
{
this
.expr_as_place
(
block
,
value
,
mutability
,
fake_borrow_temps
)
})
}
ExprKind
::
Field
{
lhs
,
name
}
=>
{
let
place_builder
=
unpack!
(
block
=
this
.expr_as_place
(
block
,
&
lhs
,
mutability
,
fake_borrow_temps
,)
);
block
.and
(
place_builder
.field
(
*
name
,
expr
.ty
))
let
place_builder
=
unpack!
(
block
=
this
.expr_as_place
(
block
,
lhs
,
mutability
,
fake_borrow_temps
,));
block
.and
(
place_builder
.field
(
name
,
expr
.ty
))
}
ExprKind
::
Deref
{
arg
}
=>
{
let
place_builder
=
unpack!
(
block
=
this
.expr_as_place
(
block
,
&
arg
,
mutability
,
fake_borrow_temps
,)
);
let
place_builder
=
unpack!
(
block
=
this
.expr_as_place
(
block
,
arg
,
mutability
,
fake_borrow_temps
,));
block
.and
(
place_builder
.deref
())
}
ExprKind
::
Index
{
lhs
,
index
}
=>
this
.lower_index_expression
(
block
,
&
lhs
,
&
index
,
lhs
,
index
,
mutability
,
fake_borrow_temps
,
expr
.temp_lifetime
,
...
...
@@ -435,16 +433,16 @@ fn expr_as_place(
source_info
,
),
ExprKind
::
UpvarRef
{
closure_def_id
,
var_hir_id
}
=>
{
let
upvar_id
=
ty
::
UpvarId
::
new
(
*
var_hir_id
,
closure_def_id
.expect_local
());
let
upvar_id
=
ty
::
UpvarId
::
new
(
var_hir_id
,
closure_def_id
.expect_local
());
this
.lower_captured_upvar
(
block
,
upvar_id
)
}
ExprKind
::
VarRef
{
id
}
=>
{
let
place_builder
=
if
this
.is_bound_var_in_guard
(
*
id
)
{
let
index
=
this
.var_local_id
(
*
id
,
RefWithinGuard
);
let
place_builder
=
if
this
.is_bound_var_in_guard
(
id
)
{
let
index
=
this
.var_local_id
(
id
,
RefWithinGuard
);
PlaceBuilder
::
from
(
index
)
.deref
()
}
else
{
let
index
=
this
.var_local_id
(
*
id
,
OutsideGuard
);
let
index
=
this
.var_local_id
(
id
,
OutsideGuard
);
PlaceBuilder
::
from
(
index
)
};
block
.and
(
place_builder
)
...
...
@@ -452,13 +450,13 @@ fn expr_as_place(
ExprKind
::
PlaceTypeAscription
{
source
,
user_ty
}
=>
{
let
place_builder
=
unpack!
(
block
=
this
.expr_as_place
(
block
,
&
source
,
mutability
,
fake_borrow_temps
,)
block
=
this
.expr_as_place
(
block
,
source
,
mutability
,
fake_borrow_temps
,)
);
if
let
Some
(
user_ty
)
=
user_ty
{
let
annotation_index
=
this
.canonical_user_type_annotations
.push
(
CanonicalUserTypeAnnotation
{
span
:
source_info
.span
,
user_ty
:
*
user_ty
,
user_ty
,
inferred_ty
:
expr
.ty
,
});
...
...
@@ -481,12 +479,12 @@ fn expr_as_place(
}
ExprKind
::
ValueTypeAscription
{
source
,
user_ty
}
=>
{
let
temp
=
unpack!
(
block
=
this
.as_temp
(
block
,
source
.temp_lifetime
,
&
source
,
mutability
));
unpack!
(
block
=
this
.as_temp
(
block
,
source
.temp_lifetime
,
source
,
mutability
));
if
let
Some
(
user_ty
)
=
user_ty
{
let
annotation_index
=
this
.canonical_user_type_annotations
.push
(
CanonicalUserTypeAnnotation
{
span
:
source_info
.span
,
user_ty
:
*
user_ty
,
user_ty
,
inferred_ty
:
expr
.ty
,
});
this
.cfg
.push
(
...
...
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
浏览文件 @
cd049ef9
...
...
@@ -41,27 +41,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let
expr_span
=
expr
.span
;
let
source_info
=
this
.source_info
(
expr_span
);
match
&
expr
.kind
{
ExprKind
::
ThreadLocalRef
(
did
)
=>
block
.and
(
Rvalue
::
ThreadLocalRef
(
*
did
)),
match
expr
.kind
{
ExprKind
::
ThreadLocalRef
(
did
)
=>
block
.and
(
Rvalue
::
ThreadLocalRef
(
did
)),
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=>
{
let
region_scope
=
(
*
region_scope
,
source_info
);
this
.in_scope
(
region_scope
,
*
lint_level
,
|
this
|
{
this
.as_rvalue
(
block
,
scope
,
&
value
)
})
let
region_scope
=
(
region_scope
,
source_info
);
this
.in_scope
(
region_scope
,
lint_level
,
|
this
|
this
.as_rvalue
(
block
,
scope
,
value
))
}
ExprKind
::
Repeat
{
value
,
count
}
=>
{
let
value_operand
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
value
));
let
value_operand
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
value
));
block
.and
(
Rvalue
::
Repeat
(
value_operand
,
count
))
}
ExprKind
::
Binary
{
op
,
lhs
,
rhs
}
=>
{
let
lhs
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
lhs
));
let
rhs
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
rhs
));
this
.build_binary_op
(
block
,
*
op
,
expr_span
,
expr
.ty
,
lhs
,
rhs
)
let
lhs
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
lhs
));
let
rhs
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
rhs
));
this
.build_binary_op
(
block
,
op
,
expr_span
,
expr
.ty
,
lhs
,
rhs
)
}
ExprKind
::
Unary
{
op
,
arg
}
=>
{
let
arg
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
arg
));
let
arg
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
arg
));
// Check for -MIN on signed integers
if
this
.check_overflow
&&
*
op
==
UnOp
::
Neg
&&
expr
.ty
.is_signed
()
{
if
this
.check_overflow
&&
op
==
UnOp
::
Neg
&&
expr
.ty
.is_signed
()
{
let
bool_ty
=
this
.tcx.types.bool
;
let
minval
=
this
.minval_literal
(
expr_span
,
expr
.ty
);
...
...
@@ -82,7 +80,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
expr_span
,
);
}
block
.and
(
Rvalue
::
UnaryOp
(
*
op
,
arg
))
block
.and
(
Rvalue
::
UnaryOp
(
op
,
arg
))
}
ExprKind
::
Box
{
value
}
=>
{
// The `Box<T>` temporary created here is not a part of the HIR,
...
...
@@ -107,18 +105,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block
=
this
.expr_into_dest
(
this
.tcx
.mk_place_deref
(
Place
::
from
(
result
)),
block
,
&
value
value
)
);
block
.and
(
Rvalue
::
Use
(
Operand
::
Move
(
Place
::
from
(
result
))))
}
ExprKind
::
Cast
{
source
}
=>
{
let
source
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
source
));
let
source
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
source
));
block
.and
(
Rvalue
::
Cast
(
CastKind
::
Misc
,
source
,
expr
.ty
))
}
ExprKind
::
Pointer
{
cast
,
source
}
=>
{
let
source
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
source
));
block
.and
(
Rvalue
::
Cast
(
CastKind
::
Pointer
(
*
cast
),
source
,
expr
.ty
))
let
source
=
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
source
));
block
.and
(
Rvalue
::
Cast
(
CastKind
::
Pointer
(
cast
),
source
,
expr
.ty
))
}
ExprKind
::
Array
{
fields
}
=>
{
// (*) We would (maybe) be closer to codegen if we
...
...
@@ -151,7 +149,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let
el_ty
=
expr
.ty
.sequence_element_type
(
this
.tcx
);
let
fields
:
Vec
<
_
>
=
fields
.into_iter
()
.map
(|
f
|
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
f
)))
.map
(|
f
|
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
f
)))
.collect
();
block
.and
(
Rvalue
::
Aggregate
(
box
AggregateKind
::
Array
(
el_ty
),
fields
))
...
...
@@ -161,7 +159,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// first process the set of fields
let
fields
:
Vec
<
_
>
=
fields
.into_iter
()
.map
(|
f
|
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
f
)))
.map
(|
f
|
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
f
)))
.collect
();
block
.and
(
Rvalue
::
Aggregate
(
box
AggregateKind
::
Tuple
,
fields
))
...
...
@@ -181,7 +179,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// This occurs when capturing by copy/move, while
// by reference captures use as_operand
Some
(
Category
::
Place
)
=>
{
let
place
=
unpack!
(
block
=
this
.as_place
(
block
,
&
upvar
));
let
place
=
unpack!
(
block
=
this
.as_place
(
block
,
upvar
));
this
.consume_by_copy_or_move
(
place
)
}
_
=>
{
...
...
@@ -189,17 +187,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// borrow captures when capturing an immutable
// variable. This is sound because the mutation
// that caused the capture will cause an error.
match
&
upvar
.kind
{
match
upvar
.kind
{
ExprKind
::
Borrow
{
borrow_kind
:
BorrowKind
::
Mut
{
allow_two_phase_borrow
:
false
},
arg
,
}
=>
unpack!
(
block
=
this
.limit_capture_mutability
(
upvar
.span
,
upvar
.ty
,
scope
,
block
,
&
arg
,
upvar
.span
,
upvar
.ty
,
scope
,
block
,
arg
,
)
),
_
=>
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
&
upvar
)),
_
=>
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
upvar
)),
}
}
}
...
...
@@ -210,9 +208,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// We implicitly set the discriminant to 0. See
// librustc_mir/transform/deaggregator.rs for details.
let
movability
=
movability
.unwrap
();
box
AggregateKind
::
Generator
(
*
closure_id
,
substs
,
movability
)
box
AggregateKind
::
Generator
(
closure_id
,
substs
,
movability
)
}
UpvarSubsts
::
Closure
(
substs
)
=>
box
AggregateKind
::
Closure
(
*
closure_id
,
substs
),
UpvarSubsts
::
Closure
(
substs
)
=>
box
AggregateKind
::
Closure
(
closure_id
,
substs
),
};
block
.and
(
Rvalue
::
Aggregate
(
result
,
operands
))
}
...
...
compiler/rustc_mir_build/src/build/expr/as_temp.rs
浏览文件 @
cd049ef9
...
...
@@ -38,8 +38,8 @@ fn as_temp_inner(
let
expr_span
=
expr
.span
;
let
source_info
=
this
.source_info
(
expr_span
);
if
let
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=
&
expr
.kind
{
return
this
.in_scope
((
*
region_scope
,
source_info
),
*
lint_level
,
|
this
|
{
if
let
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=
expr
.kind
{
return
this
.in_scope
((
region_scope
,
source_info
),
lint_level
,
|
this
|
{
this
.as_temp
(
block
,
temp_lifetime
,
value
,
mutability
)
});
}
...
...
compiler/rustc_mir_build/src/build/expr/into.rs
浏览文件 @
cd049ef9
...
...
@@ -36,24 +36,24 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this
.block_context
.push
(
BlockFrame
::
SubExpr
);
}
let
block_and
=
match
&
expr
.kind
{
let
block_and
=
match
expr
.kind
{
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=>
{
let
region_scope
=
(
*
region_scope
,
source_info
);
let
region_scope
=
(
region_scope
,
source_info
);
ensure_sufficient_stack
(||
{
this
.in_scope
(
region_scope
,
*
lint_level
,
|
this
|
{
this
.expr_into_dest
(
destination
,
block
,
&
value
)
this
.in_scope
(
region_scope
,
lint_level
,
|
this
|
{
this
.expr_into_dest
(
destination
,
block
,
value
)
})
})
}
ExprKind
::
Block
{
body
:
ast_block
}
=>
{
this
.ast_block
(
destination
,
block
,
&
ast_block
,
source_info
)
ExprKind
::
Block
{
body
:
ref
ast_block
}
=>
{
this
.ast_block
(
destination
,
block
,
ast_block
,
source_info
)
}
ExprKind
::
Match
{
scrutinee
,
arms
}
=>
{
this
.match_expr
(
destination
,
expr_span
,
block
,
&
scrutinee
,
&
arms
)
this
.match_expr
(
destination
,
expr_span
,
block
,
scrutinee
,
arms
)
}
ExprKind
::
If
{
cond
,
then
,
else_opt
}
=>
{
let
place
=
unpack!
(
block
=
this
.as_temp
(
block
,
Some
(
this
.local_scope
()),
&
cond
,
Mutability
::
Mut
)
block
=
this
.as_temp
(
block
,
Some
(
this
.local_scope
()),
cond
,
Mutability
::
Mut
)
);
let
operand
=
Operand
::
Move
(
Place
::
from
(
place
));
...
...
@@ -62,9 +62,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let
term
=
TerminatorKind
::
if_
(
this
.tcx
,
operand
,
then_block
,
else_block
);
this
.cfg
.terminate
(
block
,
source_info
,
term
);
unpack!
(
then_block
=
this
.expr_into_dest
(
destination
,
then_block
,
&
then
));
unpack!
(
then_block
=
this
.expr_into_dest
(
destination
,
then_block
,
then
));
else_block
=
if
let
Some
(
else_opt
)
=
else_opt
{
unpack!
(
this
.expr_into_dest
(
destination
,
else_block
,
&
else_opt
))
unpack!
(
this
.expr_into_dest
(
destination
,
else_block
,
else_opt
))
}
else
{
// Body of the `if` expression without an `else` clause must return `()`, thus
// we implicitly generate a `else {}` if it is not specified.
...
...
@@ -94,8 +94,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// (#66975) Source could be a const of type `!`, so has to
// exist in the generated MIR.
unpack!
(
block
=
this
.as_temp
(
block
,
Some
(
this
.local_scope
()),
&
source
,
Mutability
::
Mut
,)
block
=
this
.as_temp
(
block
,
Some
(
this
.local_scope
()),
source
,
Mutability
::
Mut
,)
);
// This is an optimization. If the expression was a call then we already have an
...
...
@@ -128,7 +127,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this
.cfg
.start_new_block
(),
);
let
lhs
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
&
lhs
));
let
lhs
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
lhs
));
let
blocks
=
match
op
{
LogicalOp
::
And
=>
(
else_block
,
false_block
),
LogicalOp
::
Or
=>
(
true_block
,
else_block
),
...
...
@@ -136,7 +135,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let
term
=
TerminatorKind
::
if_
(
this
.tcx
,
lhs
,
blocks
.0
,
blocks
.1
);
this
.cfg
.terminate
(
block
,
source_info
,
term
);
let
rhs
=
unpack!
(
else_block
=
this
.as_local_operand
(
else_block
,
&
rhs
));
let
rhs
=
unpack!
(
else_block
=
this
.as_local_operand
(
else_block
,
rhs
));
let
term
=
TerminatorKind
::
if_
(
this
.tcx
,
rhs
,
true_block
,
false_block
);
this
.cfg
.terminate
(
else_block
,
source_info
,
term
);
...
...
@@ -197,7 +196,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// introduce a unit temporary as the destination for the loop body.
let
tmp
=
this
.get_unit_temp
();
// Execute the body, branching back to the test.
let
body_block_end
=
unpack!
(
this
.expr_into_dest
(
tmp
,
body_block
,
&
body
));
let
body_block_end
=
unpack!
(
this
.expr_into_dest
(
tmp
,
body_block
,
body
));
this
.cfg
.goto
(
body_block_end
,
source_info
,
loop_block
);
// Loops are only exited by `break` expressions.
...
...
@@ -205,10 +204,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
})
}
ExprKind
::
Call
{
ty
:
_
,
fun
,
args
,
from_hir_call
,
fn_span
}
=>
{
let
fun
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
&
fun
));
let
fun
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
fun
));
let
args
:
Vec
<
_
>
=
args
.into_iter
()
.map
(|
arg
|
unpack!
(
block
=
this
.as_local_call_operand
(
block
,
&
arg
)))
.map
(|
arg
|
unpack!
(
block
=
this
.as_local_call_operand
(
block
,
arg
)))
.collect
();
let
success
=
this
.cfg
.start_new_block
();
...
...
@@ -232,14 +231,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
else
{
Some
((
destination
,
success
))
},
from_hir_call
:
*
from_hir_call
,
fn_span
:
*
fn_span
,
from_hir_call
,
fn_span
,
},
);
this
.diverge_from
(
block
);
success
.unit
()
}
ExprKind
::
Use
{
source
}
=>
this
.expr_into_dest
(
destination
,
block
,
&
source
),
ExprKind
::
Use
{
source
}
=>
this
.expr_into_dest
(
destination
,
block
,
source
),
ExprKind
::
Borrow
{
arg
,
borrow_kind
}
=>
{
// We don't do this in `as_rvalue` because we use `as_place`
// for borrow expressions, so we cannot create an `RValue` that
...
...
@@ -247,23 +246,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// by this method anyway, so this shouldn't cause too many
// unnecessary temporaries.
let
arg_place
=
match
borrow_kind
{
BorrowKind
::
Shared
=>
unpack!
(
block
=
this
.as_read_only_place
(
block
,
&
arg
)),
_
=>
unpack!
(
block
=
this
.as_place
(
block
,
&
arg
)),
BorrowKind
::
Shared
=>
unpack!
(
block
=
this
.as_read_only_place
(
block
,
arg
)),
_
=>
unpack!
(
block
=
this
.as_place
(
block
,
arg
)),
};
let
borrow
=
Rvalue
::
Ref
(
this
.tcx.lifetimes.re_erased
,
*
borrow_kind
,
arg_place
);
let
borrow
=
Rvalue
::
Ref
(
this
.tcx.lifetimes.re_erased
,
borrow_kind
,
arg_place
);
this
.cfg
.push_assign
(
block
,
source_info
,
destination
,
borrow
);
block
.unit
()
}
ExprKind
::
AddressOf
{
mutability
,
arg
}
=>
{
let
place
=
match
mutability
{
hir
::
Mutability
::
Not
=>
this
.as_read_only_place
(
block
,
&
arg
),
hir
::
Mutability
::
Mut
=>
this
.as_place
(
block
,
&
arg
),
hir
::
Mutability
::
Not
=>
this
.as_read_only_place
(
block
,
arg
),
hir
::
Mutability
::
Mut
=>
this
.as_place
(
block
,
arg
),
};
let
address_of
=
Rvalue
::
AddressOf
(
*
mutability
,
unpack!
(
block
=
place
));
let
address_of
=
Rvalue
::
AddressOf
(
mutability
,
unpack!
(
block
=
place
));
this
.cfg
.push_assign
(
block
,
source_info
,
destination
,
address_of
);
block
.unit
()
}
ExprKind
::
Adt
{
adt_def
,
variant_index
,
substs
,
user_ty
,
fields
,
base
}
=>
{
ExprKind
::
Adt
{
adt_def
,
variant_index
,
substs
,
user_ty
,
fields
,
ref
base
}
=>
{
// See the notes for `ExprKind::Array` in `as_rvalue` and for
// `ExprKind::Borrow` above.
let
is_union
=
adt_def
.is_union
();
...
...
@@ -275,16 +274,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// (evaluating them in order given by user)
let
fields_map
:
FxHashMap
<
_
,
_
>
=
fields
.into_iter
()
.map
(|
f
|
{
(
f
.name
,
unpack!
(
block
=
this
.as_operand
(
block
,
Some
(
scope
),
&
f
.expr
)))
})
.map
(|
f
|
(
f
.name
,
unpack!
(
block
=
this
.as_operand
(
block
,
Some
(
scope
),
f
.expr
))))
.collect
();
let
field_names
:
Vec
<
_
>
=
(
0
..
adt_def
.variants
[
*
variant_index
]
.fields
.len
())
.map
(
Field
::
new
)
.collect
();
(
0
..
adt_def
.variants
[
variant_index
]
.fields
.len
())
.map
(
Field
::
new
)
.collect
();
let
fields
:
Vec
<
_
>
=
if
let
Some
(
FruInfo
{
base
,
field_types
})
=
base
{
let
place_builder
=
unpack!
(
block
=
this
.as_place_builder
(
block
,
&
base
));
let
place_builder
=
unpack!
(
block
=
this
.as_place_builder
(
block
,
base
));
// MIR does not natively support FRU, so for each
// base-supplied field, generate an operand that
...
...
@@ -318,7 +315,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
});
let
adt
=
box
AggregateKind
::
Adt
(
adt_def
,
*
variant_index
,
variant_index
,
substs
,
user_ty
,
active_field_index
,
...
...
@@ -336,25 +333,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
use
rustc_middle
::
mir
;
let
operands
=
operands
.into_iter
()
.map
(|
op
|
match
op
{
.map
(|
op
|
match
*
op
{
thir
::
InlineAsmOperand
::
In
{
reg
,
expr
}
=>
mir
::
InlineAsmOperand
::
In
{
reg
:
*
reg
,
value
:
unpack!
(
block
=
this
.as_local_operand
(
block
,
&
expr
)),
reg
,
value
:
unpack!
(
block
=
this
.as_local_operand
(
block
,
expr
)),
},
thir
::
InlineAsmOperand
::
Out
{
reg
,
late
,
expr
}
=>
{
mir
::
InlineAsmOperand
::
Out
{
reg
:
*
reg
,
late
:
*
late
,
reg
,
late
,
place
:
expr
.as_ref
()
.map
(|
expr
|
unpack!
(
block
=
this
.as_place
(
block
,
expr
))),
}
}
thir
::
InlineAsmOperand
::
InOut
{
reg
,
late
,
expr
}
=>
{
let
place
=
unpack!
(
block
=
this
.as_place
(
block
,
&
expr
));
let
place
=
unpack!
(
block
=
this
.as_place
(
block
,
expr
));
mir
::
InlineAsmOperand
::
InOut
{
reg
:
*
reg
,
late
:
*
late
,
reg
,
late
,
// This works because asm operands must be Copy
in_value
:
Operand
::
Copy
(
place
),
out_place
:
Some
(
place
),
...
...
@@ -362,22 +359,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
thir
::
InlineAsmOperand
::
SplitInOut
{
reg
,
late
,
in_expr
,
out_expr
}
=>
{
mir
::
InlineAsmOperand
::
InOut
{
reg
:
*
reg
,
late
:
*
late
,
in_value
:
unpack!
(
block
=
this
.as_local_operand
(
block
,
&
in_expr
)),
reg
,
late
,
in_value
:
unpack!
(
block
=
this
.as_local_operand
(
block
,
in_expr
)),
out_place
:
out_expr
.as_ref
()
.map
(|
out_expr
|
{
unpack!
(
block
=
this
.as_place
(
block
,
out_expr
))
}),
}
}
thir
::
InlineAsmOperand
::
Const
{
expr
}
=>
mir
::
InlineAsmOperand
::
Const
{
value
:
unpack!
(
block
=
this
.as_local_operand
(
block
,
&
expr
)),
value
:
unpack!
(
block
=
this
.as_local_operand
(
block
,
expr
)),
},
thir
::
InlineAsmOperand
::
SymFn
{
expr
}
=>
{
mir
::
InlineAsmOperand
::
SymFn
{
value
:
box
this
.as_constant
(
&
expr
)
}
mir
::
InlineAsmOperand
::
SymFn
{
value
:
box
this
.as_constant
(
expr
)
}
}
thir
::
InlineAsmOperand
::
SymStatic
{
def_id
}
=>
{
mir
::
InlineAsmOperand
::
SymStatic
{
def_id
:
*
def_id
}
mir
::
InlineAsmOperand
::
SymStatic
{
def_id
}
}
})
.collect
();
...
...
@@ -390,7 +387,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
TerminatorKind
::
InlineAsm
{
template
,
operands
,
options
:
*
options
,
options
,
line_spans
,
destination
:
if
options
.contains
(
InlineAsmOptions
::
NORETURN
)
{
None
...
...
@@ -449,7 +446,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ExprKind
::
Yield
{
value
}
=>
{
let
scope
=
this
.local_scope
();
let
value
=
unpack!
(
block
=
this
.as_operand
(
block
,
Some
(
scope
),
&
value
));
let
value
=
unpack!
(
block
=
this
.as_operand
(
block
,
Some
(
scope
),
value
));
let
resume
=
this
.cfg
.start_new_block
();
this
.cfg
.terminate
(
block
,
...
...
compiler/rustc_mir_build/src/build/expr/stmt.rs
浏览文件 @
cd049ef9
...
...
@@ -21,10 +21,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let
source_info
=
this
.source_info
(
expr
.span
);
// Handle a number of expressions that don't need a destination at all. This
// avoids needing a mountain of temporary `()` variables.
match
&
expr
.kind
{
match
expr
.kind
{
ExprKind
::
Scope
{
region_scope
,
lint_level
,
value
}
=>
{
this
.in_scope
((
*
region_scope
,
source_info
),
*
lint_level
,
|
this
|
{
this
.stmt_expr
(
block
,
&
value
,
statement_scope
)
this
.in_scope
((
region_scope
,
source_info
),
lint_level
,
|
this
|
{
this
.stmt_expr
(
block
,
value
,
statement_scope
)
})
}
ExprKind
::
Assign
{
lhs
,
rhs
}
=>
{
...
...
@@ -40,12 +40,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Generate better code for things that don't need to be
// dropped.
if
lhs
.ty
.needs_drop
(
this
.tcx
,
this
.param_env
)
{
let
rhs
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
&
rhs
));
let
lhs
=
unpack!
(
block
=
this
.as_place
(
block
,
&
lhs
));
let
rhs
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
rhs
));
let
lhs
=
unpack!
(
block
=
this
.as_place
(
block
,
lhs
));
unpack!
(
block
=
this
.build_drop_and_replace
(
block
,
lhs_span
,
lhs
,
rhs
));
}
else
{
let
rhs
=
unpack!
(
block
=
this
.as_local_rvalue
(
block
,
&
rhs
));
let
lhs
=
unpack!
(
block
=
this
.as_place
(
block
,
&
lhs
));
let
rhs
=
unpack!
(
block
=
this
.as_local_rvalue
(
block
,
rhs
));
let
lhs
=
unpack!
(
block
=
this
.as_place
(
block
,
lhs
));
this
.cfg
.push_assign
(
block
,
source_info
,
lhs
,
rhs
);
}
...
...
@@ -67,21 +67,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this
.block_context
.push
(
BlockFrame
::
SubExpr
);
// As above, RTL.
let
rhs
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
&
rhs
));
let
lhs
=
unpack!
(
block
=
this
.as_place
(
block
,
&
lhs
));
let
rhs
=
unpack!
(
block
=
this
.as_local_operand
(
block
,
rhs
));
let
lhs
=
unpack!
(
block
=
this
.as_place
(
block
,
lhs
));
// we don't have to drop prior contents or anything
// because AssignOp is only legal for Copy types
// (overloaded ops should be desugared into a call).
let
result
=
unpack!
(
block
=
this
.build_binary_op
(
block
,
*
op
,
expr_span
,
lhs_ty
,
Operand
::
Copy
(
lhs
),
rhs
)
block
=
this
.build_binary_op
(
block
,
op
,
expr_span
,
lhs_ty
,
Operand
::
Copy
(
lhs
),
rhs
)
);
this
.cfg
.push_assign
(
block
,
source_info
,
lhs
,
result
);
...
...
@@ -89,12 +83,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block
.unit
()
}
ExprKind
::
Continue
{
label
}
=>
{
this
.break_scope
(
block
,
None
,
BreakableTarget
::
Continue
(
*
label
),
source_info
)
this
.break_scope
(
block
,
None
,
BreakableTarget
::
Continue
(
label
),
source_info
)
}
ExprKind
::
Break
{
label
,
value
}
=>
this
.break_scope
(
block
,
value
.as_deref
(),
BreakableTarget
::
Break
(
*
label
),
BreakableTarget
::
Break
(
label
),
source_info
,
),
ExprKind
::
Return
{
value
}
=>
{
...
...
@@ -120,7 +114,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Statement
{
source_info
,
kind
:
StatementKind
::
LlvmInlineAsm
(
box
LlvmInlineAsm
{
asm
:
(
*
asm
)
.clone
(),
asm
:
asm
.clone
(),
outputs
,
inputs
,
}),
...
...
compiler/rustc_mir_build/src/build/matches/mod.rs
浏览文件 @
cd049ef9
...
...
@@ -1754,7 +1754,7 @@ fn bind_and_guard_matched_candidate<'pat>(
Guard
::
IfLet
(
pat
,
scrutinee
)
=>
{
let
scrutinee_span
=
scrutinee
.span
;
let
scrutinee_place
=
unpack!
(
block
=
self
.lower_scrutinee
(
block
,
&
scrutinee
,
scrutinee_span
));
unpack!
(
block
=
self
.lower_scrutinee
(
block
,
scrutinee
,
scrutinee_span
));
let
mut
guard_candidate
=
Candidate
::
new
(
scrutinee_place
,
&
pat
,
false
);
let
wildcard
=
Pat
::
wildcard_from_ty
(
pat
.ty
);
let
mut
otherwise_candidate
=
Candidate
::
new
(
scrutinee_place
,
&
wildcard
,
false
);
...
...
compiler/rustc_mir_build/src/build/mod.rs
浏览文件 @
cd049ef9
...
...
@@ -643,7 +643,7 @@ fn construct_fn<'tcx, A>(
fn_def
.did
.to_def_id
(),
&
arguments
,
arg_scope
,
&
expr
,
expr
,
)
}))
}));
...
...
compiler/rustc_mir_build/src/thir/cx/block.rs
浏览文件 @
cd049ef9
...
...
@@ -11,7 +11,7 @@ impl<'thir, 'tcx> Cx<'thir, 'tcx> {
crate
fn
mirror_block
(
&
mut
self
,
block
:
&
'tcx
hir
::
Block
<
'tcx
>
)
->
Block
<
'thir
,
'tcx
>
{
// We have to eagerly lower the "spine" of the statements
// in order to get the lexical scoping correctly.
let
stmts
=
self
.mirror_stmts
(
block
.hir_id.local_id
,
&*
block
.stmts
);
let
stmts
=
self
.mirror_stmts
(
block
.hir_id.local_id
,
block
.stmts
);
let
opt_destruction_scope
=
self
.region_scope_tree
.opt_destruction_scope
(
block
.hir_id.local_id
);
Block
{
...
...
@@ -23,7 +23,7 @@ impl<'thir, 'tcx> Cx<'thir, 'tcx> {
opt_destruction_scope
,
span
:
block
.span
,
stmts
,
expr
:
block
.expr
.
as_ref
()
.
map
(|
expr
|
self
.mirror_expr
(
expr
)),
expr
:
block
.expr
.map
(|
expr
|
self
.mirror_expr
(
expr
)),
safety_mode
:
match
block
.rules
{
hir
::
BlockCheckMode
::
DefaultBlock
=>
BlockSafety
::
Safe
,
hir
::
BlockCheckMode
::
UnsafeBlock
(
..
)
=>
BlockSafety
::
ExplicitUnsafe
(
block
.hir_id
),
...
...
@@ -59,7 +59,7 @@ fn mirror_stmts(
data
:
region
::
ScopeData
::
Remainder
(
region
::
FirstStatementIndex
::
new
(
index
)),
};
let
mut
pattern
=
self
.pattern_from_hir
(
&
local
.pat
);
let
mut
pattern
=
self
.pattern_from_hir
(
local
.pat
);
if
let
Some
(
ty
)
=
&
local
.ty
{
if
let
Some
(
&
user_ty
)
=
...
...
compiler/rustc_mir_build/src/thir/cx/expr.rs
浏览文件 @
cd049ef9
...
...
@@ -203,7 +203,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
ExprKind
::
Call
{
ty
:
method
.ty
,
fun
:
self
.arena
.alloc
(
method
),
args
:
&*
self
args
:
self
.arena
.alloc_from_iter
(
vec!
[
self
.mirror_expr_inner
(
fun
),
tupled_args
]),
from_hir_call
:
true
,
...
...
@@ -243,7 +243,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
adt_def
,
substs
,
variant_index
:
index
,
fields
:
&*
field_refs
,
fields
:
field_refs
,
user_ty
,
base
:
None
,
}
...
...
@@ -277,7 +277,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
if
self
.typeck_results
()
.is_method_call
(
expr
)
{
let
lhs
=
self
.mirror_expr_inner
(
lhs
);
let
rhs
=
self
.mirror_expr_inner
(
rhs
);
self
.overloaded_operator
(
expr
,
&*
self
.arena
.alloc_from_iter
(
vec!
[
lhs
,
rhs
]))
self
.overloaded_operator
(
expr
,
self
.arena
.alloc_from_iter
(
vec!
[
lhs
,
rhs
]))
}
else
{
ExprKind
::
AssignOp
{
op
:
bin_op
(
op
.node
),
...
...
@@ -297,7 +297,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
if
self
.typeck_results
()
.is_method_call
(
expr
)
{
let
lhs
=
self
.mirror_expr_inner
(
lhs
);
let
rhs
=
self
.mirror_expr_inner
(
rhs
);
self
.overloaded_operator
(
expr
,
&*
self
.arena
.alloc_from_iter
(
vec!
[
lhs
,
rhs
]))
self
.overloaded_operator
(
expr
,
self
.arena
.alloc_from_iter
(
vec!
[
lhs
,
rhs
]))
}
else
{
// FIXME overflow
match
op
.node
{
...
...
@@ -332,7 +332,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
expr
,
expr_ty
,
None
,
&*
self
.arena
.alloc_from_iter
(
vec!
[
lhs
,
index
]),
self
.arena
.alloc_from_iter
(
vec!
[
lhs
,
index
]),
expr
.span
,
)
}
else
{
...
...
@@ -347,7 +347,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
expr
,
expr_ty
,
None
,
&*
self
.arena
.alloc_from_iter
(
iter
::
once
(
arg
)),
self
.arena
.alloc_from_iter
(
iter
::
once
(
arg
)),
expr
.span
,
)
}
else
{
...
...
@@ -358,7 +358,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
hir
::
ExprKind
::
Unary
(
hir
::
UnOp
::
Not
,
ref
arg
)
=>
{
if
self
.typeck_results
()
.is_method_call
(
expr
)
{
let
arg
=
self
.mirror_expr_inner
(
arg
);
self
.overloaded_operator
(
expr
,
&*
self
.arena
.alloc_from_iter
(
iter
::
once
(
arg
)))
self
.overloaded_operator
(
expr
,
self
.arena
.alloc_from_iter
(
iter
::
once
(
arg
)))
}
else
{
ExprKind
::
Unary
{
op
:
UnOp
::
Not
,
arg
:
self
.mirror_expr
(
arg
)
}
}
...
...
@@ -367,7 +367,7 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'thir,
hir
::
ExprKind
::
Unary
(
hir
::
UnOp
::
Neg
,
ref
arg
)
=>
{
if
self
.typeck_results
()
.is_method_call
(
expr
)
{
let
arg
=
self
.mirror_expr_inner
(
arg
);
self
.overloaded_operator
(
expr
,
&*
self
.arena
.alloc_from_iter
(
iter
::
once
(
arg
)))
self
.overloaded_operator
(
expr
,
self
.arena
.alloc_from_iter
(
iter
::
once
(
arg
)))
}
else
if
let
hir
::
ExprKind
::
Lit
(
ref
lit
)
=
arg
.kind
{
ExprKind
::
Literal
{
literal
:
self
.const_eval_literal
(
&
lit
.node
,
expr_ty
,
lit
.span
,
true
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录