Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b90bc8d7
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,发现更多精彩内容 >>
提交
b90bc8d7
编写于
7月 31, 2020
作者:
B
Bastian Kauschke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix rustdoc generic param order
上级
1799d318
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
30 deletion
+15
-30
src/librustdoc/clean/auto_trait.rs
src/librustdoc/clean/auto_trait.rs
+5
-0
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+8
-15
src/librustdoc/clean/simplify.rs
src/librustdoc/clean/simplify.rs
+0
-13
src/test/rustdoc/const-generics/const-impl.rs
src/test/rustdoc/const-generics/const-impl.rs
+2
-2
未找到文件。
src/librustdoc/clean/auto_trait.rs
浏览文件 @
b90bc8d7
...
...
@@ -480,6 +480,11 @@ fn param_env_to_generics(
.clean
(
self
.cx
)
.params
;
debug!
(
"param_env_to_generics({:?}): generic_params={:?}"
,
param_env_def_id
,
generic_params
);
let
mut
has_sized
=
FxHashSet
::
default
();
let
mut
ty_to_bounds
:
FxHashMap
<
_
,
FxHashSet
<
_
>>
=
Default
::
default
();
let
mut
lifetime_to_bounds
:
FxHashMap
<
_
,
FxHashSet
<
_
>>
=
Default
::
default
();
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
b90bc8d7
...
...
@@ -716,11 +716,11 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
// Bounds in the type_params and lifetimes fields are repeated in the
// predicates field (see rustc_typeck::collect::ty_generics), so remove
// them.
let
stripped_
ty
params
=
gens
let
stripped_params
=
gens
.params
.iter
()
.filter_map
(|
param
|
match
param
.kind
{
ty
::
GenericParamDefKind
::
Lifetime
=>
None
,
ty
::
GenericParamDefKind
::
Lifetime
=>
Some
(
param
.clean
(
cx
))
,
ty
::
GenericParamDefKind
::
Type
{
synthetic
,
..
}
=>
{
if
param
.name
==
kw
::
SelfUpper
{
assert_eq!
(
param
.index
,
0
);
...
...
@@ -732,7 +732,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
}
Some
(
param
.clean
(
cx
))
}
ty
::
GenericParamDefKind
::
Const
{
..
}
=>
None
,
ty
::
GenericParamDefKind
::
Const
{
..
}
=>
Some
(
param
.clean
(
cx
))
,
})
.collect
::
<
Vec
<
GenericParamDef
>>
();
...
...
@@ -844,8 +844,10 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
// Run through the type parameters again and insert a ?Sized
// unbound for any we didn't find to be Sized.
for
tp
in
&
stripped_typarams
{
if
!
sized_params
.contains
(
&
tp
.name
)
{
for
tp
in
&
stripped_params
{
if
matches!
(
tp
.kind
,
types
::
GenericParamDefKind
::
Type
{
..
})
&&
!
sized_params
.contains
(
&
tp
.name
)
{
where_predicates
.push
(
WP
::
BoundPredicate
{
ty
:
Type
::
Generic
(
tp
.name
.clone
()),
bounds
:
vec!
[
GenericBound
::
maybe_sized
(
cx
)],
...
...
@@ -858,16 +860,7 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
// and instead see `where T: Foo + Bar + Sized + 'a`
Generics
{
params
:
gens
.params
.iter
()
.flat_map
(|
param
|
match
param
.kind
{
ty
::
GenericParamDefKind
::
Lifetime
=>
Some
(
param
.clean
(
cx
)),
ty
::
GenericParamDefKind
::
Type
{
..
}
=>
None
,
ty
::
GenericParamDefKind
::
Const
{
..
}
=>
Some
(
param
.clean
(
cx
)),
})
.chain
(
simplify
::
ty_params
(
stripped_typarams
)
.into_iter
())
.collect
(),
params
:
stripped_params
,
where_predicates
:
simplify
::
where_clauses
(
cx
,
where_predicates
),
}
}
...
...
src/librustdoc/clean/simplify.rs
浏览文件 @
b90bc8d7
...
...
@@ -12,7 +12,6 @@
//! bounds by special casing scenarios such as these. Fun!
use
std
::
collections
::
BTreeMap
;
use
std
::
mem
;
use
rustc_hir
::
def_id
::
DefId
;
use
rustc_middle
::
ty
;
...
...
@@ -118,18 +117,6 @@ pub fn merge_bounds(
})
}
pub
fn
ty_params
(
mut
params
:
Vec
<
clean
::
GenericParamDef
>
)
->
Vec
<
clean
::
GenericParamDef
>
{
for
param
in
&
mut
params
{
match
param
.kind
{
clean
::
GenericParamDefKind
::
Type
{
ref
mut
bounds
,
..
}
=>
{
*
bounds
=
mem
::
take
(
bounds
);
}
_
=>
panic!
(
"expected only type parameters"
),
}
}
params
}
fn
trait_is_same_or_supertrait
(
cx
:
&
DocContext
<
'_
>
,
child
:
DefId
,
trait_
:
DefId
)
->
bool
{
if
child
==
trait_
{
return
true
;
...
...
src/test/rustdoc/const-generics/const-impl.rs
浏览文件 @
b90bc8d7
...
...
@@ -11,8 +11,8 @@ pub enum Order {
}
// @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet<T, const ORDER: Order>'
// @has foo/struct.VSet.html '//h3[@id="impl-Send"]/code' 'impl<
const ORDER: Order, T
> Send for VSet<T, ORDER>'
// @has foo/struct.VSet.html '//h3[@id="impl-Sync"]/code' 'impl<
const ORDER: Order, T
> Sync for VSet<T, ORDER>'
// @has foo/struct.VSet.html '//h3[@id="impl-Send"]/code' 'impl<
T, const ORDER: Order
> Send for VSet<T, ORDER>'
// @has foo/struct.VSet.html '//h3[@id="impl-Sync"]/code' 'impl<
T, const ORDER: Order
> Sync for VSet<T, ORDER>'
pub
struct
VSet
<
T
,
const
ORDER
:
Order
>
{
inner
:
Vec
<
T
>
,
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录