Skip to content

rustdoc should show module for types when the type name is not unique #37762

Closed
@quodlibetor

Description

@quodlibetor

If you look at the docs for ExactSizeIterator there are I think literally hundreds of implementations, with perhaps dozens that look identical, e.g. here are some lines I copied out:

impl<'a, T> ExactSizeIterator for Iter<'a, T>
impl<T> ExactSizeIterator for IntoIter<T>
impl<'a, T> ExactSizeIterator for Iter<'a, T>
impl<'a, T> ExactSizeIterator for IterMut<'a, T>
impl<T> ExactSizeIterator for IntoIter<T>
impl<T> ExactSizeIterator for IntoIter<T>

Those are all distinct implementations, but with the idiom of not-stuttering module names in type-names it is impossible to know which type you're looking for without hovering your mouse over each.

Those lines would be more helpful if they looked like:

impl<'a, T> ExactSizeIterator for btree_set::Iter<'a, T>
impl<T> ExactSizeIterator for btree_set::IntoIter<T>
impl<'a, T> ExactSizeIterator for linked_list::Iter<'a, T>
impl<'a, T> ExactSizeIterator for linked_list::IterMut<'a, T>
impl<T> ExactSizeIterator for linked_list::IntoIter<T>
impl<T> ExactSizeIterator for vec::IntoIter<T>

IMO the way that rustdoc should handle this is it should check if the type is ambiguous at all in the current documentation run (not just ambiguous on the current documentation page) and disambiguate with as many modules as necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions