Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
83bb4306
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,发现更多精彩内容 >>
提交
83bb4306
编写于
10月 13, 2018
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "rustc_resolve: move extern_prelude from Resolver to Session."
This reverts commit
e90985ac
.
上级
f5175277
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
22 addition
and
26 deletion
+22
-26
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+0
-18
src/librustc_resolve/error_reporting.rs
src/librustc_resolve/error_reporting.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+17
-3
src/librustc_resolve/macros.rs
src/librustc_resolve/macros.rs
+1
-1
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+3
-3
未找到文件。
src/librustc/session/mod.rs
浏览文件 @
83bb4306
...
...
@@ -35,7 +35,6 @@
use
syntax
::
feature_gate
::{
self
,
AttributeType
};
use
syntax
::
json
::
JsonEmitter
;
use
syntax
::
source_map
;
use
syntax
::
symbol
::
Symbol
;
use
syntax
::
parse
::{
self
,
ParseSess
};
use
syntax_pos
::{
MultiSpan
,
Span
};
use
util
::
profiling
::
SelfProfiler
;
...
...
@@ -166,10 +165,6 @@ pub struct Session {
/// Cap lint level specified by a driver specifically.
pub
driver_lint_caps
:
FxHashMap
<
lint
::
LintId
,
lint
::
Level
>
,
/// All the crate names specified with `--extern`, and the builtin ones.
/// Starting with the Rust 2018 edition, absolute paths resolve in this set.
pub
extern_prelude
:
FxHashSet
<
Symbol
>
,
}
pub
struct
PerfStats
{
...
...
@@ -1149,18 +1144,6 @@ pub fn build_session_(
CguReuseTracker
::
new_disabled
()
};
let
mut
extern_prelude
:
FxHashSet
<
Symbol
>
=
sopts
.externs
.iter
()
.map
(|
kv
|
Symbol
::
intern
(
kv
.0
))
.collect
();
// HACK(eddyb) this ignores the `no_{core,std}` attributes.
// FIXME(eddyb) warn (somewhere) if core/std is used with `no_{core,std}`.
// if !attr::contains_name(&krate.attrs, "no_core") {
// if !attr::contains_name(&krate.attrs, "no_std") {
extern_prelude
.insert
(
Symbol
::
intern
(
"core"
));
extern_prelude
.insert
(
Symbol
::
intern
(
"std"
));
extern_prelude
.insert
(
Symbol
::
intern
(
"meta"
));
let
sess
=
Session
{
target
:
target_cfg
,
host
,
...
...
@@ -1236,7 +1219,6 @@ pub fn build_session_(
has_global_allocator
:
Once
::
new
(),
has_panic_handler
:
Once
::
new
(),
driver_lint_caps
:
FxHashMap
(),
extern_prelude
,
};
validate_commandline_args_with_session_available
(
&
sess
);
...
...
src/librustc_resolve/error_reporting.rs
浏览文件 @
83bb4306
...
...
@@ -136,7 +136,7 @@ fn make_external_crate_suggestion(
// Need to clone else we can't call `resolve_path` without a borrow error. We also store
// into a `BTreeMap` so we can get consistent ordering (and therefore the same diagnostic)
// each time.
let
external_crate_names
:
BTreeSet
<
Symbol
>
=
self
.resolver.
session.
extern_prelude
let
external_crate_names
:
BTreeSet
<
Symbol
>
=
self
.resolver.extern_prelude
.clone
()
.drain
()
.collect
();
// Insert a new path segment that we can replace.
...
...
src/librustc_resolve/lib.rs
浏览文件 @
83bb4306
...
...
@@ -1360,6 +1360,7 @@ pub struct Resolver<'a, 'b: 'a> {
graph_root
:
Module
<
'a
>
,
prelude
:
Option
<
Module
<
'a
>>
,
extern_prelude
:
FxHashSet
<
Name
>
,
/// n.b. This is used only for better diagnostics, not name resolution itself.
has_self
:
FxHashSet
<
DefId
>
,
...
...
@@ -1676,6 +1677,17 @@ pub fn new(session: &'a Session,
DefCollector
::
new
(
&
mut
definitions
,
Mark
::
root
())
.collect_root
(
crate_name
,
session
.local_crate_disambiguator
());
let
mut
extern_prelude
:
FxHashSet
<
Name
>
=
session
.opts.externs
.iter
()
.map
(|
kv
|
Symbol
::
intern
(
kv
.0
))
.collect
();
// HACK(eddyb) this ignore the `no_{core,std}` attributes.
// FIXME(eddyb) warn (elsewhere) if core/std is used with `no_{core,std}`.
// if !attr::contains_name(&krate.attrs, "no_core") {
// if !attr::contains_name(&krate.attrs, "no_std") {
extern_prelude
.insert
(
Symbol
::
intern
(
"core"
));
extern_prelude
.insert
(
Symbol
::
intern
(
"std"
));
extern_prelude
.insert
(
Symbol
::
intern
(
"meta"
));
let
mut
invocations
=
FxHashMap
();
invocations
.insert
(
Mark
::
root
(),
arenas
.alloc_invocation_data
(
InvocationData
::
root
(
graph_root
)));
...
...
@@ -1694,6 +1706,7 @@ pub fn new(session: &'a Session,
// AST.
graph_root
,
prelude
:
None
,
extern_prelude
,
has_self
:
FxHashSet
(),
field_names
:
FxHashMap
(),
...
...
@@ -1966,7 +1979,7 @@ fn resolve_ident_in_lexical_scope(&mut self,
if
!
module
.no_implicit_prelude
{
// `record_used` means that we don't try to load crates during speculative resolution
if
record_used
&&
ns
==
TypeNS
&&
self
.
session.
extern_prelude
.contains
(
&
ident
.name
)
{
if
record_used
&&
ns
==
TypeNS
&&
self
.extern_prelude
.contains
(
&
ident
.name
)
{
let
crate_id
=
self
.crate_loader
.process_path_extern
(
ident
.name
,
ident
.span
);
let
crate_root
=
self
.get_module
(
DefId
{
krate
:
crate_id
,
index
:
CRATE_DEF_INDEX
});
self
.populate_module_if_necessary
(
&
crate_root
);
...
...
@@ -4018,7 +4031,7 @@ fn lookup_typo_candidate<FilterFn>(&mut self,
}
else
{
// Items from the prelude
if
!
module
.no_implicit_prelude
{
names
.extend
(
self
.
session.
extern_prelude
.iter
()
.cloned
());
names
.extend
(
self
.extern_prelude
.iter
()
.cloned
());
if
let
Some
(
prelude
)
=
self
.prelude
{
add_module_candidates
(
prelude
,
&
mut
names
);
}
...
...
@@ -4464,7 +4477,8 @@ fn lookup_import_candidates<FilterFn>(&mut self,
);
if
self
.session
.rust_2018
()
{
for
&
name
in
&
self
.session.extern_prelude
{
let
extern_prelude_names
=
self
.extern_prelude
.clone
();
for
&
name
in
extern_prelude_names
.iter
()
{
let
ident
=
Ident
::
with_empty_ctxt
(
name
);
match
self
.crate_loader
.maybe_process_path_extern
(
name
,
ident
.span
)
{
Some
(
crate_id
)
=>
{
...
...
src/librustc_resolve/macros.rs
浏览文件 @
83bb4306
...
...
@@ -692,7 +692,7 @@ struct Flags: u8 {
}
}
WhereToResolve
::
ExternPrelude
=>
{
if
use_prelude
&&
self
.
session.
extern_prelude
.contains
(
&
ident
.name
)
{
if
use_prelude
&&
self
.extern_prelude
.contains
(
&
ident
.name
)
{
let
crate_id
=
self
.crate_loader
.process_path_extern
(
ident
.name
,
ident
.span
);
let
crate_root
=
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
83bb4306
...
...
@@ -199,7 +199,7 @@ pub fn resolve_ident_in_module_unadjusted(&mut self,
if
!
(
ns
==
TypeNS
&&
!
ident
.is_path_segment_keyword
()
&&
self
.
session.
extern_prelude
.contains
(
&
ident
.name
)
self
.extern_prelude
.contains
(
&
ident
.name
)
)
{
// ... unless the crate name is not in the `extern_prelude`.
return
binding
;
...
...
@@ -218,7 +218,7 @@ pub fn resolve_ident_in_module_unadjusted(&mut self,
}
else
if
ns
==
TypeNS
&&
!
ident
.is_path_segment_keyword
()
&&
self
.
session.
extern_prelude
.contains
(
&
ident
.name
)
self
.extern_prelude
.contains
(
&
ident
.name
)
{
let
crate_id
=
self
.crate_loader
.process_path_extern
(
ident
.name
,
ident
.span
);
...
...
@@ -736,7 +736,7 @@ struct UniformPathsCanaryResults<'a> {
let
uniform_paths_feature
=
self
.session
.features_untracked
()
.uniform_paths
;
for
((
span
,
_
,
ns
),
results
)
in
uniform_paths_canaries
{
let
name
=
results
.name
;
let
external_crate
=
if
ns
==
TypeNS
&&
self
.
session.
extern_prelude
.contains
(
&
name
)
{
let
external_crate
=
if
ns
==
TypeNS
&&
self
.extern_prelude
.contains
(
&
name
)
{
let
crate_id
=
self
.crate_loader
.process_path_extern
(
name
,
span
);
Some
(
Def
::
Mod
(
DefId
{
krate
:
crate_id
,
index
:
CRATE_DEF_INDEX
}))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录