From a5402343f60271c7e428bb6e6aac704bd88bb2bf Mon Sep 17 00:00:00 2001 From: León Orell Valerian Liehr Date: Wed, 28 Sep 2022 22:54:39 +0200 Subject: rustdoc: re-sugar more cross-crate trait bounds --- ...assoc_item_trait_bounds_with_bindings.out0.html | 1 + ...assoc_item_trait_bounds_with_bindings.out9.html | 1 + .../assoc_item_trait_bounds_with_bindings.rs | 40 ++++++++++++++++++++++ .../assoc_item_trait_bounds_with_bindings.rs | 40 ++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out0.html create mode 100644 src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out9.html create mode 100644 src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.rs create mode 100644 src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds_with_bindings.rs (limited to 'src/test') diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out0.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out0.html new file mode 100644 index 00000000000..927a1a42a1f --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out0.html @@ -0,0 +1 @@ +

type Out0: Support<Item = ()>

\ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out9.html b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out9.html new file mode 100644 index 00000000000..69d84e1b2c1 --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.out9.html @@ -0,0 +1 @@ +

type Out9: FnMut(i32) -> bool + Clone

\ No newline at end of file diff --git a/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.rs b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.rs new file mode 100644 index 00000000000..b026f399a56 --- /dev/null +++ b/src/test/rustdoc/inline_cross/assoc_item_trait_bounds_with_bindings.rs @@ -0,0 +1,40 @@ +// Regression test for issues #77763, #84579 and #102142. +#![crate_name = "main"] + +// aux-build:assoc_item_trait_bounds_with_bindings.rs +// build-aux-docs +// ignore-cross-compile +extern crate assoc_item_trait_bounds_with_bindings as aux; + +// FIXME(fmease): Don't render an incorrect `T: ?Sized` where-clause for parameters +// of GATs like `Main::Out{2,4}`. Add a snapshot test once it's fixed. +// FIXME(fmease): Print the `for<>` parameter list in the bounds of +// `Main::Out{6,11,12}`. + +// @has main/trait.Main.html +// @has - '//*[@id="associatedtype.Out0"]' 'type Out0: Support' +// @has - '//*[@id="associatedtype.Out1"]' 'type Out1: Support' +// @has - '//*[@id="associatedtype.Out2"]' 'type Out2: Support' +// @has - '//*[@id="associatedtype.Out3"]' 'type Out3: Support = bool>' +// @has - '//*[@id="associatedtype.Out4"]' 'type Out4: Support = T>' +// @has - '//*[@id="associatedtype.Out5"]' "type Out5: Support = &'static ()>" +// @has - '//*[@id="associatedtype.Out6"]' "type Out6: Support = &'a ()>" +// @has - '//*[@id="associatedtype.Out7"]' "type Out7: Support = u32> + Unrelated" +// @has - '//*[@id="associatedtype.Out8"]' "type Out8: Unrelated + Protocol" +// @has - '//*[@id="associatedtype.Out9"]' "type Out9: FnMut(i32) -> bool + Clone" +// @has - '//*[@id="associatedtype.Out10"]' "type Out10<'q>: Support = ()>" +// @has - '//*[@id="associatedtype.Out11"]' "type Out11: Helper = &'s (), B<'r> = ()>" +// @has - '//*[@id="associatedtype.Out12"]' "type Out12: Helper = Cow<'w, str>, A<'w> = bool>" +// +// Snapshots: Check that we do not render any where-clauses for those associated types since all of +// the trait bounds contained within were moved to the bounds of the respective item. +// +// @snapshot out0 - '//*[@id="associatedtype.Out0"]/*[@class="code-header"]' +// @snapshot out9 - '//*[@id="associatedtype.Out9"]/*[@class="code-header"]' +// +// @has - '//*[@id="tymethod.make"]' \ +// "fn make(F, impl FnMut(&str) -> bool)\ +// where \ +// F: FnOnce(u32) -> String, \ +// Self::Out2<()>: Protocol" +pub use aux::Main; diff --git a/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds_with_bindings.rs b/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds_with_bindings.rs new file mode 100644 index 00000000000..7225f2dca10 --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/assoc_item_trait_bounds_with_bindings.rs @@ -0,0 +1,40 @@ +pub trait Main { + type Item; + + type Out0: Support; + type Out1: Support; + type Out2: Support; + type Out3: Support = bool>; + type Out4: Support = T>; + type Out5: Support = &'static ()>; + type Out6: for<'a> Support = &'a ()>; + type Out7: Support = u32> + Unrelated; + type Out8: Unrelated + Protocol; + type Out9: FnMut(i32) -> bool + Clone; + type Out10<'q>: Support = ()>; + type Out11: for<'r, 's> Helper = &'s (), B<'r> = ()>; + type Out12: for<'w> Helper = std::borrow::Cow<'w, str>, A<'w> = bool>; + + fn make(_: F, _: impl FnMut(&str) -> bool) + where + F: FnOnce(u32) -> String, + Self::Out2<()>: Protocol; +} + +pub trait Support { + type Item; + type Output<'a>; + type Produce; +} + +pub trait Protocol { + type Q0; + type Q1; +} + +pub trait Unrelated {} + +pub trait Helper { + type A<'q>; + type B<'q>; +} -- cgit 1.4.1-3-g733a5