Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
85a05d18
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,发现更多精彩内容 >>
提交
85a05d18
编写于
8月 23, 2018
作者:
K
Kyle Simpson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Light restructuring.
上级
3536359a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
13 addition
and
23 deletion
+13
-23
src/Cargo.lock
src/Cargo.lock
+0
-1
src/librustc_privacy/Cargo.toml
src/librustc_privacy/Cargo.toml
+0
-1
src/librustc_privacy/lib.rs
src/librustc_privacy/lib.rs
+13
-21
未找到文件。
src/Cargo.lock
浏览文件 @
85a05d18
...
...
@@ -2237,7 +2237,6 @@ dependencies = [
name = "rustc_privacy"
version = "0.0.0"
dependencies = [
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_typeck 0.0.0",
...
...
src/librustc_privacy/Cargo.toml
浏览文件 @
85a05d18
...
...
@@ -9,7 +9,6 @@ path = "lib.rs"
crate-type
=
["dylib"]
[dependencies]
log
=
{
version
=
"0.4"
,
features
=
[
"release_max_level_info"
,
"std"
]
}
rustc
=
{
path
=
"../librustc"
}
rustc_typeck
=
{
path
=
"../librustc_typeck"
}
syntax
=
{
path
=
"../libsyntax"
}
...
...
src/librustc_privacy/lib.rs
浏览文件 @
85a05d18
...
...
@@ -18,7 +18,6 @@
#![recursion_limit=
"256"
]
#[macro_use]
extern
crate
log
;
#[macro_use]
extern
crate
rustc
;
#[macro_use]
extern
crate
syntax
;
extern
crate
rustc_typeck
;
...
...
@@ -150,7 +149,6 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
}
fn
visit_item
(
&
mut
self
,
item
:
&
'tcx
hir
::
Item
)
{
debug!
(
"visit_item({:?})"
,
item
);
let
inherited_item_level
=
match
item
.node
{
// Impls inherit level from their types and traits
hir
::
ItemKind
::
Impl
(
..
)
=>
{
...
...
@@ -161,21 +159,12 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
hir
::
ItemKind
::
ForeignMod
(
..
)
=>
{
self
.prev_level
}
// Impl trait return types mark their parent function.
// It (and its children) are revisited if the change applies.
hir
::
ItemKind
::
Existential
(
ref
ty_data
)
=>
{
if
let
Some
(
impl_trait_fn
)
=
ty_data
.impl_trait_fn
{
if
let
Some
(
node_id
)
=
self
.tcx.hir
.as_local_node_id
(
impl_trait_fn
)
{
self
.update
(
node_id
,
Some
(
AccessLevel
::
ReachableFromImplTrait
));
}
}
if
item
.vis.node
.is_pub
()
{
self
.prev_level
}
else
{
None
}
}
// Other `pub` items inherit levels from parents
hir
::
ItemKind
::
Const
(
..
)
|
hir
::
ItemKind
::
Enum
(
..
)
|
hir
::
ItemKind
::
ExternCrate
(
..
)
|
hir
::
ItemKind
::
GlobalAsm
(
..
)
|
hir
::
ItemKind
::
Fn
(
..
)
|
hir
::
ItemKind
::
Mod
(
..
)
|
hir
::
ItemKind
::
Static
(
..
)
|
hir
::
ItemKind
::
Struct
(
..
)
|
hir
::
ItemKind
::
Trait
(
..
)
|
hir
::
ItemKind
::
TraitAlias
(
..
)
|
hir
::
ItemKind
::
Existential
(
..
)
|
hir
::
ItemKind
::
Ty
(
..
)
|
hir
::
ItemKind
::
Union
(
..
)
|
hir
::
ItemKind
::
Use
(
..
)
=>
{
if
item
.vis.node
.is_pub
()
{
self
.prev_level
}
else
{
None
}
}
...
...
@@ -184,8 +173,6 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
// Update level of the item itself
let
item_level
=
self
.update
(
item
.id
,
inherited_item_level
);
debug!
(
"item_level = {:?}"
,
item_level
);
// Update levels of nested things
match
item
.node
{
hir
::
ItemKind
::
Enum
(
ref
def
,
_
)
=>
{
...
...
@@ -230,7 +217,15 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
}
}
}
hir
::
ItemKind
::
Existential
(
..
)
|
// Impl trait return types mark their parent function.
// It (and its children) are revisited if the change applies.
hir
::
ItemKind
::
Existential
(
ref
ty_data
)
=>
{
if
let
Some
(
impl_trait_fn
)
=
ty_data
.impl_trait_fn
{
if
let
Some
(
node_id
)
=
self
.tcx.hir
.as_local_node_id
(
impl_trait_fn
)
{
self
.update
(
node_id
,
Some
(
AccessLevel
::
ReachableFromImplTrait
));
}
}
}
hir
::
ItemKind
::
Use
(
..
)
|
hir
::
ItemKind
::
Static
(
..
)
|
hir
::
ItemKind
::
Const
(
..
)
|
...
...
@@ -242,8 +237,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
hir
::
ItemKind
::
ExternCrate
(
..
)
=>
{}
}
let
orig_level
=
self
.prev_level
;
self
.prev_level
=
item_level
;
// Store this node's access level here to propagate the correct
// reachability level through interfaces and children.
let
orig_level
=
replace
(
&
mut
self
.prev_level
,
item_level
);
// Mark all items in interfaces of reachable items as reachable
match
item
.node
{
...
...
@@ -1752,8 +1748,6 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}
visitor
.update
(
ast
::
CRATE_NODE_ID
,
Some
(
AccessLevel
::
Public
));
debug!
(
"access levels after embargo: {:?}"
,
&
visitor
.access_levels
);
{
let
mut
visitor
=
ObsoleteVisiblePrivateTypesVisitor
{
tcx
,
...
...
@@ -1783,8 +1777,6 @@ fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
krate
.visit_all_item_likes
(
&
mut
DeepVisitor
::
new
(
&
mut
visitor
));
}
debug!
(
"final access levels: {:?}"
,
&
visitor
.access_levels
);
Lrc
::
new
(
visitor
.access_levels
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录