Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
14f32f64
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,发现更多精彩内容 >>
提交
14f32f64
编写于
5月 03, 2018
作者:
S
Shotaro Yamada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustdoc: Resolve nested `impl Trait`s
上级
427c5487
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
39 addition
and
31 deletion
+39
-31
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+32
-31
src/test/rustdoc/universal-impl-trait.rs
src/test/rustdoc/universal-impl-trait.rs
+7
-0
未找到文件。
src/librustdoc/clean/mod.rs
浏览文件 @
14f32f64
...
...
@@ -1755,8 +1755,18 @@ pub struct Generics {
impl
Clean
<
Generics
>
for
hir
::
Generics
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Generics
{
let
mut
params
=
Vec
::
with_capacity
(
self
.params
.len
());
for
p
in
&
self
.params
{
let
p
=
p
.clean
(
cx
);
if
let
GenericParam
::
Type
(
ref
tp
)
=
p
{
if
tp
.synthetic
==
Some
(
hir
::
SyntheticTyParamKind
::
ImplTrait
)
{
cx
.impl_trait_bounds
.borrow_mut
()
.insert
(
tp
.did
,
tp
.bounds
.clone
());
}
}
params
.push
(
p
);
}
let
mut
g
=
Generics
{
params
:
self
.params
.clean
(
cx
)
,
params
,
where_predicates
:
self
.where_clause.predicates
.clean
(
cx
)
};
...
...
@@ -1869,9 +1879,11 @@ pub struct Method {
impl
<
'a
>
Clean
<
Method
>
for
(
&
'a
hir
::
MethodSig
,
&
'a
hir
::
Generics
,
hir
::
BodyId
)
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Method
{
let
generics
=
self
.1
.clean
(
cx
);
let
(
generics
,
decl
)
=
enter_impl_trait
(
cx
,
||
{
(
self
.1
.clean
(
cx
),
(
&*
self
.0
.decl
,
self
.2
)
.clean
(
cx
))
});
Method
{
decl
:
enter_impl_trait
(
cx
,
&
generics
.params
,
||
(
&*
self
.0
.decl
,
self
.2
)
.clean
(
cx
))
,
decl
,
generics
,
unsafety
:
self
.0
.unsafety
,
constness
:
self
.0
.constness
,
...
...
@@ -1899,8 +1911,9 @@ pub struct Function {
impl
Clean
<
Item
>
for
doctree
::
Function
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Item
{
let
generics
=
self
.generics
.clean
(
cx
);
let
decl
=
enter_impl_trait
(
cx
,
&
generics
.params
,
||
(
&
self
.decl
,
self
.body
)
.clean
(
cx
));
let
(
generics
,
decl
)
=
enter_impl_trait
(
cx
,
||
{
(
self
.generics
.clean
(
cx
),
(
&
self
.decl
,
self
.body
)
.clean
(
cx
))
});
Item
{
name
:
Some
(
self
.name
.clean
(
cx
)),
attrs
:
self
.attrs
.clean
(
cx
),
...
...
@@ -2139,12 +2152,12 @@ fn clean(&self, cx: &DocContext) -> Item {
MethodItem
((
sig
,
&
self
.generics
,
body
)
.clean
(
cx
))
}
hir
::
TraitItemKind
::
Method
(
ref
sig
,
hir
::
TraitMethod
::
Required
(
ref
names
))
=>
{
let
generics
=
self
.generics
.clean
(
cx
);
let
(
generics
,
decl
)
=
enter_impl_trait
(
cx
,
||
{
(
self
.generics
.clean
(
cx
),
(
&*
sig
.decl
,
&
names
[
..
])
.clean
(
cx
))
});
TyMethodItem
(
TyMethod
{
unsafety
:
sig
.unsafety
.clone
(),
decl
:
enter_impl_trait
(
cx
,
&
generics
.params
,
||
{
(
&*
sig
.decl
,
&
names
[
..
])
.clean
(
cx
)
}),
decl
,
generics
,
abi
:
sig
.abi
})
...
...
@@ -3415,12 +3428,12 @@ pub struct BareFunctionDecl {
impl
Clean
<
BareFunctionDecl
>
for
hir
::
BareFnTy
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
BareFunctionDecl
{
let
generic_params
=
self
.generic_params
.clean
(
cx
);
let
(
generic_params
,
decl
)
=
enter_impl_trait
(
cx
,
||
{
(
self
.generic_params
.clean
(
cx
),
(
&*
self
.decl
,
&
self
.arg_names
[
..
])
.clean
(
cx
))
});
BareFunctionDecl
{
unsafety
:
self
.unsafety
,
decl
:
enter_impl_trait
(
cx
,
&
generic_params
,
||
{
(
&*
self
.decl
,
&
self
.arg_names
[
..
])
.clean
(
cx
)
}),
decl
,
generic_params
,
abi
:
self
.abi
,
}
...
...
@@ -3722,11 +3735,11 @@ impl Clean<Item> for hir::ForeignItem {
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Item
{
let
inner
=
match
self
.node
{
hir
::
ForeignItemFn
(
ref
decl
,
ref
names
,
ref
generics
)
=>
{
let
generics
=
generics
.clean
(
cx
);
let
(
generics
,
decl
)
=
enter_impl_trait
(
cx
,
||
{
(
generics
.clean
(
cx
),
(
&**
decl
,
&
names
[
..
])
.clean
(
cx
))
});
ForeignFunctionItem
(
Function
{
decl
:
enter_impl_trait
(
cx
,
&
generics
.params
,
||
{
(
&**
decl
,
&
names
[
..
])
.clean
(
cx
)
}),
decl
,
generics
,
unsafety
:
hir
::
Unsafety
::
Unsafe
,
abi
:
Abi
::
Rust
,
...
...
@@ -4030,23 +4043,11 @@ pub fn def_id_to_path(cx: &DocContext, did: DefId, name: Option<String>) -> Vec<
once
(
crate_name
)
.chain
(
relative
)
.collect
()
}
pub
fn
enter_impl_trait
<
F
,
R
>
(
cx
:
&
DocContext
,
gps
:
&
[
GenericParam
],
f
:
F
)
->
R
pub
fn
enter_impl_trait
<
F
,
R
>
(
cx
:
&
DocContext
,
f
:
F
)
->
R
where
F
:
FnOnce
()
->
R
,
{
let
bounds
=
gps
.iter
()
.filter_map
(|
p
|
{
if
let
GenericParam
::
Type
(
ref
tp
)
=
*
p
{
if
tp
.synthetic
==
Some
(
hir
::
SyntheticTyParamKind
::
ImplTrait
)
{
return
Some
((
tp
.did
,
tp
.bounds
.clone
()));
}
}
None
})
.collect
::
<
FxHashMap
<
DefId
,
Vec
<
TyParamBound
>>>
();
let
old_bounds
=
mem
::
replace
(
&
mut
*
cx
.impl_trait_bounds
.borrow_mut
(),
bounds
);
let
old_bounds
=
mem
::
replace
(
&
mut
*
cx
.impl_trait_bounds
.borrow_mut
(),
Default
::
default
());
let
r
=
f
();
assert
!
(
cx
.impl_trait_bounds
.borrow
()
.is_empty
());
*
cx
.impl_trait_bounds
.borrow_mut
()
=
old_bounds
;
...
...
src/test/rustdoc/universal-impl-trait.rs
浏览文件 @
14f32f64
...
...
@@ -11,6 +11,8 @@
#![feature(universal_impl_trait)]
#![crate_name
=
"foo"
]
use
std
::
io
::
Read
;
// @has foo/fn.foo.html
// @has - //pre 'foo('
// @matches - '_x: impl <a class="trait" href="[^"]+/trait\.Clone\.html"'
...
...
@@ -39,6 +41,11 @@ pub fn bar(_bar: impl Copy) {
// @matches - '_baz:.+struct\.S\.html.+impl .+trait\.Clone\.html'
pub
fn
baz
(
_
baz
:
S
<
impl
Clone
>
)
{
}
// @has - 'qux</a>('
// @matches - 'trait\.Read\.html'
pub
fn
qux
(
_
qux
:
impl
IntoIterator
<
Item
=
S
<
impl
Read
>>
)
{
}
}
// @has - 'method</a>('
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录