Skip to content

Commit d105f61

Browse files
GuillaumeGomezpietroalbini
authored andcommitted
Fix macro missing from doc search
1 parent 8049c11 commit d105f61

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/librustdoc/html/static/main.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
// used for special search precedence
161161
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
162162
var TY_KEYWORD = itemTypes.indexOf("keyword");
163+
var TY_MACRO = itemTypes.indexOf("macro");
163164

164165
onEach(document.getElementsByClassName('js-only'), function(e) {
165166
removeClass(e, 'js-only');
@@ -465,9 +466,11 @@
465466
var res = buildHrefAndPath(obj);
466467
obj.displayPath = pathSplitter(res[0]);
467468
obj.fullPath = obj.displayPath + obj.name;
469+
// To be sure than it some items aren't considered as duplicate.
468470
if (obj.ty === TY_KEYWORD) {
469-
// To be sure than it isn't considered as duplicate with items.
470471
obj.fullPath += '|k';
472+
} else if (obj.ty === TY_MACRO) {
473+
obj.fullPath += '|m';
471474
}
472475
obj.href = res[1];
473476
out.push(obj);

src/test/rustdoc-js/macro-check.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-order
12+
13+
const QUERY = 'panic';
14+
15+
const EXPECTED = {
16+
'others': [
17+
{ 'path': 'std', 'name': 'panic', ty: 14 }, // 15 is for macros
18+
{ 'path': 'std', 'name': 'panic', ty: 0 }, // 0 is for modules
19+
],
20+
};

src/tools/rustdoc-js/tester.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function main(argv) {
233233

234234
var arraysToLoad = ["itemTypes"];
235235
var variablesToLoad = ["MAX_LEV_DISTANCE", "MAX_RESULTS",
236-
"TY_PRIMITIVE", "TY_KEYWORD",
236+
"TY_PRIMITIVE", "TY_KEYWORD", "TY_MACRO",
237237
"levenshtein_row2"];
238238
// execQuery first parameter is built in getQuery (which takes in the search input).
239239
// execQuery last parameter is built in buildIndex.

0 commit comments

Comments
 (0)