Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d1e3d627
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,发现更多精彩内容 >>
提交
d1e3d627
编写于
6月 28, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the `after_expand` entry point between import resolution and the rest of name resolution
上级
9eec7382
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
75 addition
and
39 deletion
+75
-39
src/librustc_driver/driver.rs
src/librustc_driver/driver.rs
+55
-11
src/librustc_driver/test.rs
src/librustc_driver/test.rs
+5
-3
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+0
-12
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+6
-5
src/librustdoc/core.rs
src/librustdoc/core.rs
+3
-3
src/librustdoc/test.rs
src/librustdoc/test.rs
+3
-3
src/test/run-make/execution-engine/test.rs
src/test/run-make/execution-engine/test.rs
+3
-2
未找到文件。
src/librustc_driver/driver.rs
浏览文件 @
d1e3d627
...
...
@@ -116,8 +116,16 @@ pub fn compile_input(sess: &Session,
let
outputs
=
build_output_filenames
(
input
,
outdir
,
output
,
&
krate
.attrs
,
sess
);
let
id
=
link
::
find_crate_name
(
Some
(
sess
),
&
krate
.attrs
,
input
);
let
ExpansionResult
{
expanded_crate
,
defs
,
analysis
,
resolutions
,
mut
hir_forest
}
=
{
let
make_glob_map
=
control
.make_glob_map
;
phase_2_configure_and_expand
(
sess
,
&
cstore
,
krate
,
&
id
,
addl_plugins
,
make_glob_map
)
?
phase_2_configure_and_expand
(
sess
,
&
cstore
,
krate
,
&
id
,
addl_plugins
,
control
.make_glob_map
,
|
expanded_crate
|
{
let
mut
state
=
CompileState
::
state_after_expand
(
input
,
sess
,
outdir
,
output
,
&
cstore
,
expanded_crate
,
&
id
,
);
controller_entry_point!
(
after_expand
,
sess
,
state
,
Ok
(()));
Ok
(())
}
)
?
};
write_out_deps
(
sess
,
&
outputs
,
&
id
);
...
...
@@ -262,6 +270,7 @@ pub fn source_name(input: &Input) -> String {
/// Expect more entry points to be added in the future.
pub
struct
CompileController
<
'a
>
{
pub
after_parse
:
PhaseController
<
'a
>
,
pub
after_expand
:
PhaseController
<
'a
>
,
pub
after_hir_lowering
:
PhaseController
<
'a
>
,
pub
after_analysis
:
PhaseController
<
'a
>
,
pub
after_llvm
:
PhaseController
<
'a
>
,
...
...
@@ -273,6 +282,7 @@ impl<'a> CompileController<'a> {
pub
fn
basic
()
->
CompileController
<
'a
>
{
CompileController
{
after_parse
:
PhaseController
::
basic
(),
after_expand
:
PhaseController
::
basic
(),
after_hir_lowering
:
PhaseController
::
basic
(),
after_analysis
:
PhaseController
::
basic
(),
after_llvm
:
PhaseController
::
basic
(),
...
...
@@ -363,6 +373,23 @@ fn state_after_parse(input: &'a Input,
}
}
fn
state_after_expand
(
input
:
&
'a
Input
,
session
:
&
'ast
Session
,
out_dir
:
&
'a
Option
<
PathBuf
>
,
out_file
:
&
'a
Option
<
PathBuf
>
,
cstore
:
&
'a
CStore
,
expanded_crate
:
&
'a
ast
::
Crate
,
crate_name
:
&
'a
str
)
->
CompileState
<
'a
,
'b
,
'ast
,
'tcx
>
{
CompileState
{
crate_name
:
Some
(
crate_name
),
cstore
:
Some
(
cstore
),
expanded_crate
:
Some
(
expanded_crate
),
out_file
:
out_file
.as_ref
()
.map
(|
s
|
&**
s
),
..
CompileState
::
empty
(
input
,
session
,
out_dir
)
}
}
fn
state_after_hir_lowering
(
input
:
&
'a
Input
,
session
:
&
'ast
Session
,
out_dir
:
&
'a
Option
<
PathBuf
>
,
...
...
@@ -496,13 +523,16 @@ pub struct ExpansionResult<'a> {
/// standard library and prelude, and name resolution.
///
/// Returns `None` if we're aborting after handling -W help.
pub
fn
phase_2_configure_and_expand
<
'a
>
(
sess
:
&
Session
,
pub
fn
phase_2_configure_and_expand
<
'a
,
F
>
(
sess
:
&
Session
,
cstore
:
&
CStore
,
mut
krate
:
ast
::
Crate
,
crate_name
:
&
'a
str
,
addl_plugins
:
Option
<
Vec
<
String
>>
,
make_glob_map
:
MakeGlobMap
)
->
Result
<
ExpansionResult
<
'a
>
,
usize
>
{
make_glob_map
:
MakeGlobMap
,
after_expand
:
F
)
->
Result
<
ExpansionResult
<
'a
>
,
usize
>
where
F
:
FnOnce
(
&
ast
::
Crate
)
->
CompileResult
,
{
let
time_passes
=
sess
.time_passes
();
// strip before anything else because crate metadata may use #[cfg_attr]
...
...
@@ -685,9 +715,23 @@ pub fn phase_2_configure_and_expand<'a>(sess: &Session,
"AST validation"
,
||
ast_validation
::
check_crate
(
sess
,
&
krate
));
time
(
sess
.time_passes
(),
"name resolution"
,
||
{
time
(
sess
.time_passes
(),
"name resolution"
,
||
->
CompileResult
{
// Currently, we ignore the name resolution data structures for the purposes of dependency
// tracking. Instead we will run name resolution and include its output in the hash of each
// item, much like we do for macro expansion. In other words, the hash reflects not just
// its contents but the results of name resolution on those contents. Hopefully we'll push
// this back at some point.
let
_
ignore
=
sess
.dep_graph
.in_ignore
();
resolver
.build_reduced_graph
(
&
krate
);
resolver
.resolve_imports
();
// Since import resolution will eventually happen in expansion,
// don't perform `after_expand` until after import resolution.
after_expand
(
&
krate
)
?
;
resolver
.resolve_crate
(
&
krate
);
});
Ok
(())
})
?
;
// Lower ast -> hir.
let
hir_forest
=
time
(
sess
.time_passes
(),
"lowering ast -> hir"
,
||
{
...
...
src/librustc_driver/test.rs
浏览文件 @
d1e3d627
...
...
@@ -116,9 +116,11 @@ fn test_env<F>(source_string: &str,
input
:
source_string
.to_string
(),
};
let
krate
=
driver
::
phase_1_parse_input
(
&
sess
,
krate_config
,
&
input
)
.unwrap
();
let
driver
::
ExpansionResult
{
defs
,
resolutions
,
mut
hir_forest
,
..
}
=
driver
::
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
"test"
,
None
,
MakeGlobMap
::
No
)
.expect
(
"phase 2 aborted"
);
let
driver
::
ExpansionResult
{
defs
,
resolutions
,
mut
hir_forest
,
..
}
=
{
driver
::
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
"test"
,
None
,
MakeGlobMap
::
No
,
|
_
|
Ok
(()),
)
.expect
(
"phase 2 aborted"
)
};
let
_
ignore
=
dep_graph
.in_ignore
();
let
arenas
=
ty
::
CtxtArenas
::
new
();
...
...
src/librustc_resolve/lib.rs
浏览文件 @
d1e3d627
...
...
@@ -1167,18 +1167,6 @@ pub fn arenas() -> ResolverArenas<'a> {
/// Entry point to crate resolution.
pub
fn
resolve_crate
(
&
mut
self
,
krate
:
&
Crate
)
{
// Currently, we ignore the name resolution data structures for
// the purposes of dependency tracking. Instead we will run name
// resolution and include its output in the hash of each item,
// much like we do for macro expansion. In other words, the hash
// reflects not just its contents but the results of name
// resolution on those contents. Hopefully we'll push this back at
// some point.
let
_
ignore
=
self
.session.dep_graph
.in_ignore
();
self
.build_reduced_graph
(
krate
);
resolve_imports
::
resolve_imports
(
self
);
self
.current_module
=
self
.graph_root
;
visit
::
walk_crate
(
self
,
krate
);
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
d1e3d627
...
...
@@ -30,6 +30,12 @@
use
std
::
cell
::{
Cell
,
RefCell
};
impl
<
'a
>
Resolver
<
'a
>
{
pub
fn
resolve_imports
(
&
mut
self
)
{
ImportResolver
{
resolver
:
self
}
.resolve_imports
();
}
}
/// Contains data for specific types of import directives.
#[derive(Clone,
Debug)]
pub
enum
ImportDirectiveSubclass
{
...
...
@@ -722,8 +728,3 @@ fn import_directive_subclass_to_string(subclass: &ImportDirectiveSubclass) -> St
GlobImport
{
..
}
=>
"*"
.to_string
(),
}
}
pub
fn
resolve_imports
(
resolver
:
&
mut
Resolver
)
{
let
mut
import_resolver
=
ImportResolver
{
resolver
:
resolver
};
import_resolver
.resolve_imports
();
}
src/librustdoc/core.rs
浏览文件 @
d1e3d627
...
...
@@ -149,9 +149,9 @@ pub fn run_core(search_paths: SearchPaths,
let
name
=
link
::
find_crate_name
(
Some
(
&
sess
),
&
krate
.attrs
,
&
input
);
let
driver
::
ExpansionResult
{
defs
,
analysis
,
resolutions
,
mut
hir_forest
,
..
}
=
{
let
make_glob_map
=
resolve
::
MakeGlobMap
::
No
;
driver
::
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
&
name
,
None
,
make_glob_map
)
.expect
(
"phase_2_configure_and_expand aborted in rustdoc!"
)
driver
::
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
&
name
,
None
,
resolve
::
MakeGlobMap
::
No
,
|
_
|
Ok
(()),
)
.expect
(
"phase_2_configure_and_expand aborted in rustdoc!"
)
};
let
arenas
=
ty
::
CtxtArenas
::
new
();
...
...
src/librustdoc/test.rs
浏览文件 @
d1e3d627
...
...
@@ -95,9 +95,9 @@ pub fn run(input: &str,
cfg
.extend
(
config
::
parse_cfgspecs
(
cfgs
.clone
()));
let
krate
=
panictry!
(
driver
::
phase_1_parse_input
(
&
sess
,
cfg
,
&
input
));
let
driver
::
ExpansionResult
{
defs
,
mut
hir_forest
,
..
}
=
{
let
make_glob_map
=
MakeGlobMap
::
No
;
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
"rustdoc-test"
,
None
,
make_glob_map
)
.expect
(
"phase_2_configure_and_expand aborted in rustdoc!"
)
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
"rustdoc-test"
,
None
,
MakeGlobMap
::
No
,
|
_
|
Ok
(()
)
)
.expect
(
"phase_2_configure_and_expand aborted in rustdoc!"
)
};
let
dep_graph
=
DepGraph
::
new
(
false
);
...
...
src/test/run-make/execution-engine/test.rs
浏览文件 @
d1e3d627
...
...
@@ -241,8 +241,9 @@ fn compile_program(input: &str, sysroot: PathBuf)
let
krate
=
panictry!
(
driver
::
phase_1_parse_input
(
&
sess
,
cfg
,
&
input
));
let
driver
::
ExpansionResult
{
defs
,
analysis
,
resolutions
,
mut
hir_forest
,
..
}
=
{
driver
::
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
&
id
,
None
,
MakeGlobMap
::
No
)
.expect
(
"phase_2 returned `None`"
)
driver
::
phase_2_configure_and_expand
(
&
sess
,
&
cstore
,
krate
,
&
id
,
None
,
MakeGlobMap
::
No
,
|
_
|
Ok
(()),
)
.expect
(
"phase_2 returned `None`"
)
};
let
arenas
=
ty
::
CtxtArenas
::
new
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录