Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b3245a8d
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
b3245a8d
编写于
8月 24, 2022
作者:
N
Nicholas Nethercote
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Box `thir::ExprKind::Closure`.
This shrinks `thir::Expr`.
上级
2df805fc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
14 deletion
+36
-14
compiler/rustc_middle/src/thir.rs
compiler/rustc_middle/src/thir.rs
+11
-8
compiler/rustc_middle/src/thir/visit.rs
compiler/rustc_middle/src/thir/visit.rs
+9
-2
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+7
-1
compiler/rustc_mir_build/src/check_unsafety.rs
compiler/rustc_mir_build/src/check_unsafety.rs
+2
-2
compiler/rustc_mir_build/src/thir/cx/expr.rs
compiler/rustc_mir_build/src/thir/cx/expr.rs
+7
-1
未找到文件。
compiler/rustc_middle/src/thir.rs
浏览文件 @
b3245a8d
...
...
@@ -124,6 +124,15 @@ pub struct Adt<'tcx> {
pub
base
:
Option
<
FruInfo
<
'tcx
>>
,
}
#[derive(Clone,
Debug,
HashStable)]
pub
struct
ClosureExpr
<
'tcx
>
{
pub
closure_id
:
LocalDefId
,
pub
substs
:
UpvarSubsts
<
'tcx
>
,
pub
upvars
:
Box
<
[
ExprId
]
>
,
pub
movability
:
Option
<
hir
::
Movability
>
,
pub
fake_reads
:
Vec
<
(
ExprId
,
FakeReadCause
,
hir
::
HirId
)
>
,
}
#[derive(Copy,
Clone,
Debug,
HashStable)]
pub
enum
BlockSafety
{
Safe
,
...
...
@@ -387,13 +396,7 @@ pub enum ExprKind<'tcx> {
user_ty
:
UserTy
<
'tcx
>
,
},
/// A closure definition.
Closure
{
closure_id
:
LocalDefId
,
substs
:
UpvarSubsts
<
'tcx
>
,
upvars
:
Box
<
[
ExprId
]
>
,
movability
:
Option
<
hir
::
Movability
>
,
fake_reads
:
Vec
<
(
ExprId
,
FakeReadCause
,
hir
::
HirId
)
>
,
},
Closure
(
Box
<
ClosureExpr
<
'tcx
>>
),
/// A literal.
Literal
{
lit
:
&
'tcx
hir
::
Lit
,
...
...
@@ -801,7 +804,7 @@ mod size_asserts {
use
super
::
*
;
// These are in alphabetical order, which is easy to maintain.
static_assert_size!
(
Block
,
56
);
static_assert_size!
(
Expr
<
'_
>
,
8
8
);
static_assert_size!
(
Expr
<
'_
>
,
8
0
);
static_assert_size!
(
Pat
<
'_
>
,
24
);
static_assert_size!
(
Stmt
<
'_
>
,
72
);
}
compiler/rustc_middle/src/thir/visit.rs
浏览文件 @
b3245a8d
use
super
::{
Arm
,
Block
,
Expr
,
ExprKind
,
Guard
,
InlineAsmOperand
,
Pat
,
PatKind
,
Stmt
,
StmtKind
,
Thir
,
Arm
,
Block
,
ClosureExpr
,
Expr
,
ExprKind
,
Guard
,
InlineAsmOperand
,
Pat
,
PatKind
,
Stmt
,
StmtKind
,
Thir
,
};
pub
trait
Visitor
<
'a
,
'tcx
:
'a
>
:
Sized
{
...
...
@@ -126,7 +127,13 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
PlaceTypeAscription
{
source
,
user_ty
:
_
}
|
ValueTypeAscription
{
source
,
user_ty
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
source
])
}
Closure
{
closure_id
:
_
,
substs
:
_
,
upvars
:
_
,
movability
:
_
,
fake_reads
:
_
}
=>
{}
Closure
(
box
ClosureExpr
{
closure_id
:
_
,
substs
:
_
,
upvars
:
_
,
movability
:
_
,
fake_reads
:
_
,
})
=>
{}
Literal
{
lit
:
_
,
neg
:
_
}
=>
{}
NonHirLiteral
{
lit
:
_
,
user_ty
:
_
}
=>
{}
ZstLiteral
{
user_ty
:
_
}
=>
{}
...
...
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
浏览文件 @
b3245a8d
...
...
@@ -302,7 +302,13 @@ pub(crate) fn as_rvalue(
block
.and
(
Rvalue
::
Aggregate
(
Box
::
new
(
AggregateKind
::
Tuple
),
fields
))
}
ExprKind
::
Closure
{
closure_id
,
substs
,
ref
upvars
,
movability
,
ref
fake_reads
}
=>
{
ExprKind
::
Closure
(
box
ClosureExpr
{
closure_id
,
substs
,
ref
upvars
,
movability
,
ref
fake_reads
,
})
=>
{
// Convert the closure fake reads, if any, from `ExprRef` to mir `Place`
// and push the fake reads.
// This must come before creating the operands. This is required in case
...
...
compiler/rustc_mir_build/src/check_unsafety.rs
浏览文件 @
b3245a8d
...
...
@@ -402,13 +402,13 @@ fn visit_expr(&mut self, expr: &Expr<'tcx>) {
(
Bound
::
Unbounded
,
Bound
::
Unbounded
)
=>
{}
_
=>
self
.requires_unsafe
(
expr
.span
,
InitializingTypeWith
),
},
ExprKind
::
Closure
{
ExprKind
::
Closure
(
box
ClosureExpr
{
closure_id
,
substs
:
_
,
upvars
:
_
,
movability
:
_
,
fake_reads
:
_
,
}
=>
{
}
)
=>
{
let
closure_def
=
if
let
Some
((
did
,
const_param_id
))
=
ty
::
WithOptConstParam
::
try_lookup
(
closure_id
,
self
.tcx
)
{
...
...
compiler/rustc_mir_build/src/thir/cx/expr.rs
浏览文件 @
b3245a8d
...
...
@@ -548,7 +548,13 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx>
None
=>
Vec
::
new
(),
};
ExprKind
::
Closure
{
closure_id
:
def_id
,
substs
,
upvars
,
movability
,
fake_reads
}
ExprKind
::
Closure
(
Box
::
new
(
ClosureExpr
{
closure_id
:
def_id
,
substs
,
upvars
,
movability
,
fake_reads
,
}))
}
hir
::
ExprKind
::
Path
(
ref
qpath
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录