Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
06d6d3df
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,发现更多精彩内容 >>
提交
06d6d3df
编写于
8月 17, 2020
作者:
J
Joshua Nelson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
impl_for_type -> PrimitiveType::impls
上级
3ddd8b23
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
57 deletion
+59
-57
src/librustdoc/clean/types.rs
src/librustdoc/clean/types.rs
+57
-0
src/librustdoc/clean/utils.rs
src/librustdoc/clean/utils.rs
+2
-57
未找到文件。
src/librustdoc/clean/types.rs
浏览文件 @
06d6d3df
...
...
@@ -19,12 +19,14 @@
use
rustc_hir
::
Mutability
;
use
rustc_index
::
vec
::
IndexVec
;
use
rustc_middle
::
middle
::
stability
;
use
rustc_middle
::
ty
::
TyCtxt
;
use
rustc_span
::
hygiene
::
MacroKind
;
use
rustc_span
::
source_map
::
DUMMY_SP
;
use
rustc_span
::
symbol
::{
kw
,
sym
,
Ident
,
Symbol
};
use
rustc_span
::{
self
,
FileName
};
use
rustc_target
::
abi
::
VariantIdx
;
use
rustc_target
::
spec
::
abi
::
Abi
;
use
smallvec
::
SmallVec
;
use
crate
::
clean
::
cfg
::
Cfg
;
use
crate
::
clean
::
external_path
;
...
...
@@ -1264,6 +1266,61 @@ pub fn as_str(&self) -> &'static str {
}
}
pub
fn
impls
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
SmallVec
<
[
DefId
;
4
]
>
{
use
self
::
PrimitiveType
::
*
;
let
both
=
|
a
:
Option
<
DefId
>
,
b
:
Option
<
DefId
>
|
->
SmallVec
<
_
>
{
a
.into_iter
()
.chain
(
b
)
.collect
()
};
let
lang_items
=
tcx
.lang_items
();
let
primary_impl
=
match
self
{
Isize
=>
lang_items
.isize_impl
(),
I8
=>
lang_items
.i8_impl
(),
I16
=>
lang_items
.i16_impl
(),
I32
=>
lang_items
.i32_impl
(),
I64
=>
lang_items
.i64_impl
(),
I128
=>
lang_items
.i128_impl
(),
Usize
=>
lang_items
.usize_impl
(),
U8
=>
lang_items
.u8_impl
(),
U16
=>
lang_items
.u16_impl
(),
U32
=>
lang_items
.u32_impl
(),
U64
=>
lang_items
.u64_impl
(),
U128
=>
lang_items
.u128_impl
(),
F32
=>
return
both
(
lang_items
.f32_impl
(),
lang_items
.f32_runtime_impl
()),
F64
=>
return
both
(
lang_items
.f64_impl
(),
lang_items
.f64_runtime_impl
()),
Char
=>
lang_items
.char_impl
(),
Bool
=>
lang_items
.bool_impl
(),
Str
=>
return
both
(
lang_items
.str_impl
(),
lang_items
.str_alloc_impl
()),
Slice
=>
{
return
lang_items
.slice_impl
()
.into_iter
()
.chain
(
lang_items
.slice_u8_impl
())
.chain
(
lang_items
.slice_alloc_impl
())
.chain
(
lang_items
.slice_u8_alloc_impl
())
.collect
();
}
Array
=>
lang_items
.array_impl
(),
Tuple
=>
None
,
Unit
=>
None
,
RawPointer
=>
{
return
lang_items
.const_ptr_impl
()
.into_iter
()
.chain
(
lang_items
.mut_ptr_impl
())
.chain
(
lang_items
.const_slice_ptr_impl
())
.chain
(
lang_items
.mut_slice_ptr_impl
())
.collect
();
}
Reference
=>
None
,
Fn
=>
None
,
Never
=>
None
,
};
primary_impl
.into_iter
()
.collect
()
}
pub
fn
to_url_str
(
&
self
)
->
&
'static
str
{
self
.as_str
()
}
...
...
src/librustdoc/clean/utils.rs
浏览文件 @
06d6d3df
...
...
@@ -15,9 +15,8 @@
use
rustc_hir
::
def_id
::{
DefId
,
LOCAL_CRATE
};
use
rustc_middle
::
mir
::
interpret
::{
sign_extend
,
ConstValue
,
Scalar
};
use
rustc_middle
::
ty
::
subst
::{
GenericArgKind
,
SubstsRef
};
use
rustc_middle
::
ty
::{
self
,
DefIdTree
,
Ty
,
TyCtxt
};
use
rustc_middle
::
ty
::{
self
,
DefIdTree
,
Ty
};
use
rustc_span
::
symbol
::{
kw
,
sym
,
Symbol
};
use
smallvec
::
SmallVec
;
use
std
::
mem
;
pub
fn
krate
(
mut
cx
:
&
mut
DocContext
<
'_
>
)
->
Crate
{
...
...
@@ -351,60 +350,6 @@ pub fn qpath_to_string(p: &hir::QPath<'_>) -> String {
s
}
pub
fn
impl_for_type
(
tcx
:
TyCtxt
<
'_
>
,
primitive
:
PrimitiveType
)
->
SmallVec
<
[
DefId
;
4
]
>
{
use
self
::
PrimitiveType
::
*
;
let
both
=
|
a
:
Option
<
DefId
>
,
b
:
Option
<
DefId
>
|
->
SmallVec
<
_
>
{
a
.into_iter
()
.chain
(
b
)
.collect
()
};
let
lang_items
=
tcx
.lang_items
();
let
primary_impl
=
match
primitive
{
Isize
=>
lang_items
.isize_impl
(),
I8
=>
lang_items
.i8_impl
(),
I16
=>
lang_items
.i16_impl
(),
I32
=>
lang_items
.i32_impl
(),
I64
=>
lang_items
.i64_impl
(),
I128
=>
lang_items
.i128_impl
(),
Usize
=>
lang_items
.usize_impl
(),
U8
=>
lang_items
.u8_impl
(),
U16
=>
lang_items
.u16_impl
(),
U32
=>
lang_items
.u32_impl
(),
U64
=>
lang_items
.u64_impl
(),
U128
=>
lang_items
.u128_impl
(),
F32
=>
return
both
(
lang_items
.f32_impl
(),
lang_items
.f32_runtime_impl
()),
F64
=>
return
both
(
lang_items
.f64_impl
(),
lang_items
.f64_runtime_impl
()),
Char
=>
lang_items
.char_impl
(),
Bool
=>
lang_items
.bool_impl
(),
Str
=>
return
both
(
lang_items
.str_impl
(),
lang_items
.str_alloc_impl
()),
Slice
=>
{
return
lang_items
.slice_impl
()
.into_iter
()
.chain
(
lang_items
.slice_u8_impl
())
.chain
(
lang_items
.slice_alloc_impl
())
.chain
(
lang_items
.slice_u8_alloc_impl
())
.collect
();
}
Array
=>
lang_items
.array_impl
(),
Tuple
=>
None
,
Unit
=>
None
,
RawPointer
=>
{
return
lang_items
.const_ptr_impl
()
.into_iter
()
.chain
(
lang_items
.mut_ptr_impl
())
.chain
(
lang_items
.const_slice_ptr_impl
())
.chain
(
lang_items
.mut_slice_ptr_impl
())
.collect
();
}
Reference
=>
None
,
Fn
=>
None
,
Never
=>
None
,
};
primary_impl
.into_iter
()
.collect
()
}
pub
fn
build_deref_target_impls
(
cx
:
&
DocContext
<
'_
>
,
items
:
&
[
Item
],
ret
:
&
mut
Vec
<
Item
>
)
{
let
tcx
=
cx
.tcx
;
...
...
@@ -424,7 +369,7 @@ pub fn build_deref_target_impls(cx: &DocContext<'_>, items: &[Item], ret: &mut V
None
=>
continue
,
},
};
for
did
in
impl_for_type
(
tcx
,
primitive
)
{
for
did
in
primitive
.impls
(
tcx
)
{
if
!
did
.is_local
()
{
inline
::
build_impl
(
cx
,
did
,
None
,
ret
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录