Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ca88c44a
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,发现更多精彩内容 >>
提交
ca88c44a
编写于
4月 30, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid using the lowering context in `librustc_save_analysis`
上级
02df9f32
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
11 addition
and
28 deletion
+11
-28
src/librustc_driver/driver.rs
src/librustc_driver/driver.rs
+2
-10
src/librustc_driver/lib.rs
src/librustc_driver/lib.rs
+0
-1
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/dump_visitor.rs
+2
-4
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+7
-13
未找到文件。
src/librustc_driver/driver.rs
浏览文件 @
ca88c44a
...
...
@@ -165,8 +165,7 @@ pub fn compile_input(sess: &Session,
&
hir_map
,
&
expanded_crate
,
&
hir_map
.krate
(),
&
id
[
..
],
&
lcx
),
&
id
[
..
]),
Ok
(()));
}
...
...
@@ -203,7 +202,6 @@ pub fn compile_input(sess: &Session,
&
analysis
,
mir_map
.as_ref
(),
tcx
,
&
lcx
,
&
id
);
(
control
.after_analysis.callback
)(
state
);
...
...
@@ -345,7 +343,6 @@ pub struct CompileState<'a, 'ast: 'a, 'tcx: 'a> {
pub
mir_map
:
Option
<&
'a
MirMap
<
'tcx
>>
,
pub
analysis
:
Option
<&
'a
ty
::
CrateAnalysis
<
'a
>>
,
pub
tcx
:
Option
<&
'a
TyCtxt
<
'tcx
>>
,
pub
lcx
:
Option
<&
'a
LoweringContext
<
'a
>>
,
pub
trans
:
Option
<&
'a
trans
::
CrateTranslation
>
,
}
...
...
@@ -368,7 +365,6 @@ fn empty(input: &'a Input,
analysis
:
None
,
mir_map
:
None
,
tcx
:
None
,
lcx
:
None
,
trans
:
None
,
}
}
...
...
@@ -400,15 +396,13 @@ fn state_after_write_deps(input: &'a Input,
hir_map
:
&
'a
hir_map
::
Map
<
'ast
>
,
krate
:
&
'a
ast
::
Crate
,
hir_crate
:
&
'a
hir
::
Crate
,
crate_name
:
&
'a
str
,
lcx
:
&
'a
LoweringContext
<
'a
>
)
crate_name
:
&
'a
str
)
->
CompileState
<
'a
,
'ast
,
'tcx
>
{
CompileState
{
crate_name
:
Some
(
crate_name
),
ast_map
:
Some
(
hir_map
),
krate
:
Some
(
krate
),
hir_crate
:
Some
(
hir_crate
),
lcx
:
Some
(
lcx
),
..
CompileState
::
empty
(
input
,
session
,
out_dir
)
}
}
...
...
@@ -421,7 +415,6 @@ fn state_after_analysis(input: &'a Input,
analysis
:
&
'a
ty
::
CrateAnalysis
,
mir_map
:
Option
<&
'a
MirMap
<
'tcx
>>
,
tcx
:
&
'a
TyCtxt
<
'tcx
>
,
lcx
:
&
'a
LoweringContext
<
'a
>
,
crate_name
:
&
'a
str
)
->
CompileState
<
'a
,
'ast
,
'tcx
>
{
CompileState
{
...
...
@@ -430,7 +423,6 @@ fn state_after_analysis(input: &'a Input,
tcx
:
Some
(
tcx
),
krate
:
krate
,
hir_crate
:
Some
(
hir_crate
),
lcx
:
Some
(
lcx
),
crate_name
:
Some
(
crate_name
),
..
CompileState
::
empty
(
input
,
session
,
out_dir
)
}
...
...
src/librustc_driver/lib.rs
浏览文件 @
ca88c44a
...
...
@@ -499,7 +499,6 @@ fn build_controller(&mut self, sess: &Session) -> CompileController<'a> {
control
.after_analysis.callback
=
box
|
state
|
{
time
(
state
.session
.time_passes
(),
"save analysis"
,
||
{
save
::
process_crate
(
state
.tcx
.unwrap
(),
state
.lcx
.unwrap
(),
state
.krate
.unwrap
(),
state
.analysis
.unwrap
(),
state
.crate_name
.unwrap
(),
...
...
src/librustc_save_analysis/dump_visitor.rs
浏览文件 @
ca88c44a
...
...
@@ -42,8 +42,6 @@
use
syntax
::
print
::
pprust
::{
path_to_string
,
ty_to_string
};
use
syntax
::
ptr
::
P
;
use
rustc
::
hir
::
lowering
::
lower_expr
;
use
super
::{
escape
,
generated_code
,
SaveContext
,
PathCollector
};
use
super
::
data
::
*
;
use
super
::
dump
::
Dump
;
...
...
@@ -1222,7 +1220,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
visit
::
walk_expr
(
self
,
ex
);
}
ast
::
ExprKind
::
Struct
(
ref
path
,
ref
fields
,
ref
base
)
=>
{
let
hir_expr
=
lower_expr
(
self
.save_ctxt.lcx
,
ex
);
let
hir_expr
=
self
.save_ctxt.tcx.map
.expect_expr
(
ex
.id
);
let
adt
=
self
.tcx
.expr_ty
(
&
hir_expr
)
.ty_adt_def
()
.unwrap
();
let
def
=
self
.tcx
.resolve_expr
(
&
hir_expr
);
self
.process_struct_lit
(
ex
,
path
,
fields
,
adt
.variant_of_def
(
def
),
base
)
...
...
@@ -1241,7 +1239,7 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
ast
::
ExprKind
::
TupField
(
ref
sub_ex
,
idx
)
=>
{
self
.visit_expr
(
&
sub_ex
);
let
hir_node
=
lower_expr
(
self
.save_ctxt.lcx
,
sub_ex
);
let
hir_node
=
self
.save_ctxt.tcx.map
.expect_expr
(
sub_ex
.id
);
let
ty
=
&
self
.tcx
.expr_ty_adjusted
(
&
hir_node
)
.sty
;
match
*
ty
{
ty
::
TyStruct
(
def
,
_
)
=>
{
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
ca88c44a
...
...
@@ -28,7 +28,7 @@
#[macro_use]
extern
crate
syntax
;
extern
crate
serialize
as
rustc_serialize
;
use
rustc
::
hir
::{
self
,
lowering
}
;
use
rustc
::
hir
;
use
rustc
::
hir
::
map
::
NodeItem
;
use
rustc
::
hir
::
def
::
Def
;
use
rustc
::
hir
::
def_id
::
DefId
;
...
...
@@ -75,7 +75,6 @@ pub enum Row {
pub
struct
SaveContext
<
'l
,
'tcx
:
'l
>
{
tcx
:
&
'l
TyCtxt
<
'tcx
>
,
lcx
:
&
'l
lowering
::
LoweringContext
<
'l
>
,
span_utils
:
SpanUtils
<
'tcx
>
,
}
...
...
@@ -84,20 +83,16 @@ pub struct SaveContext<'l, 'tcx: 'l> {
);
impl
<
'l
,
'tcx
:
'l
>
SaveContext
<
'l
,
'tcx
>
{
pub
fn
new
(
tcx
:
&
'l
TyCtxt
<
'tcx
>
,
lcx
:
&
'l
lowering
::
LoweringContext
<
'l
>
)
->
SaveContext
<
'l
,
'tcx
>
{
pub
fn
new
(
tcx
:
&
'l
TyCtxt
<
'tcx
>
)
->
SaveContext
<
'l
,
'tcx
>
{
let
span_utils
=
SpanUtils
::
new
(
&
tcx
.sess
);
SaveContext
::
from_span_utils
(
tcx
,
lcx
,
span_utils
)
SaveContext
::
from_span_utils
(
tcx
,
span_utils
)
}
pub
fn
from_span_utils
(
tcx
:
&
'l
TyCtxt
<
'tcx
>
,
lcx
:
&
'l
lowering
::
LoweringContext
<
'l
>
,
span_utils
:
SpanUtils
<
'tcx
>
)
->
SaveContext
<
'l
,
'tcx
>
{
SaveContext
{
tcx
:
tcx
,
lcx
:
lcx
,
span_utils
:
span_utils
,
}
}
...
...
@@ -378,14 +373,14 @@ pub fn get_trait_ref_data(&self,
}
pub
fn
get_expr_data
(
&
self
,
expr
:
&
ast
::
Expr
)
->
Option
<
Data
>
{
let
hir_node
=
lowering
::
lower_expr
(
self
.lcx
,
expr
);
let
hir_node
=
self
.tcx.map
.expect_expr
(
expr
.id
);
let
ty
=
self
.tcx
.expr_ty_adjusted_opt
(
&
hir_node
);
if
ty
.is_none
()
||
ty
.unwrap
()
.sty
==
ty
::
TyError
{
return
None
;
}
match
expr
.node
{
ast
::
ExprKind
::
Field
(
ref
sub_ex
,
ident
)
=>
{
let
hir_node
=
lowering
::
lower_expr
(
self
.lcx
,
sub_ex
);
let
hir_node
=
self
.tcx.map
.expect_expr
(
sub_ex
.id
);
match
self
.tcx
.expr_ty_adjusted
(
&
hir_node
)
.sty
{
ty
::
TyStruct
(
def
,
_
)
=>
{
let
f
=
def
.struct_variant
()
.field_named
(
ident
.node.name
);
...
...
@@ -405,7 +400,7 @@ pub fn get_expr_data(&self, expr: &ast::Expr) -> Option<Data> {
}
}
ast
::
ExprKind
::
Struct
(
ref
path
,
_
,
_
)
=>
{
let
hir_node
=
lowering
::
lower_expr
(
self
.lcx
,
expr
);
let
hir_node
=
self
.tcx.map
.expect_expr
(
expr
.id
);
match
self
.tcx
.expr_ty_adjusted
(
&
hir_node
)
.sty
{
ty
::
TyStruct
(
def
,
_
)
=>
{
let
sub_span
=
self
.span_utils
.span_for_last_ident
(
path
.span
);
...
...
@@ -704,7 +699,6 @@ fn extension(&self) -> &'static str {
}
pub
fn
process_crate
<
'l
,
'tcx
>
(
tcx
:
&
'l
TyCtxt
<
'tcx
>
,
lcx
:
&
'l
lowering
::
LoweringContext
<
'l
>
,
krate
:
&
ast
::
Crate
,
analysis
:
&
'l
ty
::
CrateAnalysis
<
'l
>
,
cratename
:
&
str
,
...
...
@@ -755,7 +749,7 @@ pub fn process_crate<'l, 'tcx>(tcx: &'l TyCtxt<'tcx>,
let
output
=
&
mut
output_file
;
let
utils
:
SpanUtils
<
'tcx
>
=
SpanUtils
::
new
(
&
tcx
.sess
);
let
save_ctxt
=
SaveContext
::
new
(
tcx
,
lcx
);
let
save_ctxt
=
SaveContext
::
new
(
tcx
);
macro_rules!
dump
{
(
$new_dumper
:
expr
)
=>
{{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录