-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Comparing the rustdoc HTML output of https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/higher-ranked-trait-bounds.rs with the output of public-api
, there are differences. To see them, first generate rustdoc HTML output for that file:
% ~/.rustup/toolchains/nightly-2022-03-31-aarch64-apple-darwin/bin/rustdoc ~/src/rust/src/test/rustdoc/higher-ranked-trait-bounds.rs -Z unstable-options --output-format html -o /tmp/hrtb
and then look at e.g. open /tmp/hrtb/foo/fn.test3.html
which looks like this:
pub fn test3<F>()
where
F: for<'a, 'b> Fn(&'a u8, &'b u8),
and then generate output with public-api:
% ~/.rustup/toolchains/nightly-2022-03-31-aarch64-apple-darwin/bin/rustdoc ~/src/rust/src/test/rustdoc/higher-ranked-trait-bounds.rs -Z unstable-options --output-format json -o /tmp/hrtb
% public-api /tmp/hrtb/foo.json
pub fn foo::Foo::bar<T>() where T: Trait<'a>
pub fn foo::test1<T>() where &'a T: Iterator
pub fn foo::test2<T>() where &'a T: Trait<'b>
pub fn foo::test3<F>() where F: Fn(&'a u8, &'b u8)<'a, 'b>
pub mod foo
pub struct field foo::Bar::bar: &'a Trait<'b> + Unpin
pub struct field foo::Bar::baz: &'a Unpin + Trait<'b><'b>
pub struct field foo::Foo::some_func: fn(&'c i32) -> i32
pub struct field foo::Foo::some_trait: &'a Trait<'b>
pub struct foo::Bar<'a>
pub struct foo::Foo<'a>
pub trait foo::B<'x>
pub trait foo::Trait<'x>
Normalizing whitespace and linewlines and aligning, we have this vs that:
pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8),
pub fn foo::test3<F>() where F: Fn(&'a u8, &'b u8)<'a, 'b>
There is a FIXME related to HRTB in rust-lang/rust/src/librustdoc/json/conversions.rs, so not sure we can fix them all, but it looks like we can fix the particular example I brought up.
For reference HRTB, didn't work properly in rustdoc HTML either for quite a while (see rust-lang/rust#78482), but was fixed quite recently, which also added the FIXME (see rust-lang/rust#84814).
To fix HRTBs in rustdoc HTML, the DynTrait object was introduced in the above PR. So fixing all HRTB problems might be related to fixing cargo-public-api/cargo-public-api#40, in case it requires upstream changes.