Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ee509337
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,发现更多精彩内容 >>
提交
ee509337
编写于
3月 10, 2021
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename clean::Constant did fields to def_id
上级
d61a1786
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
18 deletion
+18
-18
src/librustdoc/clean/inline.rs
src/librustdoc/clean/inline.rs
+2
-2
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+6
-8
src/librustdoc/clean/types.rs
src/librustdoc/clean/types.rs
+10
-8
未找到文件。
src/librustdoc/clean/inline.rs
浏览文件 @
ee509337
...
@@ -499,8 +499,8 @@ fn build_module(
...
@@ -499,8 +499,8 @@ fn build_module(
}
}
}
}
fn
build_const
(
cx
:
&
mut
DocContext
<
'_
>
,
did
:
DefId
)
->
clean
::
Constant
{
fn
build_const
(
cx
:
&
mut
DocContext
<
'_
>
,
d
ef_
id
:
DefId
)
->
clean
::
Constant
{
clean
::
Constant
::
Extern
{
type_
:
cx
.tcx
.type_of
(
d
id
)
.clean
(
cx
),
d
id
}
clean
::
Constant
::
Extern
{
type_
:
cx
.tcx
.type_of
(
d
ef_id
)
.clean
(
cx
),
def_
id
}
}
}
fn
build_static
(
cx
:
&
mut
DocContext
<
'_
>
,
did
:
DefId
,
mutable
:
bool
)
->
clean
::
Static
{
fn
build_static
(
cx
:
&
mut
DocContext
<
'_
>
,
did
:
DefId
,
mutable
:
bool
)
->
clean
::
Static
{
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
ee509337
...
@@ -1133,7 +1133,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item {
...
@@ -1133,7 +1133,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item {
ty
::
AssocKind
::
Const
=>
{
ty
::
AssocKind
::
Const
=>
{
let
ty
=
tcx
.type_of
(
self
.def_id
);
let
ty
=
tcx
.type_of
(
self
.def_id
);
let
default
=
if
self
.defaultness
.has_value
()
{
let
default
=
if
self
.defaultness
.has_value
()
{
Some
(
inline
::
print_inlined_const
(
cx
.
tcx
,
self
.def_id
))
Some
(
inline
::
print_inlined_const
(
tcx
,
self
.def_id
))
}
else
{
}
else
{
None
None
};
};
...
@@ -1743,8 +1743,8 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
...
@@ -1743,8 +1743,8 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
impl
<
'tcx
>
Clean
<
Constant
>
for
ty
::
Const
<
'tcx
>
{
impl
<
'tcx
>
Clean
<
Constant
>
for
ty
::
Const
<
'tcx
>
{
fn
clean
(
&
self
,
cx
:
&
mut
DocContext
<
'_
>
)
->
Constant
{
fn
clean
(
&
self
,
cx
:
&
mut
DocContext
<
'_
>
)
->
Constant
{
// FIXME: instead of storing
`format!("{}", self)`
, store `self` directly instead.
// FIXME: instead of storing
the stringified expression
, store `self` directly instead.
Constant
::
TyConst
{
type_
:
self
.ty
.clean
(
cx
),
expr
:
format!
(
"{}"
,
self
)
}
Constant
::
TyConst
{
type_
:
self
.ty
.clean
(
cx
),
expr
:
self
.to_string
(
)
}
}
}
}
}
...
@@ -1945,11 +1945,9 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Vec<Item> {
...
@@ -1945,11 +1945,9 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Vec<Item> {
ItemKind
::
Static
(
ty
,
mutability
,
body_id
)
=>
{
ItemKind
::
Static
(
ty
,
mutability
,
body_id
)
=>
{
StaticItem
(
Static
{
type_
:
ty
.clean
(
cx
),
mutability
,
expr
:
Some
(
body_id
)
})
StaticItem
(
Static
{
type_
:
ty
.clean
(
cx
),
mutability
,
expr
:
Some
(
body_id
)
})
}
}
ItemKind
::
Const
(
ty
,
body_id
)
=>
ConstantItem
(
Constant
::
Local
{
ItemKind
::
Const
(
ty
,
body_id
)
=>
{
type_
:
ty
.clean
(
cx
),
ConstantItem
(
Constant
::
Local
{
type_
:
ty
.clean
(
cx
),
body
:
body_id
,
def_id
})
body
:
body_id
,
}
did
:
def_id
,
}),
ItemKind
::
OpaqueTy
(
ref
ty
)
=>
OpaqueTyItem
(
OpaqueTy
{
ItemKind
::
OpaqueTy
(
ref
ty
)
=>
OpaqueTyItem
(
OpaqueTy
{
bounds
:
ty
.bounds
.clean
(
cx
),
bounds
:
ty
.bounds
.clean
(
cx
),
generics
:
ty
.generics
.clean
(
cx
),
generics
:
ty
.generics
.clean
(
cx
),
...
...
src/librustdoc/clean/types.rs
浏览文件 @
ee509337
...
@@ -1995,17 +1995,17 @@ fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
...
@@ -1995,17 +1995,17 @@ fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
/// nested inside types (e.g., array lengths) or expressions (e.g., repeat counts), and also
/// nested inside types (e.g., array lengths) or expressions (e.g., repeat counts), and also
/// used to define explicit discriminant values for enum variants.
/// used to define explicit discriminant values for enum variants.
Anonymous
{
type_
:
Type
,
body
:
BodyId
},
Anonymous
{
type_
:
Type
,
body
:
BodyId
},
///
Inlined constant
.
///
A constant from a different crate
.
Extern
{
type_
:
Type
,
did
:
DefId
},
Extern
{
type_
:
Type
,
d
ef_
id
:
DefId
},
/// const FOO: u32 = ...;
/// const FOO: u32 = ...;
Local
{
type_
:
Type
,
did
:
DefId
,
body
:
BodyId
},
Local
{
type_
:
Type
,
d
ef_
id
:
DefId
,
body
:
BodyId
},
}
}
impl
Constant
{
impl
Constant
{
crate
fn
expr
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
String
{
crate
fn
expr
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
String
{
match
self
{
match
self
{
Self
::
TyConst
{
expr
,
..
}
=>
expr
.clone
(),
Self
::
TyConst
{
expr
,
..
}
=>
expr
.clone
(),
Self
::
Extern
{
d
id
,
..
}
=>
print_inlined_const
(
tcx
,
*
d
id
),
Self
::
Extern
{
d
ef_id
,
..
}
=>
print_inlined_const
(
tcx
,
*
def_
id
),
Self
::
Local
{
body
,
..
}
|
Self
::
Anonymous
{
body
,
..
}
=>
print_const_expr
(
tcx
,
*
body
),
Self
::
Local
{
body
,
..
}
|
Self
::
Anonymous
{
body
,
..
}
=>
print_const_expr
(
tcx
,
*
body
),
}
}
}
}
...
@@ -2013,16 +2013,18 @@ impl Constant {
...
@@ -2013,16 +2013,18 @@ impl Constant {
crate
fn
value
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
Option
<
String
>
{
crate
fn
value
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
Option
<
String
>
{
match
self
{
match
self
{
Self
::
TyConst
{
..
}
|
Self
::
Anonymous
{
..
}
=>
None
,
Self
::
TyConst
{
..
}
|
Self
::
Anonymous
{
..
}
=>
None
,
Self
::
Extern
{
did
,
..
}
|
Self
::
Local
{
did
,
..
}
=>
print_evaluated_const
(
tcx
,
*
did
),
Self
::
Extern
{
def_id
,
..
}
|
Self
::
Local
{
def_id
,
..
}
=>
{
print_evaluated_const
(
tcx
,
*
def_id
)
}
}
}
}
}
crate
fn
is_literal
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
bool
{
crate
fn
is_literal
(
&
self
,
tcx
:
TyCtxt
<
'_
>
)
->
bool
{
match
self
{
match
self
{
Self
::
TyConst
{
..
}
=>
false
,
Self
::
TyConst
{
..
}
=>
false
,
Self
::
Extern
{
d
id
,
..
}
=>
did
Self
::
Extern
{
d
ef_id
,
..
}
=>
def_id
.as_local
()
.map_or
(
false
,
|
def_id
|
{
.as_local
(
)
is_literal_expr
(
tcx
,
tcx
.hir
()
.local_def_id_to_hir_id
(
def_id
)
)
.map_or
(
false
,
|
did
|
is_literal_expr
(
tcx
,
tcx
.hir
()
.local_def_id_to_hir_id
(
did
))
),
}
),
Self
::
Local
{
body
,
..
}
|
Self
::
Anonymous
{
body
,
..
}
=>
{
Self
::
Local
{
body
,
..
}
|
Self
::
Anonymous
{
body
,
..
}
=>
{
is_literal_expr
(
tcx
,
body
.hir_id
)
is_literal_expr
(
tcx
,
body
.hir_id
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录