Doc link to trait method impl?

If I have the following code:

trait Foo {
    fn bar();
}

struct Baz;

impl Foo for Baz {
    fn bar() {}
}

Is it possible to create a rustdoc link to the impl of Foo::bar for Baz? I've tried the following, and neither work:

/// Blah blah [`Baz::bar`] blah blah.
///
/// [`Baz::bar`]: crate::Baz::bar
/// Blah blah [`Baz::bar`] blah blah.
///
/// [`Baz::bar`]: <crate::Baz as Foo>::bar

Any ideas how I can get this to work?

You would need this:
https://github.com/rust-lang/rust/issues/43466

I'm confused; aren't these sorts of links already supported? I use these sorts of links in code all the time, e.g.:

/// Implements [`Iterator`]...

That only works on nightly. On stable rust, those brackets will be shown as plain text.

Ah, I see. It's worked for so long that I guess I just assumed it was stable. Given that I'm on nightly, is there a way to make this work?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.