Stream: rustdoc

Topic: properly render HRTBs


view this post on Zulip Stu (May 01 2021 at 15:48):

I'm currently working on #78482 and I already have a fix.
However, the for<'a> is highlighted like the &, which wrong, right? How can I "unhighlight" it?

screen.png

view this post on Zulip Stu (May 01 2021 at 15:51):

Oh, wait. Nvm, I figured it out. primitive_link will format it to be highlighted like this

view this post on Zulip Stu (May 02 2021 at 09:53):

There's one edge case that currently breaks my PR.

pub struct Foo<'a> {
    x: &'a u8,
}

impl<'a> Foo<'a> {
    pub fn bar<T>()
    where
        T: A<'a>,
    {
    }
}

rustdoc will add a for<'a> in front of the bound, which is invalid since 'a is already declared.
So I need to remove all lifetimes that are already declared in this scope.

How would I find all lifetimes in the scope of the where bound, to remove them from the list?

view this post on Zulip Stu (May 02 2021 at 10:29):

Mhh, I could get the lifetime parameters of the method, and then try to find the impl or trait where the method is in, and then use these lifetimes :thinking:

But would that cover all cases?

view this post on Zulip Stu (May 02 2021 at 12:33):

I just noticed that I'm stupid and I can solve this without collecting the lifetimes manually.

view this post on Zulip Joshua Nelson (May 02 2021 at 13:20):

In general the proper way to do this is a ParamEnv I think


Last updated: Oct 11 2021 at 22:34 UTC