Skip to content

Commit afcf099

Browse files
Rollup merge of #96565 - notriddle:notriddle/impl-box, r=camelid
rustdoc: show implementations on `#[fundamental]` wrappers Fixes #92940
2 parents cd73afa + 62b9e06 commit afcf099

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};
@@ -452,6 +452,15 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
452452
clean::Type::Path { ref path }
453453
| clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => {
454454
dids.insert(path.def_id());
455+
if let Some(generics) = path.generics() &&
456+
let ty::Adt(adt, _) = self.tcx.type_of(path.def_id()).kind() &&
457+
adt.is_fundamental() {
458+
for ty in generics {
459+
if let Some(did) = ty.def_id(&self.cache) {
460+
dids.insert(did);
461+
}
462+
}
463+
}
455464
}
456465
clean::DynTrait(ref bounds, _)
457466
| 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)