Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
03cbee84
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
03cbee84
编写于
11月 14, 2020
作者:
J
Joshua Nelson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename ItemEnum -> ItemKind, inner -> kind
上级
a1f7ca78
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
129 addition
and
131 deletion
+129
-131
src/librustdoc/clean/auto_trait.rs
src/librustdoc/clean/auto_trait.rs
+1
-1
src/librustdoc/clean/blanket_impl.rs
src/librustdoc/clean/blanket_impl.rs
+1
-1
src/librustdoc/clean/inline.rs
src/librustdoc/clean/inline.rs
+5
-5
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+31
-31
src/librustdoc/clean/types.rs
src/librustdoc/clean/types.rs
+16
-17
src/librustdoc/clean/utils.rs
src/librustdoc/clean/utils.rs
+9
-9
src/librustdoc/fold.rs
src/librustdoc/fold.rs
+8
-8
src/librustdoc/formats/cache.rs
src/librustdoc/formats/cache.rs
+9
-9
src/librustdoc/formats/item_type.rs
src/librustdoc/formats/item_type.rs
+3
-3
src/librustdoc/formats/mod.rs
src/librustdoc/formats/mod.rs
+1
-1
src/librustdoc/formats/renderer.rs
src/librustdoc/formats/renderer.rs
+1
-1
src/librustdoc/html/render/cache.rs
src/librustdoc/html/render/cache.rs
+1
-1
src/librustdoc/html/render/mod.rs
src/librustdoc/html/render/mod.rs
+28
-29
src/librustdoc/passes/calculate_doc_coverage.rs
src/librustdoc/passes/calculate_doc_coverage.rs
+1
-1
src/librustdoc/passes/collect_intra_doc_links.rs
src/librustdoc/passes/collect_intra_doc_links.rs
+4
-4
src/librustdoc/passes/collect_trait_impls.rs
src/librustdoc/passes/collect_trait_impls.rs
+4
-4
src/librustdoc/passes/doc_test_lints.rs
src/librustdoc/passes/doc_test_lints.rs
+1
-1
src/librustdoc/passes/strip_hidden.rs
src/librustdoc/passes/strip_hidden.rs
+1
-1
src/librustdoc/passes/stripper.rs
src/librustdoc/passes/stripper.rs
+4
-4
未找到文件。
src/librustdoc/clean/auto_trait.rs
浏览文件 @
03cbee84
...
...
@@ -125,7 +125,7 @@ pub fn get_auto_trait_impls(&self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec
def_id
:
self
.cx
.next_def_id
(
param_env_def_id
.krate
),
stability
:
None
,
deprecation
:
None
,
inner
:
ImplItem
(
Impl
{
kind
:
ImplItem
(
Impl
{
unsafety
:
hir
::
Unsafety
::
Normal
,
generics
:
new_generics
,
provided_trait_methods
:
Default
::
default
(),
...
...
src/librustdoc/clean/blanket_impl.rs
浏览文件 @
03cbee84
...
...
@@ -98,7 +98,7 @@ pub fn get_blanket_impls(&self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec<It
def_id
:
self
.cx
.next_def_id
(
impl_def_id
.krate
),
stability
:
None
,
deprecation
:
None
,
inner
:
ImplItem
(
Impl
{
kind
:
ImplItem
(
Impl
{
unsafety
:
hir
::
Unsafety
::
Normal
,
generics
:
(
self
.cx.tcx
.generics_of
(
impl_def_id
),
...
...
src/librustdoc/clean/inline.rs
浏览文件 @
03cbee84
...
...
@@ -54,7 +54,7 @@
debug!
(
"attrs={:?}"
,
attrs
);
let
attrs_clone
=
attrs
;
let
inner
=
match
res
{
let
kind
=
match
res
{
Res
::
Def
(
DefKind
::
Trait
,
did
)
=>
{
record_extern_fqn
(
cx
,
did
,
clean
::
TypeKind
::
Trait
);
ret
.extend
(
build_impls
(
cx
,
Some
(
parent_module
),
did
,
attrs
));
...
...
@@ -128,7 +128,7 @@
source
:
cx
.tcx
.def_span
(
did
)
.clean
(
cx
),
name
:
Some
(
name
.clean
(
cx
)),
attrs
,
inner
,
kind
,
visibility
:
clean
::
Public
,
stability
:
cx
.tcx
.lookup_stability
(
did
)
.cloned
(),
deprecation
:
cx
.tcx
.lookup_deprecation
(
did
)
.clean
(
cx
),
...
...
@@ -446,7 +446,7 @@ fn merge_attrs(
debug!
(
"build_impl: impl {:?} for {:?}"
,
trait_
.def_id
(),
for_
.def_id
());
ret
.push
(
clean
::
Item
{
inner
:
clean
::
ImplItem
(
clean
::
Impl
{
kind
:
clean
::
ImplItem
(
clean
::
Impl
{
unsafety
:
hir
::
Unsafety
::
Normal
,
generics
,
provided_trait_methods
:
provided
,
...
...
@@ -498,7 +498,7 @@ fn fill_in(
visibility
:
clean
::
Public
,
stability
:
None
,
deprecation
:
None
,
inner
:
clean
::
ImportItem
(
clean
::
Import
::
new_simple
(
kind
:
clean
::
ImportItem
(
clean
::
Import
::
new_simple
(
item
.ident
.to_string
(),
clean
::
ImportSource
{
path
:
clean
::
Path
{
...
...
@@ -555,7 +555,7 @@ fn build_static(cx: &DocContext<'_>, did: DefId, mutable: bool) -> clean::Static
}
}
fn
build_macro
(
cx
:
&
DocContext
<
'_
>
,
did
:
DefId
,
name
:
Symbol
)
->
clean
::
Item
Enum
{
fn
build_macro
(
cx
:
&
DocContext
<
'_
>
,
did
:
DefId
,
name
:
Symbol
)
->
clean
::
Item
Kind
{
let
imported_from
=
cx
.tcx
.original_crate_name
(
did
.krate
);
match
cx
.enter_resolver
(|
r
|
r
.cstore
()
.load_macro_untracked
(
did
,
cx
.sess
()))
{
LoadedMacro
::
MacroDef
(
def
,
_
)
=>
{
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
03cbee84
...
...
@@ -42,7 +42,7 @@
pub
use
utils
::{
get_auto_trait_and_blanket_impls
,
krate
,
register_res
};
pub
use
self
::
types
::
FnRetTy
::
*
;
pub
use
self
::
types
::
Item
Enum
::
*
;
pub
use
self
::
types
::
Item
Kind
::
*
;
pub
use
self
::
types
::
SelfTy
::
*
;
pub
use
self
::
types
::
Type
::
*
;
pub
use
self
::
types
::
Visibility
::{
Inherited
,
Public
};
...
...
@@ -276,7 +276,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
def_id
:
cx
.tcx
.hir
()
.local_def_id
(
self
.id
)
.to_def_id
(),
inner
:
ModuleItem
(
Module
{
is_crate
:
self
.is_crate
,
items
}),
kind
:
ModuleItem
(
Module
{
is_crate
:
self
.is_crate
,
items
}),
}
}
}
...
...
@@ -916,7 +916,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
def_id
:
did
.to_def_id
(),
inner
:
FunctionItem
(
Function
{
kind
:
FunctionItem
(
Function
{
decl
,
generics
,
header
:
hir
::
FnHeader
{
constness
,
..
self
.header
},
...
...
@@ -1023,7 +1023,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
TraitItem
(
Trait
{
kind
:
TraitItem
(
Trait
{
auto
:
self
.is_auto
.clean
(
cx
),
unsafety
:
self
.unsafety
,
items
:
self
.items
.iter
()
.map
(|
ti
|
ti
.clean
(
cx
))
.collect
(),
...
...
@@ -1047,7 +1047,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
TraitAliasItem
(
TraitAlias
{
kind
:
TraitAliasItem
(
TraitAlias
{
generics
:
self
.generics
.clean
(
cx
),
bounds
:
self
.bounds
.clean
(
cx
),
}),
...
...
@@ -1102,7 +1102,7 @@ fn clean(&self, _: &DocContext<'_>) -> TypeKind {
impl
Clean
<
Item
>
for
hir
::
TraitItem
<
'_
>
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
>
)
->
Item
{
let
local_did
=
cx
.tcx
.hir
()
.local_def_id
(
self
.hir_id
);
let
inner
=
match
self
.kind
{
let
kind
=
match
self
.kind
{
hir
::
TraitItemKind
::
Const
(
ref
ty
,
default
)
=>
{
AssocConstItem
(
ty
.clean
(
cx
),
default
.map
(|
e
|
print_const_expr
(
cx
,
e
)))
}
...
...
@@ -1140,7 +1140,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
Visibility
::
Inherited
,
stability
:
get_stability
(
cx
,
local_did
.to_def_id
()),
deprecation
:
get_deprecation
(
cx
,
local_did
.to_def_id
()),
inner
,
kind
,
}
}
}
...
...
@@ -1148,7 +1148,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
impl
Clean
<
Item
>
for
hir
::
ImplItem
<
'_
>
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
>
)
->
Item
{
let
local_did
=
cx
.tcx
.hir
()
.local_def_id
(
self
.hir_id
);
let
inner
=
match
self
.kind
{
let
kind
=
match
self
.kind
{
hir
::
ImplItemKind
::
Const
(
ref
ty
,
expr
)
=>
{
AssocConstItem
(
ty
.clean
(
cx
),
Some
(
print_const_expr
(
cx
,
expr
)))
}
...
...
@@ -1175,14 +1175,14 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
get_stability
(
cx
,
local_did
.to_def_id
()),
deprecation
:
get_deprecation
(
cx
,
local_did
.to_def_id
()),
inner
,
kind
,
}
}
}
impl
Clean
<
Item
>
for
ty
::
AssocItem
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
>
)
->
Item
{
let
inner
=
match
self
.kind
{
let
kind
=
match
self
.kind
{
ty
::
AssocKind
::
Const
=>
{
let
ty
=
cx
.tcx
.type_of
(
self
.def_id
);
let
default
=
if
self
.defaultness
.has_value
()
{
...
...
@@ -1343,7 +1343,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
def_id
:
self
.def_id
,
attrs
:
inline
::
load_attrs
(
cx
,
self
.def_id
)
.clean
(
cx
),
source
:
cx
.tcx
.def_span
(
self
.def_id
)
.clean
(
cx
),
inner
,
kind
,
}
}
}
...
...
@@ -1784,7 +1784,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
stability
:
get_stability
(
cx
,
local_did
.to_def_id
()),
deprecation
:
get_deprecation
(
cx
,
local_did
.to_def_id
()),
def_id
:
local_did
.to_def_id
(),
inner
:
StructFieldItem
(
self
.ty
.clean
(
cx
)),
kind
:
StructFieldItem
(
self
.ty
.clean
(
cx
)),
}
}
}
...
...
@@ -1799,7 +1799,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
stability
:
get_stability
(
cx
,
self
.did
),
deprecation
:
get_deprecation
(
cx
,
self
.did
),
def_id
:
self
.did
,
inner
:
StructFieldItem
(
cx
.tcx
.type_of
(
self
.did
)
.clean
(
cx
)),
kind
:
StructFieldItem
(
cx
.tcx
.type_of
(
self
.did
)
.clean
(
cx
)),
}
}
}
...
...
@@ -1835,7 +1835,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
StructItem
(
Struct
{
kind
:
StructItem
(
Struct
{
struct_type
:
self
.struct_type
,
generics
:
self
.generics
.clean
(
cx
),
fields
:
self
.fields
.clean
(
cx
),
...
...
@@ -1855,7 +1855,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
UnionItem
(
Union
{
kind
:
UnionItem
(
Union
{
struct_type
:
self
.struct_type
,
generics
:
self
.generics
.clean
(
cx
),
fields
:
self
.fields
.clean
(
cx
),
...
...
@@ -1885,7 +1885,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
EnumItem
(
Enum
{
kind
:
EnumItem
(
Enum
{
variants
:
self
.variants
.iter
()
.map
(|
v
|
v
.clean
(
cx
))
.collect
(),
generics
:
self
.generics
.clean
(
cx
),
variants_stripped
:
false
,
...
...
@@ -1904,7 +1904,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
def_id
:
cx
.tcx
.hir
()
.local_def_id
(
self
.id
)
.to_def_id
(),
inner
:
VariantItem
(
Variant
{
kind
:
self
.def
.clean
(
cx
)
}),
kind
:
VariantItem
(
Variant
{
kind
:
self
.def
.clean
(
cx
)
}),
}
}
}
...
...
@@ -1930,7 +1930,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
def_id
:
field
.did
,
stability
:
get_stability
(
cx
,
field
.did
),
deprecation
:
get_deprecation
(
cx
,
field
.did
),
inner
:
StructFieldItem
(
cx
.tcx
.type_of
(
field
.did
)
.clean
(
cx
)),
kind
:
StructFieldItem
(
cx
.tcx
.type_of
(
field
.did
)
.clean
(
cx
)),
})
.collect
(),
}),
...
...
@@ -1941,7 +1941,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
source
:
cx
.tcx
.def_span
(
self
.def_id
)
.clean
(
cx
),
visibility
:
Inherited
,
def_id
:
self
.def_id
,
inner
:
VariantItem
(
Variant
{
kind
}),
kind
:
VariantItem
(
Variant
{
kind
}),
stability
:
get_stability
(
cx
,
self
.def_id
),
deprecation
:
get_deprecation
(
cx
,
self
.def_id
),
}
...
...
@@ -2057,7 +2057,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
TypedefItem
(
Typedef
{
type_
,
generics
:
self
.gen
.clean
(
cx
),
item_type
},
false
),
kind
:
TypedefItem
(
Typedef
{
type_
,
generics
:
self
.gen
.clean
(
cx
),
item_type
},
false
),
}
}
}
...
...
@@ -2072,7 +2072,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
OpaqueTyItem
(
OpaqueTy
{
kind
:
OpaqueTyItem
(
OpaqueTy
{
bounds
:
self
.opaque_ty.bounds
.clean
(
cx
),
generics
:
self
.opaque_ty.generics
.clean
(
cx
),
}),
...
...
@@ -2100,7 +2100,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
StaticItem
(
Static
{
kind
:
StaticItem
(
Static
{
type_
:
self
.type_
.clean
(
cx
),
mutability
:
self
.mutability
,
expr
:
print_const_expr
(
cx
,
self
.expr
),
...
...
@@ -2121,7 +2121,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
ConstantItem
(
Constant
{
kind
:
ConstantItem
(
Constant
{
type_
:
self
.type_
.clean
(
cx
),
expr
:
print_const_expr
(
cx
,
self
.expr
),
value
:
print_evaluated_const
(
cx
,
def_id
.to_def_id
()),
...
...
@@ -2175,7 +2175,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
:
ImplItem
(
Impl
{
kind
:
ImplItem
(
Impl
{
unsafety
:
self
.unsafety
,
generics
:
self
.generics
.clean
(
cx
),
provided_trait_methods
:
provided
.clone
(),
...
...
@@ -2231,7 +2231,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
None
,
deprecation
:
None
,
inner
:
ExternCrateItem
(
self
.name
.clean
(
cx
),
self
.path
.clone
()),
kind
:
ExternCrateItem
(
self
.name
.clean
(
cx
),
self
.path
.clone
()),
}]
}
}
...
...
@@ -2302,7 +2302,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
None
,
deprecation
:
None
,
inner
:
ImportItem
(
Import
::
new_simple
(
kind
:
ImportItem
(
Import
::
new_simple
(
self
.name
.clean
(
cx
),
resolve_use_source
(
cx
,
path
),
false
,
...
...
@@ -2322,14 +2322,14 @@ fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
None
,
deprecation
:
None
,
inner
:
ImportItem
(
inner
),
kind
:
ImportItem
(
inner
),
}]
}
}
impl
Clean
<
Item
>
for
doctree
::
ForeignItem
<
'_
>
{
fn
clean
(
&
self
,
cx
:
&
DocContext
<
'_
>
)
->
Item
{
let
inner
=
match
self
.kind
{
let
kind
=
match
self
.kind
{
hir
::
ForeignItemKind
::
Fn
(
ref
decl
,
ref
names
,
ref
generics
)
=>
{
let
abi
=
cx
.tcx
.hir
()
.get_foreign_abi
(
self
.id
);
let
(
generics
,
decl
)
=
...
...
@@ -2364,7 +2364,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
visibility
:
self
.vis
.clean
(
cx
),
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
inner
,
kind
,
}
}
}
...
...
@@ -2380,7 +2380,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
stability
:
cx
.stability
(
self
.hid
),
deprecation
:
cx
.deprecation
(
self
.hid
)
.clean
(
cx
),
def_id
:
self
.def_id
,
inner
:
MacroItem
(
Macro
{
kind
:
MacroItem
(
Macro
{
source
:
format!
(
"macro_rules! {} {{
\n
{}}}"
,
name
,
...
...
@@ -2405,7 +2405,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Item {
stability
:
cx
.stability
(
self
.id
),
deprecation
:
cx
.deprecation
(
self
.id
)
.clean
(
cx
),
def_id
:
cx
.tcx
.hir
()
.local_def_id
(
self
.id
)
.to_def_id
(),
inner
:
ProcMacroItem
(
ProcMacro
{
kind
:
self
.kind
,
helpers
:
self
.helpers
.clean
(
cx
)
}),
kind
:
ProcMacroItem
(
ProcMacro
{
kind
:
self
.kind
,
helpers
:
self
.helpers
.clean
(
cx
)
}),
}
}
}
...
...
src/librustdoc/clean/types.rs
浏览文件 @
03cbee84
...
...
@@ -41,7 +41,7 @@
use
crate
::
html
::
render
::
cache
::
ExternalLocation
;
use
self
::
FnRetTy
::
*
;
use
self
::
Item
Enum
::
*
;
use
self
::
Item
Kind
::
*
;
use
self
::
SelfTy
::
*
;
use
self
::
Type
::
*
;
...
...
@@ -81,7 +81,7 @@ pub struct Item {
/// Not everything has a name. E.g., impls
pub
name
:
Option
<
String
>
,
pub
attrs
:
Attributes
,
pub
inner
:
ItemEnum
,
pub
kind
:
ItemKind
,
pub
visibility
:
Visibility
,
pub
def_id
:
DefId
,
pub
stability
:
Option
<
Stability
>
,
...
...
@@ -90,14 +90,13 @@ pub struct Item {
impl
fmt
::
Debug
for
Item
{
fn
fmt
(
&
self
,
fmt
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
let
fake
=
self
.is_fake
();
let
def_id
:
&
dyn
fmt
::
Debug
=
if
fake
{
&
"**FAKE**"
}
else
{
&
self
.def_id
};
let
def_id
:
&
dyn
fmt
::
Debug
=
if
self
.is_fake
()
{
&
"**FAKE**"
}
else
{
&
self
.def_id
};
fmt
.debug_struct
(
"Item"
)
.field
(
"source"
,
&
self
.source
)
.field
(
"name"
,
&
self
.name
)
.field
(
"attrs"
,
&
self
.attrs
)
.field
(
"
inner"
,
&
self
.inner
)
.field
(
"
kind"
,
&
self
.kind
)
.field
(
"visibility"
,
&
self
.visibility
)
.field
(
"def_id"
,
def_id
)
.field
(
"stability"
,
&
self
.stability
)
...
...
@@ -124,7 +123,7 @@ pub fn links(&self) -> Vec<RenderedLink> {
}
pub
fn
is_crate
(
&
self
)
->
bool
{
match
self
.
inner
{
match
self
.
kind
{
StrippedItem
(
box
ModuleItem
(
Module
{
is_crate
:
true
,
..
}))
|
ModuleItem
(
Module
{
is_crate
:
true
,
..
})
=>
true
,
_
=>
false
,
...
...
@@ -176,14 +175,14 @@ pub fn is_keyword(&self) -> bool {
self
.type_
()
==
ItemType
::
Keyword
}
pub
fn
is_stripped
(
&
self
)
->
bool
{
match
self
.
inner
{
match
self
.
kind
{
StrippedItem
(
..
)
=>
true
,
ImportItem
(
ref
i
)
=>
!
i
.should_be_displayed
,
_
=>
false
,
}
}
pub
fn
has_stripped_fields
(
&
self
)
->
Option
<
bool
>
{
match
self
.
inner
{
match
self
.
kind
{
StructItem
(
ref
_
struct
)
=>
Some
(
_
struct
.fields_stripped
),
UnionItem
(
ref
union
)
=>
Some
(
union
.fields_stripped
),
VariantItem
(
Variant
{
kind
:
VariantKind
::
Struct
(
ref
vstruct
)
})
=>
{
...
...
@@ -227,8 +226,8 @@ pub fn type_(&self) -> ItemType {
}
pub
fn
is_default
(
&
self
)
->
bool
{
match
self
.
inner
{
Item
Enum
::
MethodItem
(
ref
meth
)
=>
{
match
self
.
kind
{
Item
Kind
::
MethodItem
(
ref
meth
)
=>
{
if
let
Some
(
defaultness
)
=
meth
.defaultness
{
defaultness
.has_value
()
&&
!
defaultness
.is_final
()
}
else
{
...
...
@@ -248,7 +247,7 @@ pub fn is_fake(&self) -> bool {
}
#[derive(Clone,
Debug)]
pub
enum
Item
Enum
{
pub
enum
Item
Kind
{
ExternCrateItem
(
String
,
Option
<
String
>
),
ImportItem
(
Import
),
StructItem
(
Struct
),
...
...
@@ -282,23 +281,23 @@ pub enum ItemEnum {
AssocConstItem
(
Type
,
Option
<
String
>
),
AssocTypeItem
(
Vec
<
GenericBound
>
,
Option
<
Type
>
),
/// An item that has been stripped by a rustdoc pass
StrippedItem
(
Box
<
Item
Enum
>
),
StrippedItem
(
Box
<
Item
Kind
>
),
KeywordItem
(
String
),
}
impl
Item
Enum
{
impl
Item
Kind
{
pub
fn
is_type_alias
(
&
self
)
->
bool
{
match
*
self
{
Item
Enum
::
TypedefItem
(
_
,
_
)
|
ItemEnum
::
AssocTypeItem
(
_
,
_
)
=>
true
,
Item
Kind
::
TypedefItem
(
_
,
_
)
|
ItemKind
::
AssocTypeItem
(
_
,
_
)
=>
true
,
_
=>
false
,
}
}
pub
fn
as_assoc_kind
(
&
self
)
->
Option
<
AssocKind
>
{
match
*
self
{
Item
Enum
::
AssocConstItem
(
..
)
=>
Some
(
AssocKind
::
Const
),
Item
Enum
::
AssocTypeItem
(
..
)
=>
Some
(
AssocKind
::
Type
),
Item
Enum
::
TyMethodItem
(
..
)
|
ItemEnum
::
MethodItem
(
..
)
=>
Some
(
AssocKind
::
Fn
),
Item
Kind
::
AssocConstItem
(
..
)
=>
Some
(
AssocKind
::
Const
),
Item
Kind
::
AssocTypeItem
(
..
)
=>
Some
(
AssocKind
::
Type
),
Item
Kind
::
TyMethodItem
(
..
)
|
ItemKind
::
MethodItem
(
..
)
=>
Some
(
AssocKind
::
Fn
),
_
=>
None
,
}
}
...
...
src/librustdoc/clean/utils.rs
浏览文件 @
03cbee84
...
...
@@ -2,7 +2,7 @@
use
crate
::
clean
::
blanket_impl
::
BlanketImplFinder
;
use
crate
::
clean
::{
inline
,
Clean
,
Crate
,
Deprecation
,
ExternalCrate
,
FnDecl
,
FnRetTy
,
Generic
,
GenericArg
,
GenericArgs
,
GenericBound
,
Generics
,
GetDefId
,
ImportSource
,
Item
,
Item
Enum
,
Lifetime
,
GenericArgs
,
GenericBound
,
Generics
,
GetDefId
,
ImportSource
,
Item
,
Item
Kind
,
Lifetime
,
MacroKind
,
Path
,
PathSegment
,
Primitive
,
PrimitiveType
,
ResolvedPath
,
Span
,
Type
,
TypeBinding
,
TypeKind
,
Visibility
,
WherePredicate
,
};
...
...
@@ -44,8 +44,8 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
let
mut
module
=
module
.clean
(
cx
);
let
mut
masked_crates
=
FxHashSet
::
default
();
match
module
.
inner
{
Item
Enum
::
ModuleItem
(
ref
module
)
=>
{
match
module
.
kind
{
Item
Kind
::
ModuleItem
(
ref
module
)
=>
{
for
it
in
&
module
.items
{
// `compiler_builtins` should be masked too, but we can't apply
// `#[doc(masked)]` to the injected `extern crate` because it's unstable.
...
...
@@ -62,8 +62,8 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
let
ExternalCrate
{
name
,
src
,
primitives
,
keywords
,
..
}
=
LOCAL_CRATE
.clean
(
cx
);
{
let
m
=
match
module
.
inner
{
Item
Enum
::
ModuleItem
(
ref
mut
m
)
=>
m
,
let
m
=
match
module
.
kind
{
Item
Kind
::
ModuleItem
(
ref
mut
m
)
=>
m
,
_
=>
unreachable!
(),
};
m
.items
.extend
(
primitives
.iter
()
.map
(|
&
(
def_id
,
prim
,
ref
attrs
)|
Item
{
...
...
@@ -74,7 +74,7 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
stability
:
get_stability
(
cx
,
def_id
),
deprecation
:
get_deprecation
(
cx
,
def_id
),
def_id
,
inner
:
ItemEnum
::
PrimitiveItem
(
prim
),
kind
:
ItemKind
::
PrimitiveItem
(
prim
),
}));
m
.items
.extend
(
keywords
.into_iter
()
.map
(|(
def_id
,
kw
,
attrs
)|
Item
{
source
:
Span
::
empty
(),
...
...
@@ -84,7 +84,7 @@ pub fn krate(mut cx: &mut DocContext<'_>) -> Crate {
stability
:
get_stability
(
cx
,
def_id
),
deprecation
:
get_deprecation
(
cx
,
def_id
),
def_id
,
inner
:
ItemEnum
::
KeywordItem
(
kw
),
kind
:
ItemKind
::
KeywordItem
(
kw
),
}));
}
...
...
@@ -355,8 +355,8 @@ pub fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut V
let
tcx
=
cx
.tcx
;
for
item
in
items
{
let
target
=
match
item
.
inner
{
Item
Enum
::
TypedefItem
(
ref
t
,
true
)
=>
&
t
.type_
,
let
target
=
match
item
.
kind
{
Item
Kind
::
TypedefItem
(
ref
t
,
true
)
=>
&
t
.type_
,
_
=>
continue
,
};
let
primitive
=
match
*
target
{
...
...
src/librustdoc/fold.rs
浏览文件 @
03cbee84
...
...
@@ -5,9 +5,9 @@
impl
StripItem
{
pub
fn
strip
(
self
)
->
Option
<
Item
>
{
match
self
.0
{
Item
{
inner
:
StrippedItem
(
..
),
..
}
=>
Some
(
self
.0
),
Item
{
kind
:
StrippedItem
(
..
),
..
}
=>
Some
(
self
.0
),
mut
i
=>
{
i
.
inner
=
StrippedItem
(
box
i
.inner
);
i
.
kind
=
StrippedItem
(
box
i
.kind
);
Some
(
i
)
}
}
...
...
@@ -20,8 +20,8 @@ fn fold_item(&mut self, item: Item) -> Option<Item> {
}
/// don't override!
fn
fold_inner_recur
(
&
mut
self
,
inner
:
ItemEnum
)
->
ItemEnum
{
match
inner
{
fn
fold_inner_recur
(
&
mut
self
,
kind
:
ItemKind
)
->
ItemKind
{
match
kind
{
StrippedItem
(
..
)
=>
unreachable!
(),
ModuleItem
(
i
)
=>
ModuleItem
(
self
.fold_mod
(
i
)),
StructItem
(
mut
i
)
=>
{
...
...
@@ -72,14 +72,14 @@ fn fold_inner_recur(&mut self, inner: ItemEnum) -> ItemEnum {
/// don't override!
fn
fold_item_recur
(
&
mut
self
,
item
:
Item
)
->
Option
<
Item
>
{
let
Item
{
attrs
,
name
,
source
,
visibility
,
def_id
,
inner
,
stability
,
deprecation
}
=
item
;
let
Item
{
attrs
,
name
,
source
,
visibility
,
def_id
,
kind
,
stability
,
deprecation
}
=
item
;
let
inner
=
match
inner
{
let
kind
=
match
kind
{
StrippedItem
(
box
i
)
=>
StrippedItem
(
box
self
.fold_inner_recur
(
i
)),
_
=>
self
.fold_inner_recur
(
inner
),
_
=>
self
.fold_inner_recur
(
kind
),
};
Some
(
Item
{
attrs
,
name
,
source
,
inner
,
visibility
,
stability
,
deprecation
,
def_id
})
Some
(
Item
{
attrs
,
name
,
source
,
kind
,
visibility
,
stability
,
deprecation
,
def_id
})
}
fn
fold_mod
(
&
mut
self
,
m
:
Module
)
->
Module
{
...
...
src/librustdoc/formats/cache.rs
浏览文件 @
03cbee84
...
...
@@ -218,7 +218,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// If this is a stripped module,
// we don't want it or its children in the search index.
let
orig_stripped_mod
=
match
item
.
inner
{
let
orig_stripped_mod
=
match
item
.
kind
{
clean
::
StrippedItem
(
box
clean
::
ModuleItem
(
..
))
=>
{
mem
::
replace
(
&
mut
self
.stripped_mod
,
true
)
}
...
...
@@ -227,7 +227,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// If the impl is from a masked crate or references something from a
// masked crate then remove it completely.
if
let
clean
::
ImplItem
(
ref
i
)
=
item
.
inner
{
if
let
clean
::
ImplItem
(
ref
i
)
=
item
.
kind
{
if
self
.masked_crates
.contains
(
&
item
.def_id.krate
)
||
i
.trait_
.def_id
()
.map_or
(
false
,
|
d
|
self
.masked_crates
.contains
(
&
d
.krate
))
||
i
.for_
.def_id
()
.map_or
(
false
,
|
d
|
self
.masked_crates
.contains
(
&
d
.krate
))
...
...
@@ -238,12 +238,12 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// Propagate a trait method's documentation to all implementors of the
// trait.
if
let
clean
::
TraitItem
(
ref
t
)
=
item
.
inner
{
if
let
clean
::
TraitItem
(
ref
t
)
=
item
.
kind
{
self
.traits
.entry
(
item
.def_id
)
.or_insert_with
(||
t
.clone
());
}
// Collect all the implementors of traits.
if
let
clean
::
ImplItem
(
ref
i
)
=
item
.
inner
{
if
let
clean
::
ImplItem
(
ref
i
)
=
item
.
kind
{
if
let
Some
(
did
)
=
i
.trait_
.def_id
()
{
if
i
.blanket_impl
.is_none
()
{
self
.implementors
...
...
@@ -256,7 +256,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// Index this method for searching later on.
if
let
Some
(
ref
s
)
=
item
.name
{
let
(
parent
,
is_inherent_impl_item
)
=
match
item
.
inner
{
let
(
parent
,
is_inherent_impl_item
)
=
match
item
.
kind
{
clean
::
StrippedItem
(
..
)
=>
((
None
,
None
),
false
),
clean
::
AssocConstItem
(
..
)
|
clean
::
TypedefItem
(
_
,
true
)
if
self
.parent_is_trait_impl
=>
...
...
@@ -345,7 +345,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
_
=>
false
,
};
match
item
.
inner
{
match
item
.
kind
{
clean
::
StructItem
(
..
)
|
clean
::
EnumItem
(
..
)
|
clean
::
TypedefItem
(
..
)
...
...
@@ -384,7 +384,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// Maintain the parent stack
let
orig_parent_is_trait_impl
=
self
.parent_is_trait_impl
;
let
parent_pushed
=
match
item
.
inner
{
let
parent_pushed
=
match
item
.
kind
{
clean
::
TraitItem
(
..
)
|
clean
::
EnumItem
(
..
)
|
clean
::
ForeignTypeItem
...
...
@@ -422,12 +422,12 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// Once we've recursively found all the generics, hoard off all the
// implementations elsewhere.
let
ret
=
self
.fold_item_recur
(
item
)
.and_then
(|
item
|
{
if
let
clean
::
Item
{
inner
:
clean
::
ImplItem
(
_
),
..
}
=
item
{
if
let
clean
::
Item
{
kind
:
clean
::
ImplItem
(
_
),
..
}
=
item
{
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
// Note: matching twice to restrict the lifetime of the `i` borrow.
let
mut
dids
=
FxHashSet
::
default
();
if
let
clean
::
Item
{
inner
:
clean
::
ImplItem
(
ref
i
),
..
}
=
item
{
if
let
clean
::
Item
{
kind
:
clean
::
ImplItem
(
ref
i
),
..
}
=
item
{
match
i
.for_
{
clean
::
ResolvedPath
{
did
,
..
}
|
clean
::
BorrowedRef
{
...
...
src/librustdoc/formats/item_type.rs
浏览文件 @
03cbee84
...
...
@@ -60,12 +60,12 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
impl
<
'a
>
From
<&
'a
clean
::
Item
>
for
ItemType
{
fn
from
(
item
:
&
'a
clean
::
Item
)
->
ItemType
{
let
inner
=
match
item
.inner
{
let
kind
=
match
item
.kind
{
clean
::
StrippedItem
(
box
ref
item
)
=>
item
,
ref
inner
=>
inner
,
ref
kind
=>
kind
,
};
match
*
inner
{
match
*
kind
{
clean
::
ModuleItem
(
..
)
=>
ItemType
::
Module
,
clean
::
ExternCrateItem
(
..
)
=>
ItemType
::
ExternCrate
,
clean
::
ImportItem
(
..
)
=>
ItemType
::
Import
,
...
...
src/librustdoc/formats/mod.rs
浏览文件 @
03cbee84
...
...
@@ -32,7 +32,7 @@ pub struct Impl {
impl
Impl
{
pub
fn
inner_impl
(
&
self
)
->
&
clean
::
Impl
{
match
self
.impl_item.
inner
{
match
self
.impl_item.
kind
{
clean
::
ImplItem
(
ref
impl_
)
=>
impl_
,
_
=>
panic!
(
"non-impl item found in impl"
),
}
...
...
src/librustdoc/formats/renderer.rs
浏览文件 @
03cbee84
...
...
@@ -86,7 +86,7 @@ pub fn run_format<T: FormatRenderer>(
}
cx
.mod_item_in
(
&
item
,
&
name
,
&
cache
)
?
;
let
module
=
match
item
.
inner
{
let
module
=
match
item
.
kind
{
clean
::
StrippedItem
(
box
clean
::
ModuleItem
(
m
))
|
clean
::
ModuleItem
(
m
)
=>
m
,
_
=>
unreachable!
(),
};
...
...
src/librustdoc/html/render/cache.rs
浏览文件 @
03cbee84
...
...
@@ -165,7 +165,7 @@ struct CrateData<'a> {
}
crate
fn
get_index_search_type
(
item
:
&
clean
::
Item
)
->
Option
<
IndexItemFunctionType
>
{
let
(
all_types
,
ret_types
)
=
match
item
.
inner
{
let
(
all_types
,
ret_types
)
=
match
item
.
kind
{
clean
::
FunctionItem
(
ref
f
)
=>
(
&
f
.all_types
,
&
f
.ret_types
),
clean
::
MethodItem
(
ref
m
)
=>
(
&
m
.all_types
,
&
m
.ret_types
),
clean
::
TyMethodItem
(
ref
m
)
=>
(
&
m
.all_types
,
&
m
.ret_types
),
...
...
src/librustdoc/html/render/mod.rs
浏览文件 @
03cbee84
...
...
@@ -618,7 +618,7 @@ fn mod_item_in(
// Render sidebar-items.js used throughout this module.
if
!
self
.render_redirect_pages
{
let
module
=
match
item
.
inner
{
let
module
=
match
item
.
kind
{
clean
::
StrippedItem
(
box
clean
::
ModuleItem
(
ref
m
))
|
clean
::
ModuleItem
(
ref
m
)
=>
m
,
_
=>
unreachable!
(),
};
...
...
@@ -1717,7 +1717,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
write!
(
buf
,
"</span>"
);
// out-of-band
write!
(
buf
,
"<span class=
\"
in-band
\"
>"
);
let
name
=
match
item
.
inner
{
let
name
=
match
item
.
kind
{
clean
::
ModuleItem
(
ref
m
)
=>
{
if
m
.is_crate
{
"Crate "
...
...
@@ -1766,7 +1766,7 @@ fn print_item(cx: &Context, item: &clean::Item, buf: &mut Buffer, cache: &Cache)
write!
(
buf
,
"</span></h1>"
);
// in-band
match
item
.
inner
{
match
item
.
kind
{
clean
::
ModuleItem
(
ref
m
)
=>
item_module
(
buf
,
cx
,
item
,
&
m
.items
),
clean
::
FunctionItem
(
ref
f
)
|
clean
::
ForeignFunctionItem
(
ref
f
)
=>
{
item_function
(
buf
,
cx
,
item
,
f
)
...
...
@@ -2133,7 +2133,7 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: usize, idx2: usize) -> Ordering
);
}
match
myitem
.
inner
{
match
myitem
.
kind
{
clean
::
ExternCrateItem
(
ref
name
,
ref
src
)
=>
{
use
crate
::
html
::
format
::
anchor
;
...
...
@@ -2169,7 +2169,7 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: usize, idx2: usize) -> Ordering
continue
;
}
let
unsafety_flag
=
match
myitem
.
inner
{
let
unsafety_flag
=
match
myitem
.
kind
{
clean
::
FunctionItem
(
ref
func
)
|
clean
::
ForeignFunctionItem
(
ref
func
)
if
func
.header.unsafety
==
hir
::
Unsafety
::
Unsafe
=>
{
...
...
@@ -2582,7 +2582,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
}
for
(
pos
,
m
)
in
provided
.iter
()
.enumerate
()
{
render_assoc_item
(
w
,
m
,
AssocItemLink
::
Anchor
(
None
),
ItemType
::
Trait
);
match
m
.
inner
{
match
m
.
kind
{
clean
::
MethodItem
(
ref
inner
)
if
!
inner
.generics.where_predicates
.is_empty
()
=>
{
write!
(
w
,
",
\n
{{ ... }}
\n
"
);
}
...
...
@@ -2958,7 +2958,7 @@ fn method(
where_clause
=
WhereClause
{
gens
:
g
,
indent
,
end_newline
}
)
}
match
item
.
inner
{
match
item
.
kind
{
clean
::
StrippedItem
(
..
)
=>
{}
clean
::
TyMethodItem
(
ref
m
)
=>
method
(
w
,
item
,
m
.header
,
&
m
.generics
,
&
m
.decl
,
link
,
parent
),
clean
::
MethodItem
(
ref
m
)
=>
method
(
w
,
item
,
m
.header
,
&
m
.generics
,
&
m
.decl
,
link
,
parent
),
...
...
@@ -2994,7 +2994,7 @@ fn item_struct(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Struct
let
mut
fields
=
s
.fields
.iter
()
.filter_map
(|
f
|
match
f
.
inner
{
.filter_map
(|
f
|
match
f
.
kind
{
clean
::
StructFieldItem
(
ref
ty
)
=>
Some
((
f
,
ty
)),
_
=>
None
,
})
...
...
@@ -3044,7 +3044,7 @@ fn item_union(w: &mut Buffer, cx: &Context, it: &clean::Item, s: &clean::Union,
let
mut
fields
=
s
.fields
.iter
()
.filter_map
(|
f
|
match
f
.
inner
{
.filter_map
(|
f
|
match
f
.
kind
{
clean
::
StructFieldItem
(
ref
ty
)
=>
Some
((
f
,
ty
)),
_
=>
None
,
})
...
...
@@ -3097,7 +3097,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
for
v
in
&
e
.variants
{
write!
(
w
,
" "
);
let
name
=
v
.name
.as_ref
()
.unwrap
();
match
v
.
inner
{
match
v
.
kind
{
clean
::
VariantItem
(
ref
var
)
=>
match
var
.kind
{
clean
::
VariantKind
::
CLike
=>
write!
(
w
,
"{}"
,
name
),
clean
::
VariantKind
::
Tuple
(
ref
tys
)
=>
{
...
...
@@ -3147,7 +3147,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
id
=
id
,
name
=
variant
.name
.as_ref
()
.unwrap
()
);
if
let
clean
::
VariantItem
(
ref
var
)
=
variant
.
inner
{
if
let
clean
::
VariantItem
(
ref
var
)
=
variant
.
kind
{
if
let
clean
::
VariantKind
::
Tuple
(
ref
tys
)
=
var
.kind
{
write!
(
w
,
"("
);
for
(
i
,
ty
)
in
tys
.iter
()
.enumerate
()
{
...
...
@@ -3164,8 +3164,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
document_non_exhaustive
(
w
,
variant
);
use
crate
::
clean
::{
Variant
,
VariantKind
};
if
let
clean
::
VariantItem
(
Variant
{
kind
:
VariantKind
::
Struct
(
ref
s
)
})
=
variant
.inner
{
if
let
clean
::
VariantItem
(
Variant
{
kind
:
VariantKind
::
Struct
(
ref
s
)
})
=
variant
.kind
{
let
variant_id
=
cx
.derive_id
(
format!
(
"{}.{}.fields"
,
ItemType
::
Variant
,
...
...
@@ -3179,7 +3178,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum, ca
);
for
field
in
&
s
.fields
{
use
crate
::
clean
::
StructFieldItem
;
if
let
StructFieldItem
(
ref
ty
)
=
field
.
inner
{
if
let
StructFieldItem
(
ref
ty
)
=
field
.
kind
{
let
id
=
cx
.derive_id
(
format!
(
"variant.{}.field.{}"
,
variant
.name
.as_ref
()
.unwrap
(),
...
...
@@ -3275,7 +3274,7 @@ fn render_struct(
let
mut
has_visible_fields
=
false
;
write!
(
w
,
" {{"
);
for
field
in
fields
{
if
let
clean
::
StructFieldItem
(
ref
ty
)
=
field
.
inner
{
if
let
clean
::
StructFieldItem
(
ref
ty
)
=
field
.
kind
{
write!
(
w
,
"
\n
{} {}{}: {},"
,
...
...
@@ -3306,7 +3305,7 @@ fn render_struct(
if
i
>
0
{
write!
(
w
,
", "
);
}
match
field
.
inner
{
match
field
.
kind
{
clean
::
StrippedItem
(
box
clean
::
StructFieldItem
(
..
))
=>
write!
(
w
,
"_"
),
clean
::
StructFieldItem
(
ref
ty
)
=>
{
write!
(
w
,
"{}{}"
,
field
.visibility
.print_with_space
(),
ty
.print
())
...
...
@@ -3352,7 +3351,7 @@ fn render_union(
write!
(
w
,
" {{
\n
{}"
,
tab
);
for
field
in
fields
{
if
let
clean
::
StructFieldItem
(
ref
ty
)
=
field
.
inner
{
if
let
clean
::
StructFieldItem
(
ref
ty
)
=
field
.
kind
{
write!
(
w
,
" {}{}: {},
\n
{}"
,
...
...
@@ -3516,7 +3515,7 @@ fn render_deref_methods(
.inner_impl
()
.items
.iter
()
.find_map
(|
item
|
match
item
.
inner
{
.find_map
(|
item
|
match
item
.
kind
{
clean
::
TypedefItem
(
ref
t
,
true
)
=>
Some
(
match
*
t
{
clean
::
Typedef
{
item_type
:
Some
(
ref
type_
),
..
}
=>
(
type_
,
&
t
.type_
),
_
=>
(
&
t
.type_
,
&
t
.type_
),
...
...
@@ -3538,7 +3537,7 @@ fn render_deref_methods(
}
fn
should_render_item
(
item
:
&
clean
::
Item
,
deref_mut_
:
bool
)
->
bool
{
let
self_type_opt
=
match
item
.
inner
{
let
self_type_opt
=
match
item
.
kind
{
clean
::
MethodItem
(
ref
method
)
=>
method
.decl
.self_type
(),
clean
::
TyMethodItem
(
ref
method
)
=>
method
.decl
.self_type
(),
_
=>
None
,
...
...
@@ -3589,7 +3588,7 @@ fn spotlight_decl(decl: &clean::FnDecl) -> String {
));
let
t_did
=
impl_
.trait_
.def_id
()
.unwrap
();
for
it
in
&
impl_
.items
{
if
let
clean
::
TypedefItem
(
ref
tydef
,
_
)
=
it
.
inner
{
if
let
clean
::
TypedefItem
(
ref
tydef
,
_
)
=
it
.
kind
{
out
.push_str
(
"<span class=
\"
where fmt-newline
\"
> "
);
assoc_type
(
&
mut
out
,
...
...
@@ -3657,7 +3656,7 @@ fn render_impl(
fmt_impl_for_trait_page
(
&
i
.inner_impl
(),
w
,
use_absolute
);
if
show_def_docs
{
for
it
in
&
i
.inner_impl
()
.items
{
if
let
clean
::
TypedefItem
(
ref
tydef
,
_
)
=
it
.
inner
{
if
let
clean
::
TypedefItem
(
ref
tydef
,
_
)
=
it
.
kind
{
write!
(
w
,
"<span class=
\"
where fmt-newline
\"
> "
);
assoc_type
(
w
,
it
,
&
[],
Some
(
&
tydef
.type_
),
AssocItemLink
::
Anchor
(
None
),
""
);
write!
(
w
,
";</span>"
);
...
...
@@ -3728,14 +3727,14 @@ fn doc_impl_item(
};
let
(
is_hidden
,
extra_class
)
=
if
(
trait_
.is_none
()
||
item
.doc_value
()
.is_some
()
||
item
.
inner
.is_type_alias
())
if
(
trait_
.is_none
()
||
item
.doc_value
()
.is_some
()
||
item
.
kind
.is_type_alias
())
&&
!
is_default_item
{
(
false
,
""
)
}
else
{
(
true
,
" hidden"
)
};
match
item
.
inner
{
match
item
.
kind
{
clean
::
MethodItem
(
clean
::
Method
{
..
})
|
clean
::
TyMethodItem
(
clean
::
TyMethod
{
..
})
=>
{
// Only render when the method is not static or we allow static methods
...
...
@@ -4000,7 +3999,7 @@ fn print_sidebar(cx: &Context, it: &clean::Item, buffer: &mut Buffer, cache: &Ca
write!
(
buffer
,
"<p class=
\"
location
\"
>{}{}</p>"
,
match
it
.
inner
{
match
it
.
kind
{
clean
::
StructItem
(
..
)
=>
"Struct "
,
clean
::
TraitItem
(
..
)
=>
"Trait "
,
clean
::
PrimitiveItem
(
..
)
=>
"Primitive Type "
,
...
...
@@ -4040,7 +4039,7 @@ fn print_sidebar(cx: &Context, it: &clean::Item, buffer: &mut Buffer, cache: &Ca
it
.name
.as_ref
()
.expect
(
"crates always have a name"
)
);
}
match
it
.
inner
{
match
it
.
kind
{
clean
::
StructItem
(
ref
s
)
=>
sidebar_struct
(
buffer
,
it
,
s
),
clean
::
TraitItem
(
ref
t
)
=>
sidebar_trait
(
buffer
,
it
,
t
),
clean
::
PrimitiveItem
(
_
)
=>
sidebar_primitive
(
buffer
,
it
),
...
...
@@ -4180,7 +4179,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
.find
(|
i
|
i
.inner_impl
()
.trait_
.def_id
()
==
c
.deref_trait_did
)
{
if
let
Some
((
target
,
real_target
))
=
impl_
.inner_impl
()
.items
.iter
()
.find_map
(|
item
|
match
item
.
inner
{
impl_
.inner_impl
()
.items
.iter
()
.find_map
(|
item
|
match
item
.
kind
{
clean
::
TypedefItem
(
ref
t
,
true
)
=>
Some
(
match
*
t
{
clean
::
Typedef
{
item_type
:
Some
(
ref
type_
),
..
}
=>
(
type_
,
&
t
.type_
),
_
=>
(
&
t
.type_
,
&
t
.type_
),
...
...
@@ -4319,8 +4318,8 @@ fn get_id_for_impl_on_foreign_type(for_: &clean::Type, trait_: &clean::Type) ->
}
fn
extract_for_impl_name
(
item
:
&
clean
::
Item
)
->
Option
<
(
String
,
String
)
>
{
match
item
.
inner
{
clean
::
Item
Enum
::
ImplItem
(
ref
i
)
=>
{
match
item
.
kind
{
clean
::
Item
Kind
::
ImplItem
(
ref
i
)
=>
{
if
let
Some
(
ref
trait_
)
=
i
.trait_
{
Some
((
format!
(
"{:#}"
,
i
.for_
.print
()),
...
...
@@ -4470,7 +4469,7 @@ fn sidebar_typedef(buf: &mut Buffer, it: &clean::Item) {
fn
get_struct_fields_name
(
fields
:
&
[
clean
::
Item
])
->
String
{
let
mut
fields
=
fields
.iter
()
.filter
(|
f
|
if
let
clean
::
StructFieldItem
(
..
)
=
f
.
inner
{
true
}
else
{
false
})
.filter
(|
f
|
if
let
clean
::
StructFieldItem
(
..
)
=
f
.
kind
{
true
}
else
{
false
})
.filter_map
(|
f
|
match
f
.name
{
Some
(
ref
name
)
=>
{
Some
(
format!
(
"<a href=
\"
#structfield.{name}
\"
>{name}</a>"
,
name
=
name
))
...
...
src/librustdoc/passes/calculate_doc_coverage.rs
浏览文件 @
03cbee84
...
...
@@ -187,7 +187,7 @@ fn print_table_record(
impl
<
'a
,
'b
>
fold
::
DocFolder
for
CoverageCalculator
<
'a
,
'b
>
{
fn
fold_item
(
&
mut
self
,
i
:
clean
::
Item
)
->
Option
<
clean
::
Item
>
{
match
i
.
inner
{
match
i
.
kind
{
_
if
!
i
.def_id
.is_local
()
=>
{
// non-local items are skipped because they can be out of the users control,
// especially in the case of trait impls, which rustdoc eagerly inlines
...
...
src/librustdoc/passes/collect_intra_doc_links.rs
浏览文件 @
03cbee84
...
...
@@ -671,7 +671,7 @@ fn resolve_associated_trait_item(
let
implicit_impls
=
crate
::
clean
::
get_auto_trait_and_blanket_impls
(
cx
,
ty
,
did
);
let
mut
candidates
:
Vec
<
_
>
=
implicit_impls
.flat_map
(|
impl_outer
|
{
match
impl_outer
.
inner
{
match
impl_outer
.
kind
{
clean
::
ImplItem
(
impl_
)
=>
{
debug!
(
"considering auto or blanket impl for trait {:?}"
,
impl_
.trait_
);
// Give precedence to methods that were overridden
...
...
@@ -681,14 +681,14 @@ fn resolve_associated_trait_item(
return
None
;
}
let
kind
=
assoc
.
inner
.
kind
.as_assoc_kind
()
.expect
(
"inner items for a trait should be associated items"
);
if
kind
.namespace
()
!=
ns
{
return
None
;
}
trace!
(
"considering associated item {:?}"
,
assoc
.
inner
);
trace!
(
"considering associated item {:?}"
,
assoc
.
kind
);
// We have a slight issue: normal methods come from `clean` types,
// but provided methods come directly from `tcx`.
// Fortunately, we don't need the whole method, we just need to know
...
...
@@ -832,7 +832,7 @@ fn fold_item(&mut self, mut item: Item) -> Option<Item> {
trace!
(
"got parent node for {:?} {:?}, id {:?}"
,
item
.type_
(),
item
.name
,
item
.def_id
);
}
let
current_item
=
match
item
.
inner
{
let
current_item
=
match
item
.
kind
{
clean
::
ModuleItem
(
..
)
=>
{
if
item
.attrs.inner_docs
{
if
item
.def_id
.is_top_level_module
()
{
item
.name
.clone
()
}
else
{
None
}
...
...
src/librustdoc/passes/collect_trait_impls.rs
浏览文件 @
03cbee84
...
...
@@ -55,11 +55,11 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
// scan through included items ahead of time to splice in Deref targets to the "valid" sets
for
it
in
&
new_items
{
if
let
ImplItem
(
Impl
{
ref
for_
,
ref
trait_
,
ref
items
,
..
})
=
it
.
inner
{
if
let
ImplItem
(
Impl
{
ref
for_
,
ref
trait_
,
ref
items
,
..
})
=
it
.
kind
{
if
cleaner
.keep_item
(
for_
)
&&
trait_
.def_id
()
==
cx
.tcx
.lang_items
()
.deref_trait
()
{
let
target
=
items
.iter
()
.find_map
(|
item
|
match
item
.
inner
{
.find_map
(|
item
|
match
item
.
kind
{
TypedefItem
(
ref
t
,
true
)
=>
Some
(
&
t
.type_
),
_
=>
None
,
})
...
...
@@ -75,7 +75,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
}
new_items
.retain
(|
it
|
{
if
let
ImplItem
(
Impl
{
ref
for_
,
ref
trait_
,
ref
blanket_impl
,
..
})
=
it
.
inner
{
if
let
ImplItem
(
Impl
{
ref
for_
,
ref
trait_
,
ref
blanket_impl
,
..
})
=
it
.
kind
{
cleaner
.keep_item
(
for_
)
||
trait_
.as_ref
()
.map_or
(
false
,
|
t
|
cleaner
.keep_item
(
t
))
||
blanket_impl
.is_some
()
...
...
@@ -96,7 +96,7 @@ pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
}
if
let
Some
(
ref
mut
it
)
=
krate
.module
{
if
let
ModuleItem
(
Module
{
ref
mut
items
,
..
})
=
it
.
inner
{
if
let
ModuleItem
(
Module
{
ref
mut
items
,
..
})
=
it
.
kind
{
items
.extend
(
synth
.impls
);
items
.extend
(
new_items
);
}
else
{
...
...
src/librustdoc/passes/doc_test_lints.rs
浏览文件 @
03cbee84
...
...
@@ -58,7 +58,7 @@ fn add_test(&mut self, _: String, config: LangString, _: usize) {
}
pub
fn
should_have_doc_example
(
cx
:
&
DocContext
<
'_
>
,
item
:
&
clean
::
Item
)
->
bool
{
if
matches!
(
item
.
inner
,
if
matches!
(
item
.
kind
,
clean
::
StructFieldItem
(
_
)
|
clean
::
VariantItem
(
_
)
|
clean
::
AssocConstItem
(
_
,
_
)
...
...
src/librustdoc/passes/strip_hidden.rs
浏览文件 @
03cbee84
...
...
@@ -41,7 +41,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
if
i
.attrs
.lists
(
sym
::
doc
)
.has_word
(
sym
::
hidden
)
{
debug!
(
"strip_hidden: stripping {:?} {:?}"
,
i
.type_
(),
i
.name
);
// use a dedicated hidden item for given item type if any
match
i
.
inner
{
match
i
.
kind
{
clean
::
StructFieldItem
(
..
)
|
clean
::
ModuleItem
(
..
)
=>
{
// We need to recurse into stripped modules to
// strip things like impl methods but when doing so
...
...
src/librustdoc/passes/stripper.rs
浏览文件 @
03cbee84
...
...
@@ -13,7 +13,7 @@ pub struct Stripper<'a> {
impl
<
'a
>
DocFolder
for
Stripper
<
'a
>
{
fn
fold_item
(
&
mut
self
,
i
:
Item
)
->
Option
<
Item
>
{
match
i
.
inner
{
match
i
.
kind
{
clean
::
StrippedItem
(
..
)
=>
{
// We need to recurse into stripped modules to strip things
// like impl methods but when doing so we must not add any
...
...
@@ -86,7 +86,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
clean
::
KeywordItem
(
..
)
=>
{}
}
let
fastreturn
=
match
i
.
inner
{
let
fastreturn
=
match
i
.
kind
{
// nothing left to do for traits (don't want to filter their
// methods out, visibility controlled by the trait)
clean
::
TraitItem
(
..
)
=>
true
,
...
...
@@ -123,7 +123,7 @@ pub struct ImplStripper<'a> {
impl
<
'a
>
DocFolder
for
ImplStripper
<
'a
>
{
fn
fold_item
(
&
mut
self
,
i
:
Item
)
->
Option
<
Item
>
{
if
let
clean
::
ImplItem
(
ref
imp
)
=
i
.
inner
{
if
let
clean
::
ImplItem
(
ref
imp
)
=
i
.
kind
{
// emptied none trait impls can be stripped
if
imp
.trait_
.is_none
()
&&
imp
.items
.is_empty
()
{
return
None
;
...
...
@@ -162,7 +162,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
impl
DocFolder
for
ImportStripper
{
fn
fold_item
(
&
mut
self
,
i
:
Item
)
->
Option
<
Item
>
{
match
i
.
inner
{
match
i
.
kind
{
clean
::
ExternCrateItem
(
..
)
|
clean
::
ImportItem
(
..
)
if
i
.visibility
!=
clean
::
Public
=>
{
None
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录