Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
43651125
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,发现更多精彩内容 >>
提交
43651125
编写于
11月 11, 2021
作者:
N
Noah Lev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove `ResolvedPath.did`
上级
db4a06e9
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
29 addition
and
30 deletion
+29
-30
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+2
-2
src/librustdoc/clean/types.rs
src/librustdoc/clean/types.rs
+2
-2
src/librustdoc/clean/utils.rs
src/librustdoc/clean/utils.rs
+4
-3
src/librustdoc/formats/cache.rs
src/librustdoc/formats/cache.rs
+5
-5
src/librustdoc/html/format.rs
src/librustdoc/html/format.rs
+2
-1
src/librustdoc/html/render/cache.rs
src/librustdoc/html/render/cache.rs
+1
-1
src/librustdoc/html/render/mod.rs
src/librustdoc/html/render/mod.rs
+3
-3
src/librustdoc/html/render/print_item.rs
src/librustdoc/html/render/print_item.rs
+5
-4
src/librustdoc/json/conversions.rs
src/librustdoc/json/conversions.rs
+5
-9
未找到文件。
src/librustdoc/clean/mod.rs
浏览文件 @
43651125
...
...
@@ -1411,12 +1411,12 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
};
inline
::
record_extern_fqn
(
cx
,
did
,
kind
);
let
path
=
external_path
(
cx
,
did
,
false
,
vec!
[],
substs
);
ResolvedPath
{
path
,
did
}
ResolvedPath
{
path
}
}
ty
::
Foreign
(
did
)
=>
{
inline
::
record_extern_fqn
(
cx
,
did
,
ItemType
::
ForeignType
);
let
path
=
external_path
(
cx
,
did
,
false
,
vec!
[],
InternalSubsts
::
empty
());
ResolvedPath
{
path
,
did
}
ResolvedPath
{
path
}
}
ty
::
Dynamic
(
obj
,
ref
reg
)
=>
{
// HACK: pick the first `did` as the `did` of the trait object. Someone
...
...
src/librustdoc/clean/types.rs
浏览文件 @
43651125
...
...
@@ -1419,7 +1419,7 @@ impl FnRetTy {
/// A named type, which could be a trait.
///
/// This is mostly Rustdoc's version of [`hir::Path`]. It has to be different because Rustdoc's [`PathSegment`] can contain cleaned generics.
ResolvedPath
{
path
:
Path
,
did
:
DefId
},
ResolvedPath
{
path
:
Path
},
/// A `dyn Trait` object: `dyn for<'a> Trait<'a> + Send + 'static`
DynTrait
(
Vec
<
PolyTrait
>
,
Option
<
Lifetime
>
),
/// A type parameter.
...
...
@@ -1522,7 +1522,7 @@ impl Type {
fn
inner_def_id
(
&
self
,
cache
:
Option
<&
Cache
>
)
->
Option
<
DefId
>
{
let
t
:
PrimitiveType
=
match
*
self
{
ResolvedPath
{
ref
path
,
did
:
_
}
=>
return
Some
(
path
.def_id
()),
ResolvedPath
{
ref
path
}
=>
return
Some
(
path
.def_id
()),
DynTrait
(
ref
bounds
,
_
)
=>
return
Some
(
bounds
[
0
]
.trait_
.def_id
()),
Primitive
(
p
)
=>
return
cache
.and_then
(|
c
|
c
.primitive_locations
.get
(
&
p
)
.cloned
()),
BorrowedRef
{
type_
:
box
Generic
(
..
),
..
}
=>
PrimitiveType
::
Reference
,
...
...
src/librustdoc/clean/utils.rs
浏览文件 @
43651125
...
...
@@ -187,7 +187,8 @@ pub(super) fn external_path(
for
&
did
in
prim
.impls
(
tcx
)
.iter
()
.filter
(|
did
|
!
did
.is_local
())
{
inline
::
build_impl
(
cx
,
None
,
did
,
None
,
ret
);
}
}
else
if
let
ResolvedPath
{
did
,
..
}
=
*
target
{
}
else
if
let
ResolvedPath
{
path
}
=
target
{
let
did
=
path
.def_id
();
if
!
did
.is_local
()
{
inline
::
build_impls
(
cx
,
None
,
did
,
None
,
ret
);
}
...
...
@@ -360,8 +361,8 @@ fn print_const_with_custom_print_scalar(tcx: TyCtxt<'_>, ct: &'tcx ty::Const<'tc
Res
::
SelfTy
(
..
)
if
path
.segments
.len
()
==
1
=>
Generic
(
kw
::
SelfUpper
),
Res
::
Def
(
DefKind
::
TyParam
,
_
)
if
path
.segments
.len
()
==
1
=>
Generic
(
path
.segments
[
0
]
.name
),
_
=>
{
let
did
=
register_res
(
cx
,
path
.res
);
ResolvedPath
{
path
,
did
}
let
_
=
register_res
(
cx
,
path
.res
);
ResolvedPath
{
path
}
}
}
}
...
...
src/librustdoc/formats/cache.rs
浏览文件 @
43651125
...
...
@@ -401,8 +401,8 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
clean
::
ImplItem
(
ref
i
)
=>
{
self
.cache.parent_is_trait_impl
=
i
.trait_
.is_some
();
match
i
.for_
{
clean
::
ResolvedPath
{
did
,
..
}
=>
{
self
.cache.parent_stack
.push
(
did
);
clean
::
ResolvedPath
{
ref
path
}
=>
{
self
.cache.parent_stack
.push
(
path
.def_id
()
);
true
}
clean
::
DynTrait
(
ref
bounds
,
_
)
...
...
@@ -436,9 +436,9 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
// Note: matching twice to restrict the lifetime of the `i` borrow.
let
mut
dids
=
FxHashSet
::
default
();
match
i
.for_
{
clean
::
ResolvedPath
{
did
,
..
}
|
clean
::
BorrowedRef
{
type_
:
box
clean
::
ResolvedPath
{
did
,
..
},
..
}
=>
{
dids
.insert
(
did
);
clean
::
ResolvedPath
{
ref
path
}
|
clean
::
BorrowedRef
{
type_
:
box
clean
::
ResolvedPath
{
ref
path
},
..
}
=>
{
dids
.insert
(
path
.def_id
()
);
}
clean
::
DynTrait
(
ref
bounds
,
_
)
|
clean
::
BorrowedRef
{
type_
:
box
clean
::
DynTrait
(
ref
bounds
,
_
),
..
}
=>
{
...
...
src/librustdoc/html/format.rs
浏览文件 @
43651125
...
...
@@ -762,8 +762,9 @@ fn fmt_type<'cx>(
match
*
t
{
clean
::
Generic
(
name
)
=>
write!
(
f
,
"{}"
,
name
),
clean
::
ResolvedPath
{
did
,
ref
path
}
=>
{
clean
::
ResolvedPath
{
ref
path
}
=>
{
// Paths like `T::Output` and `Self::Output` should be rendered with all segments.
let
did
=
path
.def_id
();
resolved_path
(
f
,
did
,
path
,
path
.is_assoc_ty
(),
use_absolute
,
cx
)
}
clean
::
DynTrait
(
ref
bounds
,
ref
lt
)
=>
{
...
...
src/librustdoc/html/render/cache.rs
浏览文件 @
43651125
...
...
@@ -371,7 +371,7 @@ fn insert_ty(
let
mut
ty_generics
=
Vec
::
new
();
for
bound
in
bound
.get_bounds
()
.unwrap_or
(
&
[])
{
if
let
Some
(
path
)
=
bound
.get_trait_path
()
{
let
ty
=
Type
::
ResolvedPath
{
did
:
path
.def_id
(),
path
};
let
ty
=
Type
::
ResolvedPath
{
path
};
get_real_types
(
generics
,
&
ty
,
tcx
,
recurse
+
1
,
&
mut
ty_generics
,
cache
);
}
}
...
...
src/librustdoc/html/render/mod.rs
浏览文件 @
43651125
...
...
@@ -1243,8 +1243,8 @@ fn should_render_item(item: &clean::Item, deref_mut_: bool, tcx: TyCtxt<'_>) ->
|
SelfTy
::
SelfExplicit
(
clean
::
BorrowedRef
{
mutability
,
..
})
=>
{
(
mutability
==
Mutability
::
Mut
,
false
,
false
)
}
SelfTy
::
SelfExplicit
(
clean
::
ResolvedPath
{
did
,
..
})
=>
{
(
false
,
Some
(
did
)
==
tcx
.lang_items
()
.owned_box
(),
false
)
SelfTy
::
SelfExplicit
(
clean
::
ResolvedPath
{
path
})
=>
{
(
false
,
Some
(
path
.def_id
()
)
==
tcx
.lang_items
()
.owned_box
(),
false
)
}
SelfTy
::
SelfValue
=>
(
false
,
false
,
true
),
_
=>
(
false
,
false
,
false
),
...
...
@@ -2536,7 +2536,7 @@ fn collect_paths_for_type(first_ty: clean::Type, cache: &Cache) -> Vec<String> {
}
match
ty
{
clean
::
Type
::
ResolvedPath
{
did
,
..
}
=>
process_path
(
did
),
clean
::
Type
::
ResolvedPath
{
path
}
=>
process_path
(
path
.def_id
()
),
clean
::
Type
::
Tuple
(
tys
)
=>
{
work
.extend
(
tys
.into_iter
());
}
...
...
src/librustdoc/html/render/print_item.rs
浏览文件 @
43651125
...
...
@@ -727,10 +727,11 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
let
mut
implementor_dups
:
FxHashMap
<
Symbol
,
(
DefId
,
bool
)
>
=
FxHashMap
::
default
();
for
implementor
in
implementors
{
match
implementor
.inner_impl
()
.for_
{
clean
::
ResolvedPath
{
ref
path
,
did
,
..
}
|
clean
::
BorrowedRef
{
type_
:
box
clean
::
ResolvedPath
{
ref
path
,
did
,
..
},
..
}
if
!
path
.is_assoc_ty
()
=>
{
clean
::
ResolvedPath
{
ref
path
}
|
clean
::
BorrowedRef
{
type_
:
box
clean
::
ResolvedPath
{
ref
path
},
..
}
if
!
path
.is_assoc_ty
()
=>
{
let
did
=
path
.def_id
();
let
&
mut
(
prev_did
,
ref
mut
has_duplicates
)
=
implementor_dups
.entry
(
path
.last
())
.or_insert
((
did
,
false
));
if
prev_did
!=
did
{
...
...
src/librustdoc/json/conversions.rs
浏览文件 @
43651125
...
...
@@ -365,8 +365,7 @@ fn from_tcx(bound: clean::GenericBound, tcx: TyCtxt<'_>) -> Self {
match
bound
{
TraitBound
(
clean
::
PolyTrait
{
trait_
,
generic_params
},
modifier
)
=>
{
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
let
trait_
=
clean
::
ResolvedPath
{
did
:
trait_
.def_id
(),
path
:
trait_
}
.into_tcx
(
tcx
);
let
trait_
=
clean
::
ResolvedPath
{
path
:
trait_
}
.into_tcx
(
tcx
);
GenericBound
::
TraitBound
{
trait_
,
generic_params
:
generic_params
.into_iter
()
.map
(|
x
|
x
.into_tcx
(
tcx
))
.collect
(),
...
...
@@ -391,9 +390,9 @@ impl FromWithTcx<clean::Type> for Type {
fn
from_tcx
(
ty
:
clean
::
Type
,
tcx
:
TyCtxt
<
'_
>
)
->
Self
{
use
clean
::
Type
::
*
;
match
ty
{
ResolvedPath
{
path
,
did
}
=>
Type
::
ResolvedPath
{
ResolvedPath
{
path
}
=>
Type
::
ResolvedPath
{
name
:
path
.whole_name
(),
id
:
from_item_id
(
did
.into
()),
id
:
from_item_id
(
path
.def_id
()
.into
()),
args
:
path
.segments
.last
()
.map
(|
args
|
Box
::
new
(
args
.clone
()
.args
.into_tcx
(
tcx
))),
param_names
:
Vec
::
new
(),
},
...
...
@@ -436,7 +435,7 @@ fn from_tcx(ty: clean::Type, tcx: TyCtxt<'_>) -> Self {
},
QPath
{
name
,
self_type
,
trait_
,
..
}
=>
{
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
let
trait_
=
ResolvedPath
{
did
:
trait_
.def_id
(),
path
:
trait_
}
.into_tcx
(
tcx
);
let
trait_
=
ResolvedPath
{
path
:
trait_
}
.into_tcx
(
tcx
);
Type
::
QualifiedPath
{
name
:
name
.to_string
(),
self_type
:
Box
::
new
((
*
self_type
)
.into_tcx
(
tcx
)),
...
...
@@ -502,10 +501,7 @@ fn from_tcx(impl_: clean::Impl, tcx: TyCtxt<'_>) -> Self {
let
provided_trait_methods
=
impl_
.provided_trait_methods
(
tcx
);
let
clean
::
Impl
{
unsafety
,
generics
,
trait_
,
for_
,
items
,
polarity
,
kind
}
=
impl_
;
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
let
trait_
=
trait_
.map
(|
path
|
{
let
did
=
path
.def_id
();
clean
::
ResolvedPath
{
path
,
did
}
.into_tcx
(
tcx
)
});
let
trait_
=
trait_
.map
(|
path
|
clean
::
ResolvedPath
{
path
}
.into_tcx
(
tcx
));
// FIXME: use something like ImplKind in JSON?
let
(
synthetic
,
blanket_impl
)
=
match
kind
{
clean
::
ImplKind
::
Normal
=>
(
false
,
None
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录