Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9ba92972
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
9ba92972
编写于
3月 24, 2021
作者:
N
Nixon Enraght-Moony
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't call `item` on modules for json renderer
Closes #80664
上级
ce21447c
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
64 addition
and
3 deletion
+64
-3
src/librustdoc/formats/renderer.rs
src/librustdoc/formats/renderer.rs
+6
-1
src/librustdoc/html/render/context.rs
src/librustdoc/html/render/context.rs
+2
-0
src/librustdoc/json/conversions.rs
src/librustdoc/json/conversions.rs
+2
-1
src/librustdoc/json/mod.rs
src/librustdoc/json/mod.rs
+5
-1
src/test/rustdoc-json/reexport/in_root_and_mod.rs
src/test/rustdoc-json/reexport/in_root_and_mod.rs
+15
-0
src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs
src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs
+20
-0
src/test/rustdoc-json/reexport/rename_private.rs
src/test/rustdoc-json/reexport/rename_private.rs
+14
-0
未找到文件。
src/librustdoc/formats/renderer.rs
浏览文件 @
9ba92972
...
...
@@ -13,6 +13,11 @@
/// Gives a description of the renderer. Used for performance profiling.
fn
descr
()
->
&
'static
str
;
/// Whether to call `item` recursivly for modules
///
/// This is true for html, and false for json. See #80664
const
RUN_ON_MODULE
:
bool
;
/// Sets up any state required for the renderer. When this is called the cache has already been
/// populated.
fn
init
(
...
...
@@ -68,7 +73,7 @@ fn after_krate(
let
unknown
=
Symbol
::
intern
(
"<unknown item>"
);
while
let
Some
((
mut
cx
,
item
))
=
work
.pop
()
{
if
item
.is_mod
()
{
if
item
.is_mod
()
&&
T
::
RUN_ON_MODULE
{
// modules are special because they add a namespace. We also need to
// recurse into the items of the module as well.
let
name
=
item
.name
.as_ref
()
.unwrap
()
.to_string
();
...
...
src/librustdoc/html/render/context.rs
浏览文件 @
9ba92972
...
...
@@ -290,6 +290,8 @@ fn descr() -> &'static str {
"html"
}
const
RUN_ON_MODULE
:
bool
=
true
;
fn
init
(
mut
krate
:
clean
::
Crate
,
options
:
RenderOptions
,
...
...
src/librustdoc/json/conversions.rs
浏览文件 @
9ba92972
...
...
@@ -179,7 +179,8 @@ fn from_clean_item_kind(item: clean::ItemKind, tcx: TyCtxt<'_>, name: &Option<Sy
bounds
:
g
.into_iter
()
.map
(
Into
::
into
)
.collect
(),
default
:
t
.map
(
Into
::
into
),
},
StrippedItem
(
inner
)
=>
from_clean_item_kind
(
*
inner
,
tcx
,
name
),
// `convert_item` early returns `None` for striped items
StrippedItem
(
_
)
=>
unreachable!
(),
PrimitiveItem
(
_
)
|
KeywordItem
(
_
)
=>
{
panic!
(
"{:?} is not supported for JSON output"
,
item
)
}
...
...
src/librustdoc/json/mod.rs
浏览文件 @
9ba92972
...
...
@@ -129,6 +129,8 @@ fn descr() -> &'static str {
"json"
}
const
RUN_ON_MODULE
:
bool
=
false
;
fn
init
(
krate
:
clean
::
Crate
,
options
:
RenderOptions
,
...
...
@@ -169,8 +171,10 @@ fn item(&mut self, item: clean::Item) -> Result<(), Error> {
e
.impls
=
self
.get_impls
(
id
)
}
let
removed
=
self
.index
.borrow_mut
()
.insert
(
from_def_id
(
id
),
new_item
.clone
());
// FIXME(adotinthevoid): Currently, the index is duplicated. This is a sanity check
// to make sure the items are unique.
// to make sure the items are unique. The main place this happens is when an item, is
// reexported in more than one place. See `rustdoc-json/reexport/in_root_and_mod`
if
let
Some
(
old_item
)
=
removed
{
assert_eq!
(
old_item
,
new_item
);
}
...
...
src/test/rustdoc-json/reexport/in_root_and_mod.rs
0 → 100644
浏览文件 @
9ba92972
#![feature(no_core)]
#![no_core]
mod
foo
{
// @set foo_id = in_root_and_mod.json "$.index[*][?(@.name=='Foo')].id"
pub
struct
Foo
;
}
// @has - "$.index[*][?(@.name=='in_root_and_mod')].inner.items[*]" $foo_id
pub
use
foo
::
Foo
;
pub
mod
bar
{
// @has - "$.index[*][?(@.name=='bar')].inner.items[*]" $foo_id
pub
use
crate
::
foo
::
Foo
;
}
src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs
0 → 100644
浏览文件 @
9ba92972
#![feature(no_core)]
#![no_core]
pub
mod
foo
{
// @set bar_id = in_root_and_mod_pub.json "$.index[*][?(@.name=='Bar')].id"
// @has - "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id
pub
struct
Bar
;
}
// @set root_import_id = - "$.index[*][?(@.inner.span=='foo::Bar')].id"
// @is - "$.index[*][?(@.inner.span=='foo::Bar')].inner.id" $bar_id
// @has - "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id
pub
use
foo
::
Bar
;
pub
mod
baz
{
// @set baz_import_id = - "$.index[*][?(@.inner.span=='crate::foo::Bar')].id"
// @is - "$.index[*][?(@.inner.span=='crate::foo::Bar')].inner.id" $bar_id
// @has - "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id
pub
use
crate
::
foo
::
Bar
;
}
src/test/rustdoc-json/reexport/rename_private.rs
0 → 100644
浏览文件 @
9ba92972
// edition:2018
#![no_core]
#![feature(no_core)]
// @!has rename_private.json "$.index[*][?(@.name=='inner')]"
mod
inner
{
// @!has - "$.index[*][?(@.name=='Public')]"
pub
struct
Public
;
}
// @set newname_id = - "$.index[*][?(@.name=='NewName')].id"
// @is - "$.index[*][?(@.name=='NewName')].kind" \"struct\"
// @has - "$.index[*][?(@.name=='rename_private')].inner.items[*]" $newname_id
pub
use
inner
::
Public
as
NewName
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录