Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0e1a302f
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,发现更多精彩内容 >>
提交
0e1a302f
编写于
11月 14, 2020
作者:
J
Joshua Nelson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove dead code in rustdoc::doctree
It was completely unused.
上级
fc4ca552
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
147 deletion
+18
-147
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+2
-2
src/librustdoc/doctree.rs
src/librustdoc/doctree.rs
+5
-47
src/librustdoc/visit_ast.rs
src/librustdoc/visit_ast.rs
+11
-98
未找到文件。
src/librustdoc/clean/mod.rs
浏览文件 @
0e1a302f
...
...
@@ -2280,7 +2280,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
}
}
impl
Clean
<
Item
>
for
doctree
::
Macro
<
'_
>
{
impl
Clean
<
Item
>
for
doctree
::
Macro
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
>
)
->
Item
{
Item
::
from_def_id_and_parts
(
self
.def_id
,
...
...
@@ -2301,7 +2301,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
}
}
impl
Clean
<
Item
>
for
doctree
::
ProcMacro
<
'_
>
{
impl
Clean
<
Item
>
for
doctree
::
ProcMacro
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
>
)
->
Item
{
Item
::
from_hir_id_and_parts
(
self
.id
,
...
...
src/librustdoc/doctree.rs
浏览文件 @
0e1a302f
...
...
@@ -28,25 +28,19 @@
crate
statics
:
Vec
<
Static
<
'hir
>>
,
crate
constants
:
Vec
<
Constant
<
'hir
>>
,
crate
traits
:
Vec
<
Trait
<
'hir
>>
,
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
crate
impls
:
Vec
<
Impl
<
'hir
>>
,
crate
foreigns
:
Vec
<
ForeignItem
<
'hir
>>
,
crate
macros
:
Vec
<
Macro
<
'hir
>
>
,
crate
proc_macros
:
Vec
<
ProcMacro
<
'hir
>
>
,
crate
macros
:
Vec
<
Macro
>
,
crate
proc_macros
:
Vec
<
ProcMacro
>
,
crate
trait_aliases
:
Vec
<
TraitAlias
<
'hir
>>
,
crate
is_crate
:
bool
,
}
impl
Module
<
'hir
>
{
crate
fn
new
(
name
:
Option
<
Symbol
>
,
attrs
:
&
'hir
[
ast
::
Attribute
],
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
)
->
Module
<
'hir
>
{
crate
fn
new
(
name
:
Option
<
Symbol
>
,
attrs
:
&
'hir
[
ast
::
Attribute
])
->
Module
<
'hir
>
{
Module
{
name
,
id
:
hir
::
CRATE_HIR_ID
,
vis
,
where_outer
:
rustc_span
::
DUMMY_SP
,
where_inner
:
rustc_span
::
DUMMY_SP
,
attrs
,
...
...
@@ -83,53 +77,39 @@ impl Module<'hir> {
}
crate
struct
Struct
<
'hir
>
{
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
crate
id
:
hir
::
HirId
,
crate
struct_type
:
StructType
,
crate
name
:
Symbol
,
crate
generics
:
&
'hir
hir
::
Generics
<
'hir
>
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
fields
:
&
'hir
[
hir
::
StructField
<
'hir
>
],
crate
span
:
Span
,
}
crate
struct
Union
<
'hir
>
{
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
crate
id
:
hir
::
HirId
,
crate
struct_type
:
StructType
,
crate
name
:
Symbol
,
crate
generics
:
&
'hir
hir
::
Generics
<
'hir
>
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
fields
:
&
'hir
[
hir
::
StructField
<
'hir
>
],
crate
span
:
Span
,
}
crate
struct
Enum
<
'hir
>
{
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
crate
variants
:
Vec
<
Variant
<
'hir
>>
,
crate
generics
:
&
'hir
hir
::
Generics
<
'hir
>
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
id
:
hir
::
HirId
,
crate
span
:
Span
,
crate
name
:
Symbol
,
}
crate
struct
Variant
<
'hir
>
{
crate
name
:
Symbol
,
crate
id
:
hir
::
HirId
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
def
:
&
'hir
hir
::
VariantData
<
'hir
>
,
crate
span
:
Span
,
}
crate
struct
Function
<
'hir
>
{
crate
decl
:
&
'hir
hir
::
FnDecl
<
'hir
>
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
id
:
hir
::
HirId
,
crate
name
:
Symbol
,
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
crate
header
:
hir
::
FnHeader
,
crate
span
:
Span
,
crate
generics
:
&
'hir
hir
::
Generics
<
'hir
>
,
crate
body
:
hir
::
BodyId
,
}
...
...
@@ -139,18 +119,12 @@ impl Module<'hir> {
crate
gen
:
&
'hir
hir
::
Generics
<
'hir
>
,
crate
name
:
Symbol
,
crate
id
:
hir
::
HirId
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
span
:
Span
,
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
}
crate
struct
OpaqueTy
<
'hir
>
{
crate
opaque_ty
:
&
'hir
hir
::
OpaqueTy
<
'hir
>
,
crate
name
:
Symbol
,
crate
id
:
hir
::
HirId
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
span
:
Span
,
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
}
#[derive(Debug)]
...
...
@@ -169,10 +143,7 @@ impl Module<'hir> {
crate
type_
:
&
'hir
hir
::
Ty
<
'hir
>
,
crate
expr
:
hir
::
BodyId
,
crate
name
:
Symbol
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
crate
id
:
hir
::
HirId
,
crate
span
:
Span
,
}
crate
struct
Trait
<
'hir
>
{
...
...
@@ -184,18 +155,13 @@ impl Module<'hir> {
crate
bounds
:
&
'hir
[
hir
::
GenericBound
<
'hir
>
],
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
id
:
hir
::
HirId
,
crate
span
:
Span
,
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
}
crate
struct
TraitAlias
<
'hir
>
{
crate
name
:
Symbol
,
crate
generics
:
&
'hir
hir
::
Generics
<
'hir
>
,
crate
bounds
:
&
'hir
[
hir
::
GenericBound
<
'hir
>
],
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
id
:
hir
::
HirId
,
crate
span
:
Span
,
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
}
#[derive(Debug)]
...
...
@@ -215,22 +181,16 @@ impl Module<'hir> {
}
crate
struct
ForeignItem
<
'hir
>
{
crate
vis
:
&
'hir
hir
::
Visibility
<
'hir
>
,
crate
id
:
hir
::
HirId
,
crate
name
:
Symbol
,
crate
kind
:
&
'hir
hir
::
ForeignItemKind
<
'hir
>
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
span
:
Span
,
}
// For Macro we store the DefId instead of the NodeId, since we also create
// these imported macro_rules (which only have a DUMMY_NODE_ID).
crate
struct
Macro
<
'hir
>
{
crate
struct
Macro
{
crate
name
:
Symbol
,
crate
hid
:
hir
::
HirId
,
crate
def_id
:
hir
::
def_id
::
DefId
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
span
:
Span
,
crate
matchers
:
Vec
<
Span
>
,
crate
imported_from
:
Option
<
Symbol
>
,
}
...
...
@@ -256,13 +216,11 @@ impl Module<'hir> {
crate
span
:
Span
,
}
crate
struct
ProcMacro
<
'hir
>
{
crate
struct
ProcMacro
{
crate
name
:
Symbol
,
crate
id
:
hir
::
HirId
,
crate
kind
:
MacroKind
,
crate
helpers
:
Vec
<
Symbol
>
,
crate
attrs
:
&
'hir
[
ast
::
Attribute
],
crate
span
:
Span
,
}
crate
fn
struct_type_from_def
(
vdata
:
&
hir
::
VariantData
<
'_
>
)
->
StructType
{
...
...
src/librustdoc/visit_ast.rs
浏览文件 @
0e1a302f
...
...
@@ -91,16 +91,7 @@ fn visit_variant_data(
)
->
Struct
<
'tcx
>
{
debug!
(
"visiting struct"
);
let
struct_type
=
struct_type_from_def
(
&*
sd
);
Struct
{
id
:
item
.hir_id
,
struct_type
,
name
,
vis
:
&
item
.vis
,
attrs
:
&
item
.attrs
,
generics
,
fields
:
sd
.fields
(),
span
:
item
.span
,
}
Struct
{
id
:
item
.hir_id
,
struct_type
,
name
,
generics
,
fields
:
sd
.fields
()
}
}
fn
visit_union_data
(
...
...
@@ -112,16 +103,7 @@ fn visit_union_data(
)
->
Union
<
'tcx
>
{
debug!
(
"visiting union"
);
let
struct_type
=
struct_type_from_def
(
&*
sd
);
Union
{
id
:
item
.hir_id
,
struct_type
,
name
,
vis
:
&
item
.vis
,
attrs
:
&
item
.attrs
,
generics
,
fields
:
sd
.fields
(),
span
:
item
.span
,
}
Union
{
id
:
item
.hir_id
,
struct_type
,
name
,
generics
,
fields
:
sd
.fields
()
}
}
fn
visit_enum_def
(
...
...
@@ -137,19 +119,10 @@ fn visit_enum_def(
variants
:
def
.variants
.iter
()
.map
(|
v
|
Variant
{
name
:
v
.ident.name
,
id
:
v
.id
,
attrs
:
&
v
.attrs
,
def
:
&
v
.data
,
span
:
v
.span
,
})
.map
(|
v
|
Variant
{
name
:
v
.ident.name
,
id
:
v
.id
,
def
:
&
v
.data
})
.collect
(),
vis
:
&
it
.vis
,
generics
,
attrs
:
&
it
.attrs
,
id
:
it
.hir_id
,
span
:
it
.span
,
}
}
...
...
@@ -202,27 +175,10 @@ fn visit_fn(
}
}
om
.proc_macros
.push
(
ProcMacro
{
name
,
id
:
item
.hir_id
,
kind
,
helpers
,
attrs
:
&
item
.attrs
,
span
:
item
.span
,
});
om
.proc_macros
.push
(
ProcMacro
{
name
,
id
:
item
.hir_id
,
kind
,
helpers
});
}
None
=>
{
om
.fns
.push
(
Function
{
id
:
item
.hir_id
,
vis
:
&
item
.vis
,
attrs
:
&
item
.attrs
,
decl
,
name
,
span
:
item
.span
,
generics
,
header
,
body
,
});
om
.fns
.push
(
Function
{
id
:
item
.hir_id
,
decl
,
name
,
generics
,
header
,
body
});
}
}
}
...
...
@@ -236,7 +192,7 @@ fn visit_mod_contents(
m
:
&
'tcx
hir
::
Mod
<
'tcx
>
,
name
:
Option
<
Symbol
>
,
)
->
Module
<
'tcx
>
{
let
mut
om
=
Module
::
new
(
name
,
attrs
,
vis
);
let
mut
om
=
Module
::
new
(
name
,
attrs
);
om
.where_outer
=
span
;
om
.where_inner
=
m
.inner
;
om
.id
=
id
;
...
...
@@ -471,26 +427,11 @@ fn visit_item(
self
.visit_fn
(
om
,
item
,
ident
.name
,
&
sig
.decl
,
sig
.header
,
gen
,
body
)
}
hir
::
ItemKind
::
TyAlias
(
ty
,
ref
gen
)
=>
{
let
t
=
Typedef
{
ty
,
gen
,
name
:
ident
.name
,
id
:
item
.hir_id
,
attrs
:
&
item
.attrs
,
span
:
item
.span
,
vis
:
&
item
.vis
,
};
let
t
=
Typedef
{
ty
,
gen
,
name
:
ident
.name
,
id
:
item
.hir_id
};
om
.typedefs
.push
(
t
);
}
hir
::
ItemKind
::
OpaqueTy
(
ref
opaque_ty
)
=>
{
let
t
=
OpaqueTy
{
opaque_ty
,
name
:
ident
.name
,
id
:
item
.hir_id
,
attrs
:
&
item
.attrs
,
span
:
item
.span
,
vis
:
&
item
.vis
,
};
let
t
=
OpaqueTy
{
opaque_ty
,
name
:
ident
.name
,
id
:
item
.hir_id
};
om
.opaque_tys
.push
(
t
);
}
hir
::
ItemKind
::
Static
(
type_
,
mutability
,
expr
)
=>
{
...
...
@@ -510,15 +451,7 @@ fn visit_item(
// Underscore constants do not correspond to a nameable item and
// so are never useful in documentation.
if
ident
.name
!=
kw
::
Underscore
{
let
s
=
Constant
{
type_
,
expr
,
id
:
item
.hir_id
,
name
:
ident
.name
,
attrs
:
&
item
.attrs
,
span
:
item
.span
,
vis
:
&
item
.vis
,
};
let
s
=
Constant
{
type_
,
expr
,
id
:
item
.hir_id
,
name
:
ident
.name
};
om
.constants
.push
(
s
);
}
}
...
...
@@ -533,21 +466,11 @@ fn visit_item(
bounds
,
id
:
item
.hir_id
,
attrs
:
&
item
.attrs
,
span
:
item
.span
,
vis
:
&
item
.vis
,
};
om
.traits
.push
(
t
);
}
hir
::
ItemKind
::
TraitAlias
(
ref
generics
,
ref
bounds
)
=>
{
let
t
=
TraitAlias
{
name
:
ident
.name
,
generics
,
bounds
,
id
:
item
.hir_id
,
attrs
:
&
item
.attrs
,
span
:
item
.span
,
vis
:
&
item
.vis
,
};
let
t
=
TraitAlias
{
name
:
ident
.name
,
generics
,
bounds
,
id
:
item
.hir_id
};
om
.trait_aliases
.push
(
t
);
}
...
...
@@ -602,29 +525,19 @@ fn visit_foreign_item(
id
:
item
.hir_id
,
name
:
renamed
.unwrap_or
(
item
.ident
)
.name
,
kind
:
&
item
.kind
,
vis
:
&
item
.vis
,
attrs
:
&
item
.attrs
,
span
:
item
.span
,
});
}
// Convert each `exported_macro` into a doc item.
fn
visit_local_macro
(
&
self
,
def
:
&
'tcx
hir
::
MacroDef
<
'_
>
,
renamed
:
Option
<
Symbol
>
,
)
->
Macro
<
'tcx
>
{
fn
visit_local_macro
(
&
self
,
def
:
&
'tcx
hir
::
MacroDef
<
'_
>
,
renamed
:
Option
<
Symbol
>
)
->
Macro
{
debug!
(
"visit_local_macro: {}"
,
def
.ident
);
let
tts
=
def
.ast.body
.inner_tokens
()
.trees
()
.collect
::
<
Vec
<
_
>>
();
// Extract the spans of all matchers. They represent the "interface" of the macro.
let
matchers
=
tts
.chunks
(
4
)
.map
(|
arm
|
arm
[
0
]
.span
())
.collect
();
Macro
{
hid
:
def
.hir_id
,
def_id
:
self
.cx.tcx
.hir
()
.local_def_id
(
def
.hir_id
)
.to_def_id
(),
attrs
:
&
def
.attrs
,
name
:
renamed
.unwrap_or
(
def
.ident.name
),
span
:
def
.span
,
matchers
,
imported_from
:
None
,
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录