diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index c9b8100fd03784b6fa01092b188fa46aefa42fd2..d5071cec0c83db878b9f3520f65b5fdc029391a9 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1548,9 +1548,9 @@ function defocusSearchBar() {
} else if (type === "structfield" && parentType === "variant") {
// Structfields belonging to variants are special: the
// final path element is the enum name.
- var splitPath = item.path.split("::");
- var enumName = splitPath.pop();
- path = splitPath.join("::");
+ var enumNameIdx = item.path.lastIndexOf("::");
+ var enumName = item.path.substr(enumNameIdx + 2);
+ path = item.path.substr(0, enumNameIdx);
displayPath = path + "::" + enumName + "::" + myparent.name + "::";
anchor = "#variant." + myparent.name + ".field." + name;
pageType = "enum";