diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index bb996e00d352..d0db6806c82f 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -160,6 +160,7 @@
// used for special search precedence
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
var TY_KEYWORD = itemTypes.indexOf("keyword");
+ var TY_MACRO = itemTypes.indexOf("macro");
onEach(document.getElementsByClassName('js-only'), function(e) {
removeClass(e, 'js-only');
@@ -465,9 +466,11 @@
var res = buildHrefAndPath(obj);
obj.displayPath = pathSplitter(res[0]);
obj.fullPath = obj.displayPath + obj.name;
+ // To be sure than it some items aren't considered as duplicate.
if (obj.ty === TY_KEYWORD) {
- // To be sure than it isn't considered as duplicate with items.
obj.fullPath += '|k';
+ } else if (obj.ty === TY_MACRO) {
+ obj.fullPath += '|m';
}
obj.href = res[1];
out.push(obj);
diff --git a/src/test/rustdoc-js/macro-check.js b/src/test/rustdoc-js/macro-check.js
new file mode 100644
index 000000000000..fb6168843334
--- /dev/null
+++ b/src/test/rustdoc-js/macro-check.js
@@ -0,0 +1,20 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-order
+
+const QUERY = 'panic';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'std', 'name': 'panic', ty: 14 }, // 15 is for macros
+ { 'path': 'std', 'name': 'panic', ty: 0 }, // 0 is for modules
+ ],
+};
diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js
index 3c1fceaf8faa..9567c4660048 100644
--- a/src/tools/rustdoc-js/tester.js
+++ b/src/tools/rustdoc-js/tester.js
@@ -233,7 +233,7 @@ function main(argv) {
var arraysToLoad = ["itemTypes"];
var variablesToLoad = ["MAX_LEV_DISTANCE", "MAX_RESULTS",
- "TY_PRIMITIVE", "TY_KEYWORD",
+ "TY_PRIMITIVE", "TY_KEYWORD", "TY_MACRO",
"levenshtein_row2"];
// execQuery first parameter is built in getQuery (which takes in the search input).
// execQuery last parameter is built in buildIndex.