Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
0df39bff
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,发现更多精彩内容 >>
提交
0df39bff
编写于
12月 17, 2017
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix ?Sized where bound not being displayed at the correct place
上级
bdae6184
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
5 deletion
+41
-5
src/librustdoc/clean/inline.rs
src/librustdoc/clean/inline.rs
+1
-2
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+23
-3
src/librustdoc/clean/simplify.rs
src/librustdoc/clean/simplify.rs
+1
-0
src/test/rustdoc/where-sized.rs
src/test/rustdoc/where-sized.rs
+16
-0
未找到文件。
src/librustdoc/clean/inline.rs
浏览文件 @
0df39bff
...
...
@@ -448,8 +448,7 @@ fn build_static(cx: &DocContext, did: DefId, mutable: bool) -> clean::Static {
///
/// The inverse of this filtering logic can be found in the `Clean`
/// implementation for `AssociatedType`
fn
filter_non_trait_generics
(
trait_did
:
DefId
,
mut
g
:
clean
::
Generics
)
->
clean
::
Generics
{
fn
filter_non_trait_generics
(
trait_did
:
DefId
,
mut
g
:
clean
::
Generics
)
->
clean
::
Generics
{
for
pred
in
&
mut
g
.where_predicates
{
match
*
pred
{
clean
::
WherePredicate
::
BoundPredicate
{
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
0df39bff
...
...
@@ -1190,16 +1190,36 @@ fn clean(&self, cx: &DocContext) -> Type {
pub
struct
Generics
{
pub
lifetimes
:
Vec
<
Lifetime
>
,
pub
type_params
:
Vec
<
TyParam
>
,
pub
where_predicates
:
Vec
<
WherePredicate
>
pub
where_predicates
:
Vec
<
WherePredicate
>
,
}
impl
Clean
<
Generics
>
for
hir
::
Generics
{
fn
clean
(
&
self
,
cx
:
&
DocContext
)
->
Generics
{
Generics
{
let
mut
g
=
Generics
{
lifetimes
:
self
.lifetimes
.clean
(
cx
),
type_params
:
self
.ty_params
.clean
(
cx
),
where_predicates
:
self
.where_clause.predicates
.clean
(
cx
)
};
// Some duplicates are generated for ?Sized bounds between type params and where
// predicates. The point in here is to move the bounds definitions from type params
// to where predicates when such cases occur.
for
where_pred
in
&
mut
g
.where_predicates
{
match
*
where_pred
{
WherePredicate
::
BoundPredicate
{
ty
:
Generic
(
ref
name
),
ref
mut
bounds
}
=>
{
if
bounds
.is_empty
()
{
for
type_params
in
&
mut
g
.type_params
{
if
&
type_params
.name
==
name
{
mem
::
swap
(
bounds
,
&
mut
type_params
.bounds
);
break
}
}
}
}
_
=>
continue
,
}
}
g
}
}
...
...
@@ -1225,7 +1245,7 @@ fn clean(&self, cx: &DocContext) -> Generics {
let
mut
where_predicates
=
preds
.predicates
.to_vec
()
.clean
(
cx
);
// Type parameters and have a Sized bound by default unless removed with
// ?Sized.
Scan through the predicates and mark any type parameter with
// ?Sized. Scan through the predicates and mark any type parameter with
// a Sized bound, removing the bounds as we find them.
//
// Note that associated types also have a sized bound by default, but we
...
...
src/librustdoc/clean/simplify.rs
浏览文件 @
0df39bff
...
...
@@ -38,6 +38,7 @@ pub fn where_clauses(cx: &DocContext, clauses: Vec<WP>) -> Vec<WP> {
let
mut
lifetimes
=
Vec
::
new
();
let
mut
equalities
=
Vec
::
new
();
let
mut
tybounds
=
Vec
::
new
();
for
clause
in
clauses
{
match
clause
{
WP
::
BoundPredicate
{
ty
,
bounds
}
=>
{
...
...
src/test/rustdoc/where-sized.rs
0 → 100644
浏览文件 @
0df39bff
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name
=
"foo"
]
// @has foo/fn.foo.html
// @has - '//*[@class="rust fn"]' 'pub fn foo<X, Y: ?Sized>(_: &X)'
// @has - '//*[@class="rust fn"]' 'where X: ?Sized,'
pub
fn
foo
<
X
,
Y
:
?
Sized
>
(
_
:
&
X
)
where
X
:
?
Sized
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录