Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
be9c64b0
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,发现更多精彩内容 >>
提交
be9c64b0
编写于
8月 11, 2017
作者:
J
John Kåre Alsaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Store generator interior in MIR literals
上级
91dde3eb
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
41 addition
and
29 deletion
+41
-29
src/librustc/ich/impls_mir.rs
src/librustc/ich/impls_mir.rs
+6
-2
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+7
-6
src/librustc/mir/tcx.rs
src/librustc/mir/tcx.rs
+2
-7
src/librustc/mir/visit.rs
src/librustc/mir/visit.rs
+14
-2
src/librustc_mir/build/expr/as_rvalue.rs
src/librustc_mir/build/expr/as_rvalue.rs
+3
-3
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/expr.rs
+5
-5
src/librustc_mir/hair/mod.rs
src/librustc_mir/hair/mod.rs
+2
-2
src/librustc_mir/transform/generator.rs
src/librustc_mir/transform/generator.rs
+2
-2
未找到文件。
src/librustc/ich/impls_mir.rs
浏览文件 @
be9c64b0
...
...
@@ -442,11 +442,15 @@ fn hash_stable<W: StableHasherResult>(&self,
substs
.hash_stable
(
hcx
,
hasher
);
active_field
.hash_stable
(
hcx
,
hasher
);
}
mir
::
AggregateKind
::
Closure
(
def_id
,
ref
substs
)
|
mir
::
AggregateKind
::
Generator
(
def_id
,
ref
substs
)
=>
{
mir
::
AggregateKind
::
Closure
(
def_id
,
ref
substs
)
=>
{
def_id
.hash_stable
(
hcx
,
hasher
);
substs
.hash_stable
(
hcx
,
hasher
);
}
mir
::
AggregateKind
::
Generator
(
def_id
,
ref
substs
,
ref
interior
)
=>
{
def_id
.hash_stable
(
hcx
,
hasher
);
substs
.hash_stable
(
hcx
,
hasher
);
interior
.hash_stable
(
hcx
,
hasher
);
}
}
}
}
...
...
src/librustc/mir/mod.rs
浏览文件 @
be9c64b0
...
...
@@ -21,7 +21,7 @@
use
hir
::
def
::
CtorKind
;
use
hir
::
def_id
::
DefId
;
use
ty
::
subst
::{
Subst
,
Substs
};
use
ty
::{
self
,
AdtDef
,
ClosureSubsts
,
Region
,
Ty
};
use
ty
::{
self
,
AdtDef
,
ClosureSubsts
,
Region
,
Ty
,
GeneratorInterior
};
use
ty
::
fold
::{
TypeFoldable
,
TypeFolder
,
TypeVisitor
};
use
util
::
ppaux
;
use
rustc_back
::
slice
;
...
...
@@ -1260,7 +1260,7 @@ pub enum AggregateKind<'tcx> {
/// number and is present only for union expressions.
Adt
(
&
'tcx
AdtDef
,
usize
,
&
'tcx
Substs
<
'tcx
>
,
Option
<
usize
>
),
Closure
(
DefId
,
ClosureSubsts
<
'tcx
>
),
Generator
(
DefId
,
ClosureSubsts
<
'tcx
>
),
Generator
(
DefId
,
ClosureSubsts
<
'tcx
>
,
GeneratorInterior
<
'tcx
>
),
}
#[derive(Copy,
Clone,
Debug,
PartialEq,
Eq,
RustcEncodable,
RustcDecodable)]
...
...
@@ -1423,7 +1423,7 @@ fn fmt_tuple(fmt: &mut Formatter, lvs: &[Operand]) -> fmt::Result {
}
}),
AggregateKind
::
Generator
(
def_id
,
_
)
=>
ty
::
tls
::
with
(|
tcx
|
{
AggregateKind
::
Generator
(
def_id
,
_
,
_
)
=>
ty
::
tls
::
with
(|
tcx
|
{
if
let
Some
(
node_id
)
=
tcx
.hir
.as_local_node_id
(
def_id
)
{
let
name
=
format!
(
"[generator@{:?}]"
,
tcx
.hir
.span
(
node_id
));
let
mut
struct_fmt
=
fmt
.debug_struct
(
&
name
);
...
...
@@ -1892,8 +1892,8 @@ fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F)
AggregateKind
::
Adt
(
def
,
v
,
substs
.fold_with
(
folder
),
n
),
AggregateKind
::
Closure
(
id
,
substs
)
=>
AggregateKind
::
Closure
(
id
,
substs
.fold_with
(
folder
)),
AggregateKind
::
Generator
(
id
,
substs
)
=>
AggregateKind
::
Generator
(
id
,
substs
.fold_with
(
folder
)),
AggregateKind
::
Generator
(
id
,
substs
,
interior
)
=>
AggregateKind
::
Generator
(
id
,
substs
.fold_with
(
folder
)
,
interior
.fold_with
(
folder
)
),
};
Aggregate
(
kind
,
fields
.fold_with
(
folder
))
}
...
...
@@ -1920,7 +1920,8 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
AggregateKind
::
Tuple
=>
false
,
AggregateKind
::
Adt
(
_
,
_
,
substs
,
_
)
=>
substs
.visit_with
(
visitor
),
AggregateKind
::
Closure
(
_
,
substs
)
=>
substs
.visit_with
(
visitor
),
AggregateKind
::
Generator
(
_
,
substs
)
=>
substs
.visit_with
(
visitor
),
AggregateKind
::
Generator
(
_
,
substs
,
interior
)
=>
substs
.visit_with
(
visitor
)
||
interior
.visit_with
(
visitor
),
})
||
fields
.visit_with
(
visitor
)
}
}
...
...
src/librustc/mir/tcx.rs
浏览文件 @
be9c64b0
...
...
@@ -202,13 +202,8 @@ pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> T
AggregateKind
::
Closure
(
did
,
substs
)
=>
{
tcx
.mk_closure_from_closure_substs
(
did
,
substs
)
}
AggregateKind
::
Generator
(
did
,
substs
)
=>
{
let
node_id
=
tcx
.hir
.as_local_node_id
(
did
)
.unwrap
();
let
interior
=
*
tcx
.typeck_tables_of
(
did
)
.generator_interiors
.get
(
&
node_id
)
.unwrap
();
tcx
.mk_generator
(
did
,
substs
,
interior
.subst
(
tcx
,
substs
.substs
))
AggregateKind
::
Generator
(
did
,
substs
,
interior
)
=>
{
tcx
.mk_generator
(
did
,
substs
,
interior
)
}
}
}
...
...
src/librustc/mir/visit.rs
浏览文件 @
be9c64b0
...
...
@@ -11,7 +11,7 @@
use
middle
::
const_val
::
ConstVal
;
use
hir
::
def_id
::
DefId
;
use
ty
::
subst
::
Substs
;
use
ty
::{
ClosureSubsts
,
Region
,
Ty
};
use
ty
::{
ClosureSubsts
,
Region
,
Ty
,
GeneratorInterior
};
use
mir
::
*
;
use
rustc_const_math
::
ConstUsize
;
use
syntax_pos
::
Span
;
...
...
@@ -226,6 +226,12 @@ fn visit_closure_substs(&mut self,
self
.super_closure_substs
(
substs
);
}
fn
visit_generator_interior
(
&
mut
self
,
interior
:
&
$
(
$mutability
)
*
GeneratorInterior
<
'tcx
>
,
_
:
Location
)
{
self
.super_generator_interior
(
interior
);
}
fn
visit_const_val
(
&
mut
self
,
const_val
:
&
$
(
$mutability
)
*
ConstVal
,
_
:
Location
)
{
...
...
@@ -570,9 +576,11 @@ fn super_rvalue(&mut self,
self
.visit_closure_substs
(
closure_substs
,
location
);
}
AggregateKind
::
Generator
(
ref
$
(
$mutability
)
*
def_id
,
ref
$
(
$mutability
)
*
closure_substs
)
=>
{
ref
$
(
$mutability
)
*
closure_substs
,
ref
$
(
$mutability
)
*
interior
)
=>
{
self
.visit_def_id
(
def_id
,
location
);
self
.visit_closure_substs
(
closure_substs
,
location
);
self
.visit_generator_interior
(
interior
,
location
);
}
}
...
...
@@ -742,6 +750,10 @@ fn super_ty(&mut self, _ty: & $($mutability)* Ty<'tcx>) {
fn
super_substs
(
&
mut
self
,
_
substs
:
&
$
(
$mutability
)
*
&
'tcx
Substs
<
'tcx
>
)
{
}
fn
super_generator_interior
(
&
mut
self
,
_
interior
:
&
$
(
$mutability
)
*
GeneratorInterior
<
'tcx
>
)
{
}
fn
super_closure_substs
(
&
mut
self
,
_
substs
:
&
$
(
$mutability
)
*
ClosureSubsts
<
'tcx
>
)
{
}
...
...
src/librustc_mir/build/expr/as_rvalue.rs
浏览文件 @
be9c64b0
...
...
@@ -179,12 +179,12 @@ fn expr_as_rvalue(&mut self,
block
.and
(
Rvalue
::
Aggregate
(
box
AggregateKind
::
Tuple
,
fields
))
}
ExprKind
::
Closure
{
closure_id
,
substs
,
upvars
,
generat
or
}
=>
{
// see (*) above
ExprKind
::
Closure
{
closure_id
,
substs
,
upvars
,
interi
or
}
=>
{
// see (*) above
let
mut
operands
:
Vec
<
_
>
=
upvars
.into_iter
()
.map
(|
upvar
|
unpack!
(
block
=
this
.as_operand
(
block
,
scope
,
upvar
)))
.collect
();
let
result
=
if
generat
or
{
let
result
=
if
let
Some
(
interior
)
=
interi
or
{
// Add the state operand
operands
.push
(
Operand
::
Constant
(
box
Constant
{
span
:
expr_span
,
...
...
@@ -193,7 +193,7 @@ fn expr_as_rvalue(&mut self,
value
:
ConstVal
::
Integral
(
ConstInt
::
U32
(
0
)),
},
}));
box
AggregateKind
::
Generator
(
closure_id
,
substs
)
box
AggregateKind
::
Generator
(
closure_id
,
substs
,
interior
)
}
else
{
box
AggregateKind
::
Closure
(
closure_id
,
substs
)
};
...
...
src/librustc_mir/hair/cx/expr.rs
浏览文件 @
be9c64b0
...
...
@@ -428,11 +428,11 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
}
}
hir
::
ExprClosure
(
..
,
is_generator
)
=>
{
hir
::
ExprClosure
(
..
)
=>
{
let
closure_ty
=
cx
.tables
()
.expr_ty
(
expr
);
let
(
def_id
,
substs
)
=
match
closure_ty
.sty
{
ty
::
TyClosure
(
def_id
,
substs
)
|
ty
::
TyGenerator
(
def_id
,
substs
,
_
)
=>
(
def_id
,
substs
),
let
(
def_id
,
substs
,
interior
)
=
match
closure_ty
.sty
{
ty
::
TyClosure
(
def_id
,
substs
)
=>
(
def_id
,
substs
,
None
),
ty
::
TyGenerator
(
def_id
,
substs
,
interior
)
=>
(
def_id
,
substs
,
Some
(
interior
)
),
_
=>
{
span_bug!
(
expr
.span
,
"closure expr w/o closure type: {:?}"
,
closure_ty
);
}
...
...
@@ -447,7 +447,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
closure_id
:
def_id
,
substs
:
substs
,
upvars
:
upvars
,
generator
:
is_generat
or
,
interi
or
,
}
}
...
...
src/librustc_mir/hair/mod.rs
浏览文件 @
be9c64b0
...
...
@@ -19,7 +19,7 @@
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc
::
middle
::
region
::
CodeExtent
;
use
rustc
::
ty
::
subst
::
Substs
;
use
rustc
::
ty
::{
self
,
AdtDef
,
ClosureSubsts
,
Region
,
Ty
};
use
rustc
::
ty
::{
self
,
AdtDef
,
ClosureSubsts
,
Region
,
Ty
,
GeneratorInterior
};
use
rustc
::
hir
;
use
syntax
::
ast
;
use
syntax_pos
::
Span
;
...
...
@@ -239,7 +239,7 @@ pub enum ExprKind<'tcx> {
closure_id
:
DefId
,
substs
:
ClosureSubsts
<
'tcx
>
,
upvars
:
Vec
<
ExprRef
<
'tcx
>>
,
generator
:
bool
,
interior
:
Option
<
GeneratorInterior
<
'tcx
>>
,
},
Literal
{
literal
:
Literal
<
'tcx
>
,
...
...
src/librustc_mir/transform/generator.rs
浏览文件 @
be9c64b0
...
...
@@ -76,8 +76,8 @@ struct TransformVisitor<'a, 'tcx: 'a> {
// The number of generator states. 0 is unresumed, 1 is poisoned. So this is initialized to 2
bb_target_count
:
u32
,
// Map from a (which block to resume execution at, which block to use to drop the generator)
to a
//
gen
rator state
// Map from a (which block to resume execution at, which block to use to drop the generator)
//
to a gene
rator state
bb_targets
:
HashMap
<
(
BasicBlock
,
Option
<
BasicBlock
>
),
u32
>
,
// The original RETURN_POINTER local
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录