Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b10c157b
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,发现更多精彩内容 >>
提交
b10c157b
编写于
5月 29, 2018
作者:
E
Eduard-Mihai Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: turn mir::LocalDecl's syntactic_scope into a SourceInfo.
上级
ca1ac6b6
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
53 addition
and
33 deletion
+53
-33
src/librustc/ich/impls_mir.rs
src/librustc/ich/impls_mir.rs
+1
-1
src/librustc/mir/mod.rs
src/librustc/mir/mod.rs
+19
-10
src/librustc/mir/visit.rs
src/librustc/mir/visit.rs
+2
-2
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/mod.rs
+1
-1
src/librustc_mir/build/expr/into.rs
src/librustc_mir/build/expr/into.rs
+1
-1
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/matches/mod.rs
+11
-7
src/librustc_mir/build/mod.rs
src/librustc_mir/build/mod.rs
+6
-5
src/librustc_mir/shim.rs
src/librustc_mir/shim.rs
+3
-2
src/librustc_mir/transform/generator.rs
src/librustc_mir/transform/generator.rs
+5
-4
src/librustc_mir/transform/inline.rs
src/librustc_mir/transform/inline.rs
+3
-0
src/librustc_mir/transform/promote_consts.rs
src/librustc_mir/transform/promote_consts.rs
+1
-0
未找到文件。
src/librustc/ich/impls_mir.rs
浏览文件 @
b10c157b
...
...
@@ -26,8 +26,8 @@
ty
,
name
,
source_info
,
syntactic_source_info
,
internal
,
syntactic_scope
,
is_user_variable
});
impl_stable_hash_for!
(
struct
mir
::
UpvarDecl
{
debug_name
,
by_ref
,
mutability
});
...
...
src/librustc/mir/mod.rs
浏览文件 @
b10c157b
...
...
@@ -506,7 +506,7 @@ pub struct LocalDecl<'tcx> {
pub
name
:
Option
<
Name
>
,
/// Source info of the local. The `SourceScope` is the *visibility* one,
/// not the the *syntactic* one (see `syntactic_s
cope
` for more details).
/// not the the *syntactic* one (see `syntactic_s
ource_info
` for more details).
pub
source_info
:
SourceInfo
,
/// The *syntactic* (i.e. not visibility) source scope the local is defined
...
...
@@ -560,9 +560,9 @@ pub struct LocalDecl<'tcx> {
/// `drop(x)`, we want it to refer to `x: u32`.
///
/// To allow both uses to work, we need to have more than a single scope
/// for a local. We have the `syntactic_scope` represent the
/// for a local. We have the `syntactic_s
ource_info.s
cope` represent the
/// "syntactic" lint scope (with a variable being under its let
/// block) while the
source-info scope
represents the "local variable"
/// block) while the
`source_info.scope`
represents the "local variable"
/// scope (where the "rest" of a block is under all prior let-statements).
///
/// The end result looks like this:
...
...
@@ -574,10 +574,10 @@ pub struct LocalDecl<'tcx> {
/// │ │{ #[allow(unused_mut] } // this is actually split into 2 scopes
/// │ │ // in practice because I'm lazy.
/// │ │
/// │ │← x.syntactic_scope
/// │ │← x.syntactic_s
ource_info.s
cope
/// │ │← `x.parse().unwrap()`
/// │ │
/// │ │ │← y.syntactic_scope
/// │ │ │← y.syntactic_s
ource_info.s
cope
/// │ │
/// │ │ │{ let y: u32 }
/// │ │ │
...
...
@@ -588,7 +588,7 @@ pub struct LocalDecl<'tcx> {
/// │ │← x.source_info.scope
/// │ │← `drop(x)` // this accesses `x: u32`
/// ```
pub
syntactic_s
cope
:
SourceScope
,
pub
syntactic_s
ource_info
:
SourceInfo
,
}
impl
<
'tcx
>
LocalDecl
<
'tcx
>
{
...
...
@@ -603,7 +603,10 @@ pub fn new_temp(ty: Ty<'tcx>, span: Span) -> Self {
span
,
scope
:
OUTERMOST_SOURCE_SCOPE
},
syntactic_scope
:
OUTERMOST_SOURCE_SCOPE
,
syntactic_source_info
:
SourceInfo
{
span
,
scope
:
OUTERMOST_SOURCE_SCOPE
},
internal
:
false
,
is_user_variable
:
false
}
...
...
@@ -620,7 +623,10 @@ pub fn new_internal(ty: Ty<'tcx>, span: Span) -> Self {
span
,
scope
:
OUTERMOST_SOURCE_SCOPE
},
syntactic_scope
:
OUTERMOST_SOURCE_SCOPE
,
syntactic_source_info
:
SourceInfo
{
span
,
scope
:
OUTERMOST_SOURCE_SCOPE
},
internal
:
true
,
is_user_variable
:
false
}
...
...
@@ -638,7 +644,10 @@ pub fn new_return_place(return_ty: Ty, span: Span) -> LocalDecl {
span
,
scope
:
OUTERMOST_SOURCE_SCOPE
},
syntactic_scope
:
OUTERMOST_SOURCE_SCOPE
,
syntactic_source_info
:
SourceInfo
{
span
,
scope
:
OUTERMOST_SOURCE_SCOPE
},
internal
:
false
,
name
:
None
,
// FIXME maybe we do want some name here?
is_user_variable
:
false
...
...
@@ -2192,7 +2201,7 @@ impl<'tcx> TypeFoldable<'tcx> for LocalDecl<'tcx> {
ty
,
name
,
source_info
,
syntactic_s
cope
,
syntactic_s
ource_info
,
}
}
...
...
src/librustc/mir/visit.rs
浏览文件 @
b10c157b
...
...
@@ -716,7 +716,7 @@ fn super_local_decl(&mut self,
name
:
_
,
ref
$
(
$mutability
)
*
source_info
,
internal
:
_
,
ref
$
(
$mutability
)
*
syntactic_s
cope
,
ref
$
(
$mutability
)
*
syntactic_s
ource_info
,
is_user_variable
:
_
,
}
=
*
local_decl
;
...
...
@@ -724,8 +724,8 @@ fn super_local_decl(&mut self,
local
,
source_info
:
*
source_info
,
});
self
.visit_source_info
(
syntactic_source_info
);
self
.visit_source_info
(
source_info
);
self
.visit_source_scope
(
syntactic_scope
);
}
fn
super_source_scope
(
&
mut
self
,
...
...
src/librustc_mir/borrow_check/mod.rs
浏览文件 @
b10c157b
...
...
@@ -311,7 +311,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
tcx
.struct_span_lint_node
(
UNUSED_MUT
,
vsi
[
local_decl
.syntactic_scope
]
.lint_root
,
vsi
[
local_decl
.syntactic_s
ource_info.s
cope
]
.lint_root
,
source_info
.span
,
"variable does not need to be mutable"
)
...
...
src/librustc_mir/build/expr/into.rs
浏览文件 @
b10c157b
...
...
@@ -247,7 +247,7 @@ pub fn into_expr(&mut self,
ty
:
ptr_ty
,
name
:
None
,
source_info
,
syntactic_s
cope
:
source_info
.scope
,
syntactic_s
ource_info
:
source_info
,
internal
:
true
,
is_user_variable
:
false
});
...
...
src/librustc_mir/build/matches/mod.rs
浏览文件 @
b10c157b
...
...
@@ -314,7 +314,7 @@ pub fn declare_bindings(&mut self,
None
));
// If we have lints, create a new source scope
// that marks the lints for the locals. See the comment
// on the `syntactic_s
cope
` field for why this is needed.
// on the `syntactic_s
ource_info
` field for why this is needed.
if
lint_level
.is_explicit
()
{
syntactic_scope
=
this
.new_source_scope
(
scope_span
,
lint_level
,
None
);
...
...
@@ -324,7 +324,11 @@ pub fn declare_bindings(&mut self,
span
,
scope
:
var_scope
.unwrap
()
};
this
.declare_binding
(
source_info
,
syntactic_scope
,
mutability
,
name
,
var
,
let
syntactic_source_info
=
SourceInfo
{
span
,
scope
:
syntactic_scope
,
};
this
.declare_binding
(
source_info
,
syntactic_source_info
,
mutability
,
name
,
var
,
ty
,
has_guard
);
});
var_scope
...
...
@@ -1114,7 +1118,7 @@ fn bind_matched_candidate_for_arm_body(&mut self,
/// in the arm body, which will have type `T`.
fn
declare_binding
(
&
mut
self
,
source_info
:
SourceInfo
,
syntactic_s
cope
:
SourceScope
,
syntactic_s
ource_info
:
SourceInfo
,
mutability
:
Mutability
,
name
:
Name
,
var_id
:
NodeId
,
...
...
@@ -1122,8 +1126,8 @@ fn declare_binding(&mut self,
has_guard
:
ArmHasGuard
)
{
debug!
(
"declare_binding(var_id={:?}, name={:?}, var_ty={:?}, source_info={:?},
\
syntactic_s
cope
={:?})"
,
var_id
,
name
,
var_ty
,
source_info
,
syntactic_s
cope
);
syntactic_s
ource_info
={:?})"
,
var_id
,
name
,
var_ty
,
source_info
,
syntactic_s
ource_info
);
let
tcx
=
self
.hir
.tcx
();
let
local
=
LocalDecl
::
<
'tcx
>
{
...
...
@@ -1131,7 +1135,7 @@ fn declare_binding(&mut self,
ty
:
var_ty
.clone
(),
name
:
Some
(
name
),
source_info
,
syntactic_s
cope
,
syntactic_s
ource_info
,
internal
:
false
,
is_user_variable
:
true
,
};
...
...
@@ -1143,7 +1147,7 @@ fn declare_binding(&mut self,
ty
:
tcx
.mk_imm_ref
(
tcx
.types.re_empty
,
var_ty
),
name
:
Some
(
name
),
source_info
,
syntactic_s
cope
,
syntactic_s
ource_info
,
internal
:
false
,
is_user_variable
:
true
,
});
...
...
src/librustc_mir/build/mod.rs
浏览文件 @
b10c157b
...
...
@@ -657,14 +657,15 @@ fn args_and_body(&mut self,
}
}
let
source_info
=
SourceInfo
{
scope
:
OUTERMOST_SOURCE_SCOPE
,
span
:
pattern
.map_or
(
self
.fn_span
,
|
pat
|
pat
.span
)
};
self
.local_decls
.push
(
LocalDecl
{
mutability
:
Mutability
::
Mut
,
ty
,
source_info
:
SourceInfo
{
scope
:
OUTERMOST_SOURCE_SCOPE
,
span
:
pattern
.map_or
(
self
.fn_span
,
|
pat
|
pat
.span
)
},
syntactic_scope
:
OUTERMOST_SOURCE_SCOPE
,
source_info
,
syntactic_source_info
:
source_info
,
name
,
internal
:
false
,
is_user_variable
:
false
,
...
...
src/librustc_mir/shim.rs
浏览文件 @
b10c157b
...
...
@@ -138,10 +138,11 @@ enum CallKind {
}
fn
temp_decl
(
mutability
:
Mutability
,
ty
:
Ty
,
span
:
Span
)
->
LocalDecl
{
let
source_info
=
SourceInfo
{
scope
:
OUTERMOST_SOURCE_SCOPE
,
span
};
LocalDecl
{
mutability
,
ty
,
name
:
None
,
source_info
:
SourceInfo
{
scope
:
OUTERMOST_SOURCE_SCOPE
,
span
}
,
syntactic_s
cope
:
OUTERMOST_SOURCE_SCOPE
,
source_info
,
syntactic_s
ource_info
:
source_info
,
internal
:
false
,
is_user_variable
:
false
}
...
...
src/librustc_mir/transform/generator.rs
浏览文件 @
b10c157b
...
...
@@ -295,12 +295,13 @@ fn make_generator_state_argument_indirect<'a, 'tcx>(
fn
replace_result_variable
<
'tcx
>
(
ret_ty
:
Ty
<
'tcx
>
,
mir
:
&
mut
Mir
<
'tcx
>
)
->
Local
{
let
source_info
=
source_info
(
mir
);
let
new_ret
=
LocalDecl
{
mutability
:
Mutability
::
Mut
,
ty
:
ret_ty
,
name
:
None
,
source_info
:
source_info
(
mir
)
,
syntactic_s
cope
:
OUTERMOST_SOURCE_SCOPE
,
source_info
,
syntactic_s
ource_info
:
source_info
,
internal
:
false
,
is_user_variable
:
false
,
};
...
...
@@ -641,7 +642,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
ty
:
tcx
.mk_nil
(),
name
:
None
,
source_info
,
syntactic_s
cope
:
OUTERMOST_SOURCE_SCOPE
,
syntactic_s
ource_info
:
source_info
,
internal
:
false
,
is_user_variable
:
false
,
};
...
...
@@ -657,7 +658,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
}),
name
:
None
,
source_info
,
syntactic_s
cope
:
OUTERMOST_SOURCE_SCOPE
,
syntactic_s
ource_info
:
source_info
,
internal
:
false
,
is_user_variable
:
false
,
};
...
...
src/librustc_mir/transform/inline.rs
浏览文件 @
b10c157b
...
...
@@ -400,6 +400,9 @@ fn inline_call(&self,
local
.source_info.scope
=
scope_map
[
local
.source_info.scope
];
local
.source_info.span
=
callsite
.location.span
;
local
.syntactic_source_info.scope
=
scope_map
[
local
.syntactic_source_info.scope
];
local
.syntactic_source_info.span
=
callsite
.location.span
;
let
idx
=
caller_mir
.local_decls
.push
(
local
);
local_map
.push
(
idx
);
...
...
src/librustc_mir/transform/promote_consts.rs
浏览文件 @
b10c157b
...
...
@@ -335,6 +335,7 @@ fn interior_base<'a, 'tcx>(place: &'a mut Place<'tcx>)
// otherwise we would use the `promoted` directly.
let
mut
promoted_ref
=
LocalDecl
::
new_temp
(
ref_ty
,
span
);
promoted_ref
.source_info
=
statement
.source_info
;
promoted_ref
.syntactic_source_info
=
statement
.source_info
;
let
promoted_ref
=
local_decls
.push
(
promoted_ref
);
assert_eq!
(
self
.temps
.push
(
TempState
::
Unpromotable
),
promoted_ref
);
self
.extra_statements
.push
((
loc
,
Statement
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录