diff options
| author | bors <bors@rust-lang.org> | 2021-06-26 10:52:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-06-26 10:52:16 +0000 |
| commit | 831ae3c1364b7b033bd1da430bc1cb86d93ad186 (patch) | |
| tree | 32db4a7d7858a85aefba7d95d4e728858b1ebee1 /src/test/rustdoc | |
| parent | 481971978fda83aa7cf1f1f3c80cfad822377cf2 (diff) | |
| parent | 4ea27484c9582389cded2301d1f0dd4f421c8c35 (diff) | |
Auto merge of #84814 - Stupremee:properly-render-hrtbs, r=GuillaumeGomez
Properly render HRTBs
```rust
pub fn test<T>()
where
for<'a> &'a T: Iterator,
{}
```
This will now render properly including the `for<'a>`

I do not know if this covers all cases, it only covers everything that I could think of that includes `for` and lifetimes in where bounds.
Also someone need to mentor me on how to add a proper rustdoc test for this.
Resolves #78482
Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/for-lifetime.rs | 12 | ||||
| -rw-r--r-- | src/test/rustdoc/higher-ranked-trait-bounds.rs | 61 |
2 files changed, 61 insertions, 12 deletions
diff --git a/src/test/rustdoc/for-lifetime.rs b/src/test/rustdoc/for-lifetime.rs deleted file mode 100644 index 34a7eae31c7..00000000000 --- a/src/test/rustdoc/for-lifetime.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![crate_name = "foo"] -#![crate_type = "lib"] - -pub struct Foo { - pub some_func: for<'a> fn(val: &'a i32) -> i32, - pub some_trait: dyn for<'a> Trait<'a>, -} - -// @has foo/struct.Foo.html '//span[@id="structfield.some_func"]' "some_func: for<'a> fn(val: &'a i32) -> i32" -// @has foo/struct.Foo.html '//span[@id="structfield.some_trait"]' "some_trait: dyn Trait<'a>" - -pub trait Trait<'a> {} diff --git a/src/test/rustdoc/higher-ranked-trait-bounds.rs b/src/test/rustdoc/higher-ranked-trait-bounds.rs new file mode 100644 index 00000000000..41940b0884e --- /dev/null +++ b/src/test/rustdoc/higher-ranked-trait-bounds.rs @@ -0,0 +1,61 @@ +#![crate_name = "foo"] + +// @has foo/trait.Trait.html +pub trait Trait<'x> {} + +// @has foo/fn.test1.html +// @has - '//pre' "pub fn test1<T>() where for<'a> &'a T: Iterator," +pub fn test1<T>() +where + for<'a> &'a T: Iterator, +{ +} + +// @has foo/fn.test2.html +// @has - '//pre' "pub fn test2<T>() where for<'a, 'b> &'a T: Trait<'b>," +pub fn test2<T>() +where + for<'a, 'b> &'a T: Trait<'b>, +{ +} + +// @has foo/fn.test3.html +// @has - '//pre' "pub fn test3<F>() where F: for<'a, 'b> Fn(&'a u8, &'b u8)," +pub fn test3<F>() +where + F: for<'a, 'b> Fn(&'a u8, &'b u8), +{ +} + +// @has foo/struct.Foo.html +pub struct Foo<'a> { + _x: &'a u8, + pub some_trait: &'a dyn for<'b> Trait<'b>, + pub some_func: for<'c> fn(val: &'c i32) -> i32, +} + +// @has - '//span[@id="structfield.some_func"]' "some_func: for<'c> fn(val: &'c i32) -> i32" +// @has - '//span[@id="structfield.some_trait"]' "some_trait: &'a dyn for<'b> Trait<'b>" + +impl<'a> Foo<'a> { + // @has - '//code' "pub fn bar<T>() where T: Trait<'a>," + pub fn bar<T>() + where + T: Trait<'a>, + { + } +} + +// @has foo/trait.B.html +pub trait B<'x> {} + +// @has - '//code[@class="in-band"]' "impl<'a> B<'a> for dyn for<'b> Trait<'b>" +impl<'a> B<'a> for dyn for<'b> Trait<'b> {} + +// @has foo/struct.Bar.html +// @has - '//span[@id="structfield.bar"]' "bar: &'a (dyn for<'b> Trait<'b> + Unpin)" +// @has - '//span[@id="structfield.baz"]' "baz: &'a (dyn Unpin + for<'b> Trait<'b>)" +pub struct Bar<'a> { + pub bar: &'a (dyn for<'b> Trait<'b> + Unpin), + pub baz: &'a (dyn Unpin + for<'b> Trait<'b>), +} |
