Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d61a1786
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,发现更多精彩内容 >>
提交
d61a1786
编写于
3月 08, 2021
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve new Constant variants' name
上级
e25e15ce
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
21 addition
and
20 deletion
+21
-20
src/librustdoc/clean/inline.rs
src/librustdoc/clean/inline.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+2
-2
src/librustdoc/clean/types.rs
src/librustdoc/clean/types.rs
+18
-17
未找到文件。
src/librustdoc/clean/inline.rs
浏览文件 @
d61a1786
...
...
@@ -500,7 +500,7 @@ fn build_module(
}
fn
build_const
(
cx
:
&
mut
DocContext
<
'_
>
,
did
:
DefId
)
->
clean
::
Constant
{
clean
::
Constant
::
Inline
{
type_
:
cx
.tcx
.type_of
(
did
)
.clean
(
cx
),
did
}
clean
::
Constant
::
Extern
{
type_
:
cx
.tcx
.type_of
(
did
)
.clean
(
cx
),
did
}
}
fn
build_static
(
cx
:
&
mut
DocContext
<
'_
>
,
did
:
DefId
,
mutable
:
bool
)
->
clean
::
Static
{
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
d61a1786
...
...
@@ -393,7 +393,7 @@ fn clean(&self, _: &mut DocContext<'_>) -> Lifetime {
impl
Clean
<
Constant
>
for
hir
::
ConstArg
{
fn
clean
(
&
self
,
cx
:
&
mut
DocContext
<
'_
>
)
->
Constant
{
Constant
::
Generic
{
Constant
::
Anonymous
{
type_
:
cx
.tcx
.type_of
(
cx
.tcx
.hir
()
.body_owner_def_id
(
self
.value.body
)
.to_def_id
())
...
...
@@ -1945,7 +1945,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Vec<Item> {
ItemKind
::
Static
(
ty
,
mutability
,
body_id
)
=>
{
StaticItem
(
Static
{
type_
:
ty
.clean
(
cx
),
mutability
,
expr
:
Some
(
body_id
)
})
}
ItemKind
::
Const
(
ty
,
body_id
)
=>
ConstantItem
(
Constant
::
Const
{
ItemKind
::
Const
(
ty
,
body_id
)
=>
ConstantItem
(
Constant
::
Local
{
type_
:
ty
.clean
(
cx
),
body
:
body_id
,
did
:
def_id
,
...
...
src/librustdoc/clean/types.rs
浏览文件 @
d61a1786
...
...
@@ -1988,41 +1988,42 @@ fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
#[derive(Clone,
PartialEq,
Eq,
Hash,
Debug)]
crate
enum
Constant
{
/// Typed constant value.
/// This is the wrapper around `ty::Const` for a non-local constant. Because it doesn't have a
/// `BodyId`, we need to handle it on its own.
TyConst
{
type_
:
Type
,
expr
:
String
},
/// A constant (expression) that’s not an item or associated item. These are usually found
/// nested inside types (e.g., array lengths) or expressions (e.g., repeat counts), and also
/// used to define explicit discriminant values for enum variants.
Generic
{
type_
:
Type
,
body
:
BodyId
},
/// Inlined constant
(from another crate)
.
Inline
{
type_
:
Type
,
did
:
DefId
},
Anonymous
{
type_
:
Type
,
body
:
BodyId
},
/// Inlined constant.
Extern
{
type_
:
Type
,
did
:
DefId
},
/// const FOO: u32 = ...;
Const
{
type_
:
Type
,
did
:
DefId
,
body
:
BodyId
},
Local
{
type_
:
Type
,
did
:
DefId
,
body
:
BodyId
},
}
impl
Constant
{
crate
fn
expr
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
String
{
match
self
{
Self
::
TyConst
{
expr
,
..
}
=>
expr
.clone
(),
Self
::
Inline
{
did
,
..
}
=>
print_inlined_const
(
tcx
,
*
did
),
Self
::
Const
{
body
,
..
}
|
Self
::
Generic
{
body
,
..
}
=>
print_const_expr
(
tcx
,
*
body
),
Self
::
Extern
{
did
,
..
}
=>
print_inlined_const
(
tcx
,
*
did
),
Self
::
Local
{
body
,
..
}
|
Self
::
Anonymous
{
body
,
..
}
=>
print_const_expr
(
tcx
,
*
body
),
}
}
crate
fn
value
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
Option
<
String
>
{
match
self
{
Self
::
TyConst
{
..
}
|
Self
::
Generic
{
..
}
=>
None
,
Self
::
Inline
{
did
,
..
}
|
Self
::
Const
{
did
,
..
}
=>
print_evaluated_const
(
tcx
,
*
did
),
Self
::
TyConst
{
..
}
|
Self
::
Anonymous
{
..
}
=>
None
,
Self
::
Extern
{
did
,
..
}
|
Self
::
Local
{
did
,
..
}
=>
print_evaluated_const
(
tcx
,
*
did
),
}
}
crate
fn
is_literal
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
bool
{
match
self
{
Self
::
TyConst
{
..
}
=>
false
,
Self
::
Inline
{
did
,
..
}
=>
did
Self
::
Extern
{
did
,
..
}
=>
did
.as_local
()
.map_or
(
false
,
|
did
|
is_literal_expr
(
tcx
,
tcx
.hir
()
.local_def_id_to_hir_id
(
did
))),
Self
::
Const
{
body
,
..
}
|
Self
::
Generic
{
body
,
..
}
=>
{
Self
::
Local
{
body
,
..
}
|
Self
::
Anonymous
{
body
,
..
}
=>
{
is_literal_expr
(
tcx
,
body
.hir_id
)
}
}
...
...
@@ -2031,18 +2032,18 @@ impl Constant {
crate
fn
type_
(
&
self
)
->
&
Type
{
match
*
self
{
Self
::
TyConst
{
ref
type_
,
..
}
|
Self
::
Inline
{
ref
type_
,
..
}
|
Self
::
Const
{
ref
type_
,
..
}
|
Self
::
Generic
{
ref
type_
,
..
}
=>
type_
,
|
Self
::
Extern
{
ref
type_
,
..
}
|
Self
::
Local
{
ref
type_
,
..
}
|
Self
::
Anonymous
{
ref
type_
,
..
}
=>
type_
,
}
}
crate
fn
to_type
(
self
)
->
Type
{
match
self
{
Self
::
TyConst
{
type_
,
..
}
|
Self
::
Inline
{
type_
,
..
}
|
Self
::
Const
{
type_
,
..
}
|
Self
::
Generic
{
type_
,
..
}
=>
type_
,
|
Self
::
Extern
{
type_
,
..
}
|
Self
::
Local
{
type_
,
..
}
|
Self
::
Anonymous
{
type_
,
..
}
=>
type_
,
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录