about summary refs log tree commit diff
path: root/src/librustdoc/formats
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-06-26 10:52:16 +0000
committerbors <bors@rust-lang.org>2021-06-26 10:52:16 +0000
commit831ae3c1364b7b033bd1da430bc1cb86d93ad186 (patch)
tree32db4a7d7858a85aefba7d95d4e728858b1ebee1 /src/librustdoc/formats
parent481971978fda83aa7cf1f1f3c80cfad822377cf2 (diff)
parent4ea27484c9582389cded2301d1f0dd4f421c8c35 (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>`
![image](https://user-images.githubusercontent.com/39732259/116808426-fe6ce600-ab38-11eb-9452-f33f554fbb8e.png)

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/librustdoc/formats')
-rw-r--r--src/librustdoc/formats/cache.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs
index c9682bd84f7..1e1fc2436aa 100644
--- a/src/librustdoc/formats/cache.rs
+++ b/src/librustdoc/formats/cache.rs
@@ -402,6 +402,15 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
                         self.cache.parent_stack.push(did);
                         true
                     }
+                    clean::DynTrait(ref bounds, _)
+                    | clean::BorrowedRef { type_: box clean::DynTrait(ref bounds, _), .. } => {
+                        if let Some(did) = bounds[0].trait_.def_id() {
+                            self.cache.parent_stack.push(did);
+                            true
+                        } else {
+                            false
+                        }
+                    }
                     ref t => {
                         let prim_did = t
                             .primitive_type()
@@ -432,6 +441,12 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
                 | clean::BorrowedRef { type_: box clean::ResolvedPath { did, .. }, .. } => {
                     dids.insert(did);
                 }
+                clean::DynTrait(ref bounds, _)
+                | clean::BorrowedRef { type_: box clean::DynTrait(ref bounds, _), .. } => {
+                    if let Some(did) = bounds[0].trait_.def_id() {
+                        dids.insert(did);
+                    }
+                }
                 ref t => {
                     let did = t
                         .primitive_type()