Skip to content

Commit 0853c33

Browse files
committed
Use def_id_full() where easily possible
In general, it should be preferred over `Type::def_id()`. See each method's docs for more.
1 parent bf0cc90 commit 0853c33

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/librustdoc/clean/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ crate fn build_impl(
374374
// Only inline impl if the implementing type is
375375
// reachable in rustdoc generated documentation
376376
if !did.is_local() {
377-
if let Some(did) = for_.def_id() {
377+
if let Some(did) = for_.def_id_full(&cx.cache) {
378378
if !cx.cache.access_levels.is_public(did) {
379379
return;
380380
}
@@ -462,7 +462,7 @@ crate fn build_impl(
462462
}
463463

464464
while let Some(ty) = stack.pop() {
465-
if let Some(did) = ty.def_id() {
465+
if let Some(did) = ty.def_id_full(&cx.cache) {
466466
if tcx.get_attrs(did).lists(sym::doc).has_word(sym::hidden) {
467467
return;
468468
}

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
385385
let self_type = self.self_ty().clean(cx);
386386
Type::QPath {
387387
name: cx.tcx.associated_item(self.item_def_id).ident.name,
388-
self_def_id: self_type.def_id(),
388+
self_def_id: self_type.def_id_full(&cx.cache),
389389
self_type: box self_type,
390390
trait_,
391391
}
@@ -1887,7 +1887,7 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
18871887
}
18881888

18891889
let for_ = impl_.self_ty.clean(cx);
1890-
let type_alias = for_.def_id().and_then(|did| match tcx.def_kind(did) {
1890+
let type_alias = for_.def_id_full(&cx.cache).and_then(|did| match tcx.def_kind(did) {
18911891
DefKind::TyAlias => Some(tcx.type_of(did).clean(cx)),
18921892
_ => None,
18931893
});

src/librustdoc/formats/cache.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
206206
|| i.trait_
207207
.as_ref()
208208
.map_or(false, |t| self.cache.masked_crates.contains(&t.def_id().krate))
209-
|| i.for_.def_id().map_or(false, |d| self.cache.masked_crates.contains(&d.krate))
209+
|| i.for_
210+
.def_id_full(self.cache)
211+
.map_or(false, |d| self.cache.masked_crates.contains(&d.krate))
210212
{
211213
return None;
212214
}
@@ -454,7 +456,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
454456

455457
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
456458
for bound in generics {
457-
if let Some(did) = bound.def_id() {
459+
if let Some(did) = bound.def_id_full(self.cache) {
458460
dids.insert(did);
459461
}
460462
}

src/librustdoc/passes/collect_trait_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ crate fn collect_trait_impls(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
7070

7171
if let Some(prim) = target.primitive_type() {
7272
cleaner.prims.insert(prim);
73-
} else if let Some(did) = target.def_id() {
73+
} else if let Some(did) = target.def_id_full(&cx.cache) {
7474
cleaner.items.insert(did.into());
7575
}
7676
}

0 commit comments

Comments
 (0)