Skip to content

Commit 62b9e06

Browse files
committed
rustdoc: show implementations on #[fundamental] wrappers
Fixes #92940
1 parent 1c8966e commit 62b9e06

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/librustdoc/formats/cache.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::mem;
33
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
44
use rustc_hir::def_id::{CrateNum, DefId};
55
use rustc_middle::middle::privacy::AccessLevels;
6-
use rustc_middle::ty::TyCtxt;
6+
use rustc_middle::ty::{self, TyCtxt};
77
use rustc_span::{sym, Symbol};
88

99
use crate::clean::{self, types::ExternalLocation, ExternalCrate, ItemId, PrimitiveType};
@@ -450,6 +450,15 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
450450
clean::Type::Path { ref path }
451451
| clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => {
452452
dids.insert(path.def_id());
453+
if let Some(generics) = path.generics() &&
454+
let ty::Adt(adt, _) = self.tcx.type_of(path.def_id()).kind() &&
455+
adt.is_fundamental() {
456+
for ty in generics {
457+
if let Some(did) = ty.def_id(&self.cache) {
458+
dids.insert(did);
459+
}
460+
}
461+
}
453462
}
454463
clean::DynTrait(ref bounds, _)
455464
| clean::BorrowedRef { type_: box clean::DynTrait(ref bounds, _), .. } => {

src/test/rustdoc/impl-box.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// https://github.com/rust-lang/rust/issues/92940
2+
//
3+
// Show traits implemented on fundamental types that wrap local ones.
4+
5+
pub struct MyType;
6+
7+
// @has 'impl_box/struct.MyType.html'
8+
// @has '-' '//*[@id="impl-Iterator"]' 'impl Iterator for Box<MyType>'
9+
10+
impl Iterator for Box<MyType> {
11+
type Item = ();
12+
13+
fn next(&mut self) -> Option<Self::Item> {
14+
todo!()
15+
}
16+
}

0 commit comments

Comments
 (0)