diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2022-05-20 14:03:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-20 14:03:01 +0200 |
| commit | afcf099e30c9d740cee7301cac486f27c5716857 (patch) | |
| tree | baf60e78e0fa6c22bd997a9aba3b8946698dc2b1 /src | |
| parent | cd73afadae5b0163f9285f1b5edbbd1c84fde410 (diff) | |
| parent | 62b9e0643b54f2ebe9d01e9537de7d4ad741ca83 (diff) | |
Rollup merge of #96565 - notriddle:notriddle/impl-box, r=camelid
rustdoc: show implementations on `#[fundamental]` wrappers Fixes #92940
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/formats/cache.rs | 11 | ||||
| -rw-r--r-- | src/test/rustdoc/impl-box.rs | 16 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index 9dc30d8a189..28648e25d90 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -3,7 +3,7 @@ use std::mem; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::{CrateNum, DefId}; use rustc_middle::middle::privacy::AccessLevels; -use rustc_middle::ty::TyCtxt; +use rustc_middle::ty::{self, TyCtxt}; use rustc_span::{sym, Symbol}; use crate::clean::{self, types::ExternalLocation, ExternalCrate, ItemId, PrimitiveType}; @@ -452,6 +452,15 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { clean::Type::Path { ref path } | clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => { dids.insert(path.def_id()); + if let Some(generics) = path.generics() && + let ty::Adt(adt, _) = self.tcx.type_of(path.def_id()).kind() && + adt.is_fundamental() { + for ty in generics { + if let Some(did) = ty.def_id(&self.cache) { + dids.insert(did); + } + } + } } clean::DynTrait(ref bounds, _) | clean::BorrowedRef { type_: box clean::DynTrait(ref bounds, _), .. } => { diff --git a/src/test/rustdoc/impl-box.rs b/src/test/rustdoc/impl-box.rs new file mode 100644 index 00000000000..a371db135cf --- /dev/null +++ b/src/test/rustdoc/impl-box.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/92940 +// +// Show traits implemented on fundamental types that wrap local ones. + +pub struct MyType; + +// @has 'impl_box/struct.MyType.html' +// @has '-' '//*[@id="impl-Iterator"]' 'impl Iterator for Box<MyType>' + +impl Iterator for Box<MyType> { + type Item = (); + + fn next(&mut self) -> Option<Self::Item> { + todo!() + } +} |
