Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6ae73e2f
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,发现更多精彩内容 >>
提交
6ae73e2f
编写于
3月 07, 2019
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve bounds search
上级
d611301e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
52 deletion
+11
-52
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+6
-48
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+5
-4
未找到文件。
src/librustdoc/clean/mod.rs
浏览文件 @
6ae73e2f
...
@@ -1755,35 +1755,24 @@ pub fn get_real_types(
...
@@ -1755,35 +1755,24 @@ pub fn get_real_types(
generics
:
&
Generics
,
generics
:
&
Generics
,
arg
:
&
Type
,
arg
:
&
Type
,
cx
:
&
DocContext
<
'_
,
'_
,
'_
>
,
cx
:
&
DocContext
<
'_
,
'_
,
'_
>
,
debug
:
bool
,
)
->
Option
<
Vec
<
Type
>>
{
)
->
Option
<
Vec
<
Type
>>
{
let
mut
res
=
Vec
::
new
();
let
mut
res
=
Vec
::
new
();
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"0. {:?}"
,
arg
);
}
if
let
Some
(
where_pred
)
=
generics
.where_predicates
.iter
()
.find
(|
g
|
{
if
let
Some
(
where_pred
)
=
generics
.where_predicates
.iter
()
.find
(|
g
|
{
match
g
{
match
g
{
&
WherePredicate
::
BoundPredicate
{
ref
ty
,
..
}
=>
ty
.def_id
()
==
arg
.def_id
(),
&
WherePredicate
::
BoundPredicate
{
ref
ty
,
..
}
=>
ty
.def_id
()
==
arg
.def_id
(),
_
=>
false
,
_
=>
false
,
}
}
})
{
})
{
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"1. {:?} => {:?}"
,
arg
,
where_pred
);
}
let
bounds
=
where_pred
.get_bounds
()
.unwrap_or_else
(||
&
[]);
let
bounds
=
where_pred
.get_bounds
()
.unwrap_or_else
(||
&
[]);
for
bound
in
bounds
.iter
()
{
for
bound
in
bounds
.iter
()
{
match
*
bound
{
match
*
bound
{
GenericBound
::
TraitBound
(
ref
poly_trait
,
_
)
=>
{
GenericBound
::
TraitBound
(
ref
poly_trait
,
_
)
=>
{
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
" {:?}"
,
poly_trait
.trait_
);
}
for
x
in
poly_trait
.generic_params
.iter
()
{
for
x
in
poly_trait
.generic_params
.iter
()
{
if
!
x
.is_type
()
{
if
!
x
.is_type
()
{
continue
continue
}
}
if
let
Some
(
ty
)
=
x
.get_type
(
cx
)
{
if
let
Some
(
ty
)
=
x
.get_type
(
cx
)
{
if
let
Some
(
mut
adds
)
=
get_real_types
(
generics
,
&
ty
,
cx
,
if
let
Some
(
mut
adds
)
=
get_real_types
(
generics
,
&
ty
,
cx
)
{
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
)
{
res
.append
(
&
mut
adds
);
res
.append
(
&
mut
adds
);
}
else
if
!
ty
.is_full_generic
()
{
}
else
if
!
ty
.is_full_generic
()
{
res
.push
(
ty
);
res
.push
(
ty
);
...
@@ -1799,51 +1788,25 @@ pub fn get_real_types(
...
@@ -1799,51 +1788,25 @@ pub fn get_real_types(
if
let
Some
(
bound
)
=
generics
.params
.iter
()
.find
(|
g
|
{
if
let
Some
(
bound
)
=
generics
.params
.iter
()
.find
(|
g
|
{
g
.is_type
()
&&
g
.name
==
arg_s
g
.is_type
()
&&
g
.name
==
arg_s
})
{
})
{
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"2. {:?} => {:?}"
,
arg
,
bound
);
}
for
bound
in
bound
.get_bounds
()
.unwrap_or_else
(||
&
[])
{
for
bound
in
bound
.get_bounds
()
.unwrap_or_else
(||
&
[])
{
if
let
Some
(
ty
)
=
bound
.get_trait_type
()
{
if
let
Some
(
ty
)
=
bound
.get_trait_type
()
{
if
let
Some
(
mut
adds
)
=
get_real_types
(
generics
,
&
ty
,
cx
,
if
let
Some
(
mut
adds
)
=
get_real_types
(
generics
,
&
ty
,
cx
)
{
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
)
{
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"3. {:?}"
,
adds
);
}
res
.append
(
&
mut
adds
);
res
.append
(
&
mut
adds
);
}
else
{
}
else
{
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"4. {:?}"
,
ty
);
}
if
!
ty
.is_full_generic
()
{
if
!
ty
.is_full_generic
()
{
res
.push
(
ty
.clone
());
res
.push
(
ty
.clone
());
}
}
}
}
}
}
}
}
/*if let Some(ty) = bound.get_type(cx) {
if let Some(mut adds) = get_real_types(generics, &ty, cx, level + 1) {
res.append(&mut adds);
} else {
res.push(ty);
}
} else {
res.push(arg.clone());
}*/
}
else
if
let
Some
(
gens
)
=
arg
.generics
()
{
}
else
if
let
Some
(
gens
)
=
arg
.generics
()
{
res
.push
(
arg
.clone
());
res
.push
(
arg
.clone
());
for
gen
in
gens
.iter
()
{
for
gen
in
gens
.iter
()
{
if
gen
.is_full_generic
()
{
if
gen
.is_full_generic
()
{
if
let
Some
(
mut
adds
)
=
get_real_types
(
generics
,
gen
,
cx
,
if
let
Some
(
mut
adds
)
=
get_real_types
(
generics
,
gen
,
cx
)
{
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
)
{
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"5. {:?}"
,
adds
);
}
res
.append
(
&
mut
adds
);
res
.append
(
&
mut
adds
);
}
}
}
else
{
}
else
{
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"6. {:?}"
,
gen
);
}
res
.push
(
gen
.clone
());
res
.push
(
gen
.clone
());
}
}
}
}
...
@@ -1852,9 +1815,6 @@ pub fn get_real_types(
...
@@ -1852,9 +1815,6 @@ pub fn get_real_types(
if
res
.is_empty
()
&&
!
arg
.is_full_generic
()
{
if
res
.is_empty
()
&&
!
arg
.is_full_generic
()
{
res
.push
(
arg
.clone
());
res
.push
(
arg
.clone
());
}
}
if
arg
.to_string
()
==
"W"
||
arg
.to_string
()
==
"Z"
||
debug
{
println!
(
"7. /!
\\
{:?}"
,
res
);
}
Some
(
res
)
Some
(
res
)
}
}
...
@@ -1868,17 +1828,15 @@ pub fn get_all_types(
...
@@ -1868,17 +1828,15 @@ pub fn get_all_types(
if
arg
.type_
.is_self_type
()
{
if
arg
.type_
.is_self_type
()
{
continue
;
continue
;
}
}
if
let
Some
(
mut
args
)
=
get_real_types
(
generics
,
&
arg
.type_
,
cx
,
false
)
{
if
let
Some
(
mut
args
)
=
get_real_types
(
generics
,
&
arg
.type_
,
cx
)
{
all_types
.append
(
&
mut
args
);
all_types
.append
(
&
mut
args
);
}
else
{
}
else
{
all_types
.push
(
arg
.type_
.clone
());
all_types
.push
(
arg
.type_
.clone
());
}
}
}
}
all_types
.sort_unstable_by
(|
a
,
b
|
a
.to_string
()
.partial_cmp
(
&
b
.to_string
())
.expect
(
"a"
)
);
// FIXME: use a HashSet instead?
all_types
.sort_unstable_by
(|
a
,
b
|
a
.to_string
()
.partial_cmp
(
&
b
.to_string
())
.unwrap
());
all_types
.dedup
();
all_types
.dedup
();
if
decl
.inputs.values
.iter
()
.any
(|
s
|
s
.type_
.to_string
()
==
"W"
||
s
.type_
.to_string
()
==
"Z"
)
{
println!
(
"||||> {:?}"
,
all_types
);
}
all_types
all_types
}
}
...
...
src/librustdoc/html/render.rs
浏览文件 @
6ae73e2f
...
@@ -5029,16 +5029,17 @@ fn get_index_search_type(item: &clean::Item) -> Option<IndexItemFunctionType> {
...
@@ -5029,16 +5029,17 @@ fn get_index_search_type(item: &clean::Item) -> Option<IndexItemFunctionType> {
clean
::
FunctionItem
(
ref
f
)
=>
(
&
f
.decl
,
&
f
.all_types
),
clean
::
FunctionItem
(
ref
f
)
=>
(
&
f
.decl
,
&
f
.all_types
),
clean
::
MethodItem
(
ref
m
)
=>
(
&
m
.decl
,
&
m
.all_types
),
clean
::
MethodItem
(
ref
m
)
=>
(
&
m
.decl
,
&
m
.all_types
),
clean
::
TyMethodItem
(
ref
m
)
=>
(
&
m
.decl
,
&
m
.all_types
),
clean
::
TyMethodItem
(
ref
m
)
=>
(
&
m
.decl
,
&
m
.all_types
),
_
=>
return
None
_
=>
return
None
,
};
};
println!
(
"====> {:?}"
,
all_types
);
let
inputs
=
all_types
.iter
()
.map
(|
arg
|
{
let
inputs
=
all_types
.iter
()
.map
(|
arg
|
{
get_index_type
(
&
arg
)
get_index_type
(
&
arg
)
})
.collect
();
})
.collect
();
let
output
=
match
decl
.output
{
let
output
=
match
decl
.output
{
clean
::
FunctionRetTy
::
Return
(
ref
return_type
)
=>
Some
(
get_index_type
(
return_type
)),
clean
::
FunctionRetTy
::
Return
(
ref
return_type
)
=>
{
_
=>
None
Some
(
get_index_type
(
return_type
))
},
_
=>
None
,
};
};
Some
(
IndexItemFunctionType
{
inputs
:
inputs
,
output
:
output
})
Some
(
IndexItemFunctionType
{
inputs
:
inputs
,
output
:
output
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录