Skip to content

Rustdoc does not properly render higher-ranked lifetimes on the left-hand side of where clause bounds #39213

Closed
@abonander

Description

@abonander

Rustdoc confusingly renders the following function:

pub fn takes_ref<T>(foo: &T) where for<'a> &'a T: Sized {}

(Sized bound just used for demonstration, I know this doesn't add any meaning.)

as this:

pub fn takes_ref<T>(foo: &T) 
where &'a T: Sized

The for<'a> is omitted when it shouldn't be, because there's now magically a lifetime parameter that doesn't appear to be declared anywhere.

This doesn't just affect functions, of course:

pub struct Foo<T>(T) where for<'a> &'a T: Sized;
// Rendered:
pub struct Foo<T>(_) where &'a T: Sized;
pub trait Foo<T> where for<'a> &'a T: Sized {}
// Rendered: 
pub trait Foo<T> where &'a T: Sized { }

Higher-ranked lifetimes on the right-hand side of a where clause bound are rendered correctly:

pub trait Foo<T> where T: for<'a> Bar<'a> {}
pub trait Bar<'a> {}

// `Foo` rendered:
pub trait Foo<T> where T: for<'a> Bar<'a> { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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