Skip to content

rustdoc: Impl for boxed type doesn't show up on the type's page #92940

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
camelid opened this issue Jan 15, 2022 · 4 comments · Fixed by #96565
Closed

rustdoc: Impl for boxed type doesn't show up on the type's page #92940

camelid opened this issue Jan 15, 2022 · 4 comments · Fixed by #96565
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@camelid
Copy link
Member

camelid commented Jan 15, 2022

You'd expect the impl for the boxed type to show up, but it doesn't. I seem to recall rustdoc displays impls anytime the type is contained in the generics, though, so it's odd that it's not happening.

pub struct MyType;

impl Iterator for Box<MyType> {
    type Item = ();

    fn next(&mut self) -> Option<Self::Item> {
        todo!()
    }
}

Originally reported by @danielhenrymantilla (with Pin<&mut MyType>) on Discord.

@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-trait-system Area: Trait system C-bug Category: This is a bug. labels Jan 15, 2022
@camelid
Copy link
Member Author

camelid commented Jan 15, 2022

@danielhenrymantilla also reported a case involving a Box<dyn Trait> impl that didn't show up on the trait's page. IIRC this issue is somewhat known already though.

@GuillaumeGomez
Copy link
Member

I can't find a case where the impl is added if the type is in the generics. Do you have an example maybe?

@camelid
Copy link
Member Author

camelid commented Feb 16, 2022

@notriddle
Copy link
Contributor

That one's happening because of this thing. Notice that the generics on the trait count, but the generics on Self don't.

let ret = if let clean::Item { kind: box clean::ImplItem(ref i), .. } = item {
// Figure out the id of this impl. This may map to a
// primitive rather than always to a struct/enum.
// Note: matching twice to restrict the lifetime of the `i` borrow.
let mut dids = FxHashSet::default();
match i.for_ {
clean::Type::Path { ref path }
| clean::BorrowedRef { type_: box clean::Type::Path { ref path }, .. } => {
dids.insert(path.def_id());
}
clean::DynTrait(ref bounds, _)
| clean::BorrowedRef { type_: box clean::DynTrait(ref bounds, _), .. } => {
dids.insert(bounds[0].trait_.def_id());
}
ref t => {
let did = t
.primitive_type()
.and_then(|t| self.cache.primitive_locations.get(&t).cloned());
if let Some(did) = did {
dids.insert(did);
}
}
}
if let Some(generics) = i.trait_.as_ref().and_then(|t| t.generics()) {
for bound in generics {
if let Some(did) = bound.def_id(self.cache) {
dids.insert(did);
}
}
}

We definitely need to fix this, specifically, for #[fundamental] types, because that's how you wind up with impls that aren't actually documented anywhere.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 20, 2022
…elid

rustdoc: show implementations on `#[fundamental]` wrappers

Fixes rust-lang#92940
@bors bors closed this as completed in 62b9e06 May 20, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-trait-system Area: Trait system C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants