Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e2414852
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,发现更多精彩内容 >>
提交
e2414852
编写于
11月 23, 2019
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc_metadata: Privatize `CrateMetadata::extern_crate`
上级
37304cda
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
31 deletion
+23
-31
src/librustc/middle/cstore.rs
src/librustc/middle/cstore.rs
+7
-0
src/librustc_metadata/creader.rs
src/librustc_metadata/creader.rs
+6
-30
src/librustc_metadata/rmeta/decoder.rs
src/librustc_metadata/rmeta/decoder.rs
+10
-1
未找到文件。
src/librustc/middle/cstore.rs
浏览文件 @
e2414852
...
...
@@ -146,6 +146,13 @@ impl ExternCrate {
pub
fn
is_direct
(
&
self
)
->
bool
{
self
.dependency_of
==
LOCAL_CRATE
}
pub
fn
rank
(
&
self
)
->
impl
PartialOrd
{
// Prefer:
// - direct extern crate to indirect
// - shorter paths to longer
(
self
.is_direct
(),
!
self
.path_len
)
}
}
#[derive(Copy,
Clone,
Debug,
HashStable)]
...
...
src/librustc_metadata/creader.rs
浏览文件 @
e2414852
...
...
@@ -400,36 +400,12 @@ fn update_extern_crate(&self,
if
!
visited
.insert
((
cnum
,
extern_crate
.is_direct
()))
{
return
}
let
cmeta
=
self
.cstore
.get_crate_data
(
cnum
);
let
mut
old_extern_crate
=
cmeta
.extern_crate
.borrow_mut
();
// Prefer:
// - something over nothing (tuple.0);
// - direct extern crate to indirect (tuple.1);
// - shorter paths to longer (tuple.2).
let
new_rank
=
(
true
,
extern_crate
.is_direct
(),
cmp
::
Reverse
(
extern_crate
.path_len
),
);
let
old_rank
=
match
*
old_extern_crate
{
None
=>
(
false
,
false
,
cmp
::
Reverse
(
usize
::
max_value
())),
Some
(
ref
c
)
=>
(
true
,
c
.is_direct
(),
cmp
::
Reverse
(
c
.path_len
),
),
};
if
old_rank
>=
new_rank
{
return
;
// no change needed
}
*
old_extern_crate
=
Some
(
extern_crate
);
drop
(
old_extern_crate
);
// Propagate the extern crate info to dependencies.
extern_crate
.dependency_of
=
cnum
;
for
&
dep_cnum
in
cmeta
.dependencies
()
.iter
()
{
self
.update_extern_crate
(
dep_cnum
,
extern_crate
,
visited
);
if
cmeta
.update_extern_crate
(
extern_crate
)
{
// Propagate the extern crate info to dependencies.
extern_crate
.dependency_of
=
cnum
;
for
&
dep_cnum
in
cmeta
.dependencies
()
.iter
()
{
self
.update_extern_crate
(
dep_cnum
,
extern_crate
,
visited
);
}
}
}
...
...
src/librustc_metadata/rmeta/decoder.rs
浏览文件 @
e2414852
...
...
@@ -112,7 +112,7 @@
/// Information about the `extern crate` item or path that caused this crate to be loaded.
/// If this is `None`, then the crate was injected (e.g., by the allocator).
crate
extern_crate
:
Lock
<
Option
<
ExternCrate
>>
,
extern_crate
:
Lock
<
Option
<
ExternCrate
>>
,
}
/// Holds information about a syntax_pos::SourceFile imported from another crate.
...
...
@@ -1525,6 +1525,15 @@ fn get_crate_dep_node_index(&self, tcx: TyCtxt<'tcx>) -> DepNodeIndex {
crate
fn
add_dependency
(
&
self
,
cnum
:
CrateNum
)
{
self
.dependencies
.borrow_mut
()
.push
(
cnum
);
}
crate
fn
update_extern_crate
(
&
self
,
new_extern_crate
:
ExternCrate
)
->
bool
{
let
mut
extern_crate
=
self
.extern_crate
.borrow_mut
();
let
update
=
Some
(
new_extern_crate
.rank
())
>
extern_crate
.as_ref
()
.map
(
ExternCrate
::
rank
);
if
update
{
*
extern_crate
=
Some
(
new_extern_crate
);
}
update
}
}
// Cannot be implemented on 'ProcMacro', as libproc_macro
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录