Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c60fb12a
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,发现更多精彩内容 >>
提交
c60fb12a
编写于
11月 21, 2022
作者:
M
Maybe Waffle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
`thir`: Add `Become` expression kind
上级
b5e51db1
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
32 addition
and
9 deletion
+32
-9
compiler/rustc_middle/src/thir.rs
compiler/rustc_middle/src/thir.rs
+4
-0
compiler/rustc_middle/src/thir/visit.rs
compiler/rustc_middle/src/thir/visit.rs
+1
-0
compiler/rustc_mir_build/src/build/expr/as_place.rs
compiler/rustc_mir_build/src/build/expr/as_place.rs
+1
-0
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
+1
-0
compiler/rustc_mir_build/src/build/expr/category.rs
compiler/rustc_mir_build/src/build/expr/category.rs
+2
-1
compiler/rustc_mir_build/src/build/expr/into.rs
compiler/rustc_mir_build/src/build/expr/into.rs
+4
-1
compiler/rustc_mir_build/src/build/expr/stmt.rs
compiler/rustc_mir_build/src/build/expr/stmt.rs
+7
-0
compiler/rustc_mir_build/src/check_unsafety.rs
compiler/rustc_mir_build/src/check_unsafety.rs
+1
-0
compiler/rustc_mir_build/src/thir/cx/expr.rs
compiler/rustc_mir_build/src/thir/cx/expr.rs
+2
-6
compiler/rustc_mir_build/src/thir/print.rs
compiler/rustc_mir_build/src/thir/print.rs
+6
-0
compiler/rustc_ty_utils/src/consts.rs
compiler/rustc_ty_utils/src/consts.rs
+3
-1
未找到文件。
compiler/rustc_middle/src/thir.rs
浏览文件 @
c60fb12a
...
...
@@ -410,6 +410,10 @@ pub enum ExprKind<'tcx> {
Return
{
value
:
Option
<
ExprId
>
,
},
/// A `become` expression.
Become
{
value
:
ExprId
,
},
/// An inline `const` block, e.g. `const {}`.
ConstBlock
{
did
:
DefId
,
...
...
compiler/rustc_middle/src/thir/visit.rs
浏览文件 @
c60fb12a
...
...
@@ -100,6 +100,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
visitor
.visit_expr
(
&
visitor
.thir
()[
value
])
}
}
Become
{
value
}
=>
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]),
ConstBlock
{
did
:
_
,
substs
:
_
}
=>
{}
Repeat
{
value
,
count
:
_
}
=>
{
visitor
.visit_expr
(
&
visitor
.thir
()[
value
]);
...
...
compiler/rustc_mir_build/src/build/expr/as_place.rs
浏览文件 @
c60fb12a
...
...
@@ -549,6 +549,7 @@ fn expr_as_place(
|
ExprKind
::
Break
{
..
}
|
ExprKind
::
Continue
{
..
}
|
ExprKind
::
Return
{
..
}
|
ExprKind
::
Become
{
..
}
|
ExprKind
::
Literal
{
..
}
|
ExprKind
::
NamedConst
{
..
}
|
ExprKind
::
NonHirLiteral
{
..
}
...
...
compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
浏览文件 @
c60fb12a
...
...
@@ -532,6 +532,7 @@ pub(crate) fn as_rvalue(
|
ExprKind
::
Break
{
..
}
|
ExprKind
::
Continue
{
..
}
|
ExprKind
::
Return
{
..
}
|
ExprKind
::
Become
{
..
}
|
ExprKind
::
InlineAsm
{
..
}
|
ExprKind
::
PlaceTypeAscription
{
..
}
|
ExprKind
::
ValueTypeAscription
{
..
}
=>
{
...
...
compiler/rustc_mir_build/src/build/expr/category.rs
浏览文件 @
c60fb12a
...
...
@@ -82,7 +82,8 @@ pub(crate) fn of(ek: &ExprKind<'_>) -> Option<Category> {
|
ExprKind
::
Block
{
..
}
|
ExprKind
::
Break
{
..
}
|
ExprKind
::
Continue
{
..
}
|
ExprKind
::
Return
{
..
}
=>
|
ExprKind
::
Return
{
..
}
|
ExprKind
::
Become
{
..
}
=>
// FIXME(#27840) these probably want their own
// category, like "nonterminating"
{
...
...
compiler/rustc_mir_build/src/build/expr/into.rs
浏览文件 @
c60fb12a
...
...
@@ -493,7 +493,10 @@ pub(crate) fn expr_into_dest(
block
.unit
()
}
ExprKind
::
Continue
{
..
}
|
ExprKind
::
Break
{
..
}
|
ExprKind
::
Return
{
..
}
=>
{
ExprKind
::
Continue
{
..
}
|
ExprKind
::
Break
{
..
}
|
ExprKind
::
Return
{
..
}
|
ExprKind
::
Become
{
..
}
=>
{
unpack!
(
block
=
this
.stmt_expr
(
block
,
expr
,
None
));
// No assign, as these have type `!`.
block
.unit
()
...
...
compiler/rustc_mir_build/src/build/expr/stmt.rs
浏览文件 @
c60fb12a
...
...
@@ -99,6 +99,13 @@ pub(crate) fn stmt_expr(
BreakableTarget
::
Return
,
source_info
,
),
// FIXME(explicit_tail_calls): properly lower tail calls here
ExprKind
::
Become
{
value
}
=>
this
.break_scope
(
block
,
Some
(
&
this
.thir
[
value
]),
BreakableTarget
::
Return
,
source_info
,
),
_
=>
{
assert
!
(
statement_scope
.is_some
(),
...
...
compiler/rustc_mir_build/src/check_unsafety.rs
浏览文件 @
c60fb12a
...
...
@@ -316,6 +316,7 @@ fn visit_expr(&mut self, expr: &Expr<'tcx>) {
|
ExprKind
::
Closure
{
..
}
|
ExprKind
::
Continue
{
..
}
|
ExprKind
::
Return
{
..
}
|
ExprKind
::
Become
{
..
}
|
ExprKind
::
Yield
{
..
}
|
ExprKind
::
Loop
{
..
}
|
ExprKind
::
Let
{
..
}
...
...
compiler/rustc_mir_build/src/thir/cx/expr.rs
浏览文件 @
c60fb12a
...
...
@@ -694,12 +694,8 @@ fn make_mirror_unadjusted(&mut self, expr: &'tcx hir::Expr<'tcx>) -> Expr<'tcx>
ExprKind
::
Repeat
{
value
:
self
.mirror_expr
(
v
),
count
:
*
count
}
}
hir
::
ExprKind
::
Ret
(
ref
v
)
=>
ExprKind
::
Return
{
value
:
v
.map
(|
v
|
self
.mirror_expr
(
v
))
},
hir
::
ExprKind
::
Become
(
call
)
=>
{
// FIXME(explicit_tail_calls): use `ExprKind::Become` once we implemented it
// Temporary transform `become` into a `return`, so we can write tests for code before this stage
ExprKind
::
Return
{
value
:
Some
(
self
.mirror_expr
(
call
))
}
}
hir
::
ExprKind
::
Ret
(
v
)
=>
ExprKind
::
Return
{
value
:
v
.map
(|
v
|
self
.mirror_expr
(
v
))
},
hir
::
ExprKind
::
Become
(
call
)
=>
ExprKind
::
Become
{
value
:
self
.mirror_expr
(
call
)
},
hir
::
ExprKind
::
Break
(
dest
,
ref
value
)
=>
match
dest
.target_id
{
Ok
(
target_id
)
=>
ExprKind
::
Break
{
label
:
region
::
Scope
{
id
:
target_id
.local_id
,
data
:
region
::
ScopeData
::
Node
},
...
...
compiler/rustc_mir_build/src/thir/print.rs
浏览文件 @
c60fb12a
...
...
@@ -421,6 +421,12 @@ fn print_expr_kind(&mut self, expr_kind: &ExprKind<'tcx>, depth_lvl: usize) {
print_indented!
(
self
,
"}"
,
depth_lvl
);
}
Become
{
value
}
=>
{
print_indented!
(
self
,
"Become {"
,
depth_lvl
);
print_indented!
(
self
,
"value:"
,
depth_lvl
+
1
);
self
.print_expr
(
*
value
,
depth_lvl
+
2
);
print_indented!
(
self
,
"}"
,
depth_lvl
);
}
ConstBlock
{
did
,
substs
}
=>
{
print_indented!
(
self
,
"ConstBlock {"
,
depth_lvl
);
print_indented!
(
self
,
format!
(
"did: {:?}"
,
did
),
depth_lvl
+
1
);
...
...
compiler/rustc_ty_utils/src/consts.rs
浏览文件 @
c60fb12a
...
...
@@ -241,7 +241,8 @@ fn recurse_build<'tcx>(
ExprKind
::
Assign
{
..
}
|
ExprKind
::
AssignOp
{
..
}
=>
{
error
(
GenericConstantTooComplexSub
::
AssignNotSupported
(
node
.span
))
?
}
ExprKind
::
Closure
{
..
}
|
ExprKind
::
Return
{
..
}
=>
{
// FIXME(explicit_tail_calls): maybe get `become` a new error
ExprKind
::
Closure
{
..
}
|
ExprKind
::
Return
{
..
}
|
ExprKind
::
Become
{
..
}
=>
{
error
(
GenericConstantTooComplexSub
::
ClosureAndReturnNotSupported
(
node
.span
))
?
}
// let expressions imply control flow
...
...
@@ -337,6 +338,7 @@ fn expr_is_poly(&mut self, expr: &thir::Expr<'tcx>) -> bool {
|
thir
::
ExprKind
::
Break
{
..
}
|
thir
::
ExprKind
::
Continue
{
..
}
|
thir
::
ExprKind
::
Return
{
..
}
|
thir
::
ExprKind
::
Become
{
..
}
|
thir
::
ExprKind
::
Array
{
..
}
|
thir
::
ExprKind
::
Tuple
{
..
}
|
thir
::
ExprKind
::
Adt
(
_
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录