about summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2021-07-10 14:58:36 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2021-07-10 14:58:36 +0200
commit8ccee61d38b94f868da9ae11ad5efd69d7a04072 (patch)
tree3d0e6e9190d658fedecb51b233f13f3b62629489 /src/librustdoc/html
parentac8c3bfffb2829d0af075a5d4020fb7e9e86c3a2 (diff)
downloadrust-8ccee61d38b94f868da9ae11ad5efd69d7a04072.tar.gz
rust-8ccee61d38b94f868da9ae11ad5efd69d7a04072.zip
Fix display for external trait implementors
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/static/js/main.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 98128878999..38ddbb3ad74 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -683,6 +683,9 @@ function hideThemeButtonState() {
             });
         }
 
+        var currentNbImpls = implementors.getElementsByClassName("impl").length;
+        var traitName = document.querySelector("h1.fqn > .in-band > .trait").textContent;
+        var baseIdName = "impl-" + traitName + "-";
         var libs = Object.getOwnPropertyNames(imp);
         for (var i = 0, llength = libs.length; i < llength; ++i) {
             if (libs[i] === window.currentCrate) { continue; }
@@ -705,6 +708,7 @@ function hideThemeButtonState() {
 
                 var code = document.createElement("code");
                 code.innerHTML = struct.text;
+                addClass(code, "in-band");
 
                 onEachLazy(code.getElementsByTagName("a"), function(elem) {
                     var href = elem.getAttribute("href");
@@ -714,12 +718,18 @@ function hideThemeButtonState() {
                     }
                 });
 
-                var display = document.createElement("h3");
+                var currentId = baseIdName + currentNbImpls;
+                var anchor = document.createElement("a");
+                anchor.href = "#" + currentId;
+                addClass(anchor, "anchor");
+
+                var display = document.createElement("div");
+                display.id = currentId;
                 addClass(display, "impl");
-                display.innerHTML = "<span class=\"in-band\"><table class=\"table-display\">" +
-                    "<tbody><tr><td><code>" + code.outerHTML + "</code></td><td></td></tr>" +
-                    "</tbody></table></span>";
+                display.appendChild(anchor);
+                display.appendChild(code);
                 list.appendChild(display);
+                currentNbImpls += 1;
             }
         }
     };