Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,13 @@ function defocusSearchBar() {
var aliases = [];
var crateAliases = [];
var i;
if (filterCrates !== undefined &&
ALIASES[filterCrates] &&
ALIASES[filterCrates][query.search]) {
for (i = 0; i < ALIASES[crate][query.search].length; ++i) {
aliases.push(
createAliasFromItem(searchIndex[ALIASES[filterCrates][query.search]]));
if (filterCrates !== undefined) {
if (ALIASES[filterCrates] && ALIASES[filterCrates][query.search]) {
for (i = 0; i < ALIASES[filterCrates][query.search].length; ++i) {
aliases.push(
createAliasFromItem(
searchIndex[ALIASES[filterCrates][query.search][i]]));
}
}
} else {
Object.keys(ALIASES).forEach(function(crate) {
Expand Down
9 changes: 9 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter-out.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// exact-check

const QUERY = 'true';

const FILTER_CRATE = 'some_other_crate';

const EXPECTED = {
'others': [],
};
4 changes: 4 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter-out.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(doc_alias)]

#[doc(alias = "true")]
pub struct Foo;
17 changes: 17 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// exact-check

const QUERY = 'true';

const FILTER_CRATE = 'doc_alias_filter';

const EXPECTED = {
'others': [
{
'path': 'doc_alias_filter',
'name': 'Foo',
'alias': 'true',
'href': '../doc_alias_filter/struct.Foo.html',
'is_alias': true
},
],
};
7 changes: 7 additions & 0 deletions src/test/rustdoc-js/doc-alias-filter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![feature(doc_alias)]

#[doc(alias = "true")]
pub struct Foo;

#[doc(alias = "false")]
pub struct Bar;
13 changes: 11 additions & 2 deletions src/tools/rustdoc-js/tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,12 @@ function runSearch(query, expected, index, loaded, loadedFile, queryName) {
break;
}
var entry = expected[key];

if (exact_check == true && entry.length !== results[key].length) {
error_text.push(queryName + "==> Expected exactly " + entry.length +
" results but found " + results[key].length + " in '" + key + "'");
}

var prev_pos = -1;
for (var i = 0; i < entry.length; ++i) {
var entry_pos = lookForEntry(entry[i], results[key]);
Expand Down Expand Up @@ -307,8 +313,11 @@ function checkResult(error_text, loadedFile, displaySuccess) {
}

function runChecks(testFile, loaded, index) {
var loadedFile = loadContent(
readFile(testFile) + 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
var testFileContent = readFile(testFile) + 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;';
if (testFileContent.indexOf("FILTER_CRATE") !== -1) {
testFileContent += "exports.FILTER_CRATE = FILTER_CRATE;";
}
var loadedFile = loadContent(testFileContent);

const expected = loadedFile.EXPECTED;
const query = loadedFile.QUERY;
Expand Down