Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
82bd7196
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,发现更多精彩内容 >>
提交
82bd7196
编写于
5月 16, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: don't track var_hir_id or mutability in mir::UpvarDecl.
上级
61fcbfcd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
20 deletion
+20
-20
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+5
-10
src/librustc_mir/build/expr/as_rvalue.rs
src/librustc_mir/build/expr/as_rvalue.rs
+2
-2
src/librustc_mir/build/mod.rs
src/librustc_mir/build/mod.rs
+13
-8
未找到文件。
src/librustc/mir/mod.rs
浏览文件 @
82bd7196
...
...
@@ -4,7 +4,7 @@
use
crate
::
hir
::
def
::{
CtorKind
,
Namespace
};
use
crate
::
hir
::
def_id
::
DefId
;
use
crate
::
hir
::{
self
,
HirId
,
InlineAsm
as
HirInlineAsm
};
use
crate
::
hir
::{
self
,
InlineAsm
as
HirInlineAsm
};
use
crate
::
mir
::
interpret
::{
ConstValue
,
InterpError
,
Scalar
};
use
crate
::
mir
::
visit
::
MirVisitable
;
use
rustc_apfloat
::
ieee
::{
Double
,
Single
};
...
...
@@ -138,16 +138,16 @@ pub struct Mir<'tcx> {
/// If this MIR was built for a constant, this will be 0.
pub
arg_count
:
usize
,
/// Names and capture modes of all the closure upvars, assuming
/// the first argument is either the closure or a reference to it.
pub
upvar_decls
:
Vec
<
UpvarDecl
>
,
/// Mark an argument local (which must be a tuple) as getting passed as
/// its individual components at the LLVM level.
///
/// This is used for the "rust-call" ABI.
pub
spread_arg
:
Option
<
Local
>
,
/// Names and capture modes of all the closure upvars, assuming
/// the first argument is either the closure or a reference to it.
pub
upvar_decls
:
Vec
<
UpvarDecl
>
,
/// Mark this MIR of a const context other than const functions as having converted a `&&` or
/// `||` expression into `&` or `|` respectively. This is problematic because if we ever stop
/// this conversion from happening and use short circuiting, we will cause the following code
...
...
@@ -986,13 +986,8 @@ pub fn new_return_place(return_ty: Ty<'_>, span: Span) -> LocalDecl<'_> {
pub
struct
UpvarDecl
{
pub
debug_name
:
Name
,
/// `HirId` of the captured variable
pub
var_hir_id
:
ClearCrossCrate
<
HirId
>
,
/// If true, the capture is behind a reference.
pub
by_ref
:
bool
,
pub
mutability
:
Mutability
,
}
///////////////////////////////////////////////////////////////////////////
...
...
src/librustc_mir/build/expr/as_rvalue.rs
浏览文件 @
82bd7196
...
...
@@ -556,10 +556,10 @@ fn limit_capture_mutability(
);
// Not in a closure
debug_assert!
(
this
.upvar_
dec
ls
.len
()
>
upvar_index
.index
(),
this
.upvar_
mutb
ls
.len
()
>
upvar_index
.index
(),
"Unexpected capture place"
);
this
.upvar_
decls
[
upvar_index
.index
()]
.mutability
this
.upvar_
mutbls
[
upvar_index
.index
()]
}
_
=>
bug!
(
"Unexpected capture place"
),
};
...
...
src/librustc_mir/build/mod.rs
浏览文件 @
82bd7196
...
...
@@ -376,6 +376,7 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
local_decls
:
IndexVec
<
Local
,
LocalDecl
<
'tcx
>>
,
canonical_user_type_annotations
:
ty
::
CanonicalUserTypeAnnotations
<
'tcx
>
,
upvar_decls
:
Vec
<
UpvarDecl
>
,
upvar_mutbls
:
Vec
<
Mutability
>
,
unit_temp
:
Option
<
Place
<
'tcx
>>
,
/// Cached block with the `RESUME` terminator; this is created
...
...
@@ -625,6 +626,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
let
fn_def_id
=
tcx_hir
.local_def_id_from_hir_id
(
fn_id
);
// Gather the upvars of a closure, if any.
let
mut
upvar_mutbls
=
vec!
[];
// In analyze_closure() in upvar.rs we gathered a list of upvars used by a
// closure and we stored in a map called upvar_list in TypeckTables indexed
// with the closure's DefId. Here, we run through that vec of UpvarIds for
...
...
@@ -644,24 +646,24 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
};
let
mut
decl
=
UpvarDecl
{
debug_name
:
keywords
::
Invalid
.name
(),
var_hir_id
:
ClearCrossCrate
::
Set
(
var_hir_id
),
by_ref
,
mutability
:
Mutability
::
Not
,
};
let
mut
mutability
=
Mutability
::
Not
;
if
let
Some
(
Node
::
Binding
(
pat
))
=
tcx_hir
.find
(
var_node_id
)
{
if
let
hir
::
PatKind
::
Binding
(
_
,
_
,
ident
,
_
)
=
pat
.node
{
decl
.debug_name
=
ident
.name
;
if
let
Some
(
&
bm
)
=
hir
.tables
.pat_binding_modes
()
.get
(
pat
.hir_id
)
{
if
bm
==
ty
::
BindByValue
(
hir
::
MutMutable
)
{
decl
.
mutability
=
Mutability
::
Mut
;
mutability
=
Mutability
::
Mut
;
}
else
{
decl
.
mutability
=
Mutability
::
Not
;
mutability
=
Mutability
::
Not
;
}
}
else
{
tcx
.sess
.delay_span_bug
(
pat
.span
,
"missing binding mode"
);
}
}
}
upvar_mutbls
.push
(
mutability
);
decl
})
.collect
();
...
...
@@ -672,7 +674,8 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
safety
,
return_ty
,
return_ty_span
,
upvar_decls
);
upvar_decls
,
upvar_mutbls
);
let
call_site_scope
=
region
::
Scope
{
id
:
body
.value.hir_id.local_id
,
...
...
@@ -734,7 +737,7 @@ fn construct_const<'a, 'gcx, 'tcx>(
let
ty
=
hir
.tables
()
.expr_ty_adjusted
(
ast_expr
);
let
owner_id
=
tcx
.hir
()
.body_owner
(
body_id
);
let
span
=
tcx
.hir
()
.span
(
owner_id
);
let
mut
builder
=
Builder
::
new
(
hir
,
span
,
0
,
Safety
::
Safe
,
ty
,
ty_span
,
vec!
[]);
let
mut
builder
=
Builder
::
new
(
hir
,
span
,
0
,
Safety
::
Safe
,
ty
,
ty_span
,
vec!
[],
vec!
[]);
let
mut
block
=
START_BLOCK
;
let
expr
=
builder
.hir
.mirror
(
ast_expr
);
...
...
@@ -762,7 +765,7 @@ fn construct_error<'a, 'gcx, 'tcx>(hir: Cx<'a, 'gcx, 'tcx>,
let
owner_id
=
hir
.tcx
()
.hir
()
.body_owner
(
body_id
);
let
span
=
hir
.tcx
()
.hir
()
.span
(
owner_id
);
let
ty
=
hir
.tcx
()
.types.err
;
let
mut
builder
=
Builder
::
new
(
hir
,
span
,
0
,
Safety
::
Safe
,
ty
,
span
,
vec!
[]);
let
mut
builder
=
Builder
::
new
(
hir
,
span
,
0
,
Safety
::
Safe
,
ty
,
span
,
vec!
[]
,
vec!
[]
);
let
source_info
=
builder
.source_info
(
span
);
builder
.cfg
.terminate
(
START_BLOCK
,
source_info
,
TerminatorKind
::
Unreachable
);
builder
.finish
(
None
)
...
...
@@ -775,7 +778,8 @@ fn new(hir: Cx<'a, 'gcx, 'tcx>,
safety
:
Safety
,
return_ty
:
Ty
<
'tcx
>
,
return_span
:
Span
,
upvar_decls
:
Vec
<
UpvarDecl
>
)
upvar_decls
:
Vec
<
UpvarDecl
>
,
upvar_mutbls
:
Vec
<
Mutability
>
)
->
Builder
<
'a
,
'gcx
,
'tcx
>
{
let
lint_level
=
LintLevel
::
Explicit
(
hir
.root_lint_level
);
let
mut
builder
=
Builder
{
...
...
@@ -798,6 +802,7 @@ fn new(hir: Cx<'a, 'gcx, 'tcx>,
),
canonical_user_type_annotations
:
IndexVec
::
new
(),
upvar_decls
,
upvar_mutbls
,
var_indices
:
Default
::
default
(),
unit_temp
:
None
,
cached_resume_block
:
None
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录