From 446285e45c02f71392c7084328dc167d2e1ff58c Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Thu, 5 Apr 2018 18:12:01 +0100 Subject: [PATCH 1/8] Removed 'proc' from the reserved keywords list --- src/libsyntax_pos/symbol.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 0cba094da641d..7ab4ac9794d9f 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -314,7 +314,6 @@ declare_keywords! { (46, Offsetof, "offsetof") (47, Override, "override") (48, Priv, "priv") - (49, Proc, "proc") (50, Pure, "pure") (51, Sizeof, "sizeof") (52, Typeof, "typeof") From 16e75e356603dac9c01711945790aa08fd7b415e Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 11 Apr 2018 13:27:43 +0100 Subject: [PATCH 2/8] Reenumerated symbols --- src/libsyntax_pos/symbol.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index ce269e69b8b1c..ff36cb06ec43a 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -318,23 +318,23 @@ declare_keywords! { (46, Offsetof, "offsetof") (47, Override, "override") (48, Priv, "priv") - (50, Pure, "pure") - (51, Sizeof, "sizeof") - (52, Typeof, "typeof") - (53, Unsized, "unsized") - (54, Virtual, "virtual") - (55, Yield, "yield") + (49, Pure, "pure") + (50, Sizeof, "sizeof") + (51, Typeof, "typeof") + (52, Unsized, "unsized") + (53, Virtual, "virtual") + (54, Yield, "yield") // Special lifetime names - (56, UnderscoreLifetime, "'_") - (57, StaticLifetime, "'static") + (55, UnderscoreLifetime, "'_") + (56, StaticLifetime, "'static") // Weak keywords, have special meaning only in specific contexts. - (58, Auto, "auto") - (59, Catch, "catch") - (60, Default, "default") - (61, Dyn, "dyn") - (62, Union, "union") + (57, Auto, "auto") + (58, Catch, "catch") + (59, Default, "default") + (60, Dyn, "dyn") + (61, Union, "union") } // If an interner exists, return it. Otherwise, prepare a fresh one. From 7f58d2ff6621911d25c5e84d32fde53e47494506 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 11 Apr 2018 15:14:32 +0100 Subject: [PATCH 3/8] Removed proc test --- src/test/parse-fail/obsolete-proc.rs | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 src/test/parse-fail/obsolete-proc.rs diff --git a/src/test/parse-fail/obsolete-proc.rs b/src/test/parse-fail/obsolete-proc.rs deleted file mode 100644 index 648c46d246cbc..0000000000000 --- a/src/test/parse-fail/obsolete-proc.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 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. - -// compile-flags: -Z parse-only - -// Test that we generate obsolete syntax errors around usages of `proc`. - -fn foo(p: proc()) { } //~ ERROR expected type, found reserved keyword `proc` - -fn bar() { proc() 1; } //~ ERROR expected expression, found reserved keyword `proc` - -fn main() { } From abded6111bcdaf53a74abb5188d81708180a364f Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Fri, 13 Apr 2018 14:58:43 +0100 Subject: [PATCH 4/8] rustdoc: Don't include private paths in all.html --- src/librustdoc/html/render.rs | 4 +++- src/test/rustdoc/all.rs | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 9e2c7bd7ef1ed..586d889722c17 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1728,7 +1728,9 @@ impl Context { let mut dst = try_err!(File::create(&joint_dst), &joint_dst); try_err!(dst.write_all(&buf), &joint_dst); - all.append(full_path(self, &item), &item_type); + if !self.render_redirect_pages { + all.append(full_path(self, &item), &item_type); + } // Redirect from a sane URL using the namespace to Rustdoc's // URL for the page. let redir_name = format!("{}.{}.html", name, item_type.name_space()); diff --git a/src/test/rustdoc/all.rs b/src/test/rustdoc/all.rs index ec391319b183c..1969cf859eee4 100644 --- a/src/test/rustdoc/all.rs +++ b/src/test/rustdoc/all.rs @@ -28,3 +28,11 @@ pub union Union { pub const CONST: u32 = 0; pub static STATIC: &str = "baguette"; pub fn function() {} + +mod private_module { + pub struct ReexportedStruct; +} + +// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct' +// @!has foo/all.html 'private_module' +pub use private_module::ReexportedStruct; From 47a9ffa573aac587b7d045177a4f05bd649261e3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 14 Apr 2018 17:01:28 +0200 Subject: [PATCH 5/8] Add multi-query search --- src/librustdoc/html/static/main.js | 77 +++++++++++++++++++++++++++--- src/test/rustdoc-js/multi-query.js | 20 ++++++++ src/tools/rustdoc-js/tester.js | 5 +- 3 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 src/test/rustdoc-js/multi-query.js diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 3a3fa833c238b..2546a9410a9f6 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1299,14 +1299,78 @@ printTab(currentTab); } + function execSearch(query, searchWords) { + var queries = query.raw.split(","); + var results = { + 'in_args': [], + 'returned': [], + 'others': [], + }; + + for (var i = 0; i < queries.length; ++i) { + var query = queries[i].trim(); + if (query.length !== 0) { + var tmp = execQuery(getQuery(query), searchWords); + + results['in_args'].push(tmp['in_args']); + results['returned'].push(tmp['returned']); + results['others'].push(tmp['others']); + } + } + if (queries.length > 1) { + function getSmallest(arrays, positions) { + var start = null; + + for (var it = 0; it < positions.length; ++it) { + if (arrays[it].length > positions[it] && + (start === null || start > arrays[it][positions[it]].lev)) { + start = arrays[it][positions[it]].lev; + } + } + return start; + } + + function mergeArrays(arrays) { + var ret = []; + var positions = []; + + for (var x = 0; x < arrays.length; ++x) { + positions.push(0); + } + while (ret.length < MAX_RESULTS) { + var smallest = getSmallest(arrays, positions); + if (smallest === null) { + break; + } + for (x = 0; x < arrays.length && ret.length < MAX_RESULTS; ++x) { + if (arrays[x].length > positions[x] && + arrays[x][positions[x]].lev === smallest) { + ret.push(arrays[x][positions[x]]); + positions[x] += 1; + } + } + } + return ret; + } + + return { + 'in_args': mergeArrays(results['in_args']), + 'returned': mergeArrays(results['returned']), + 'others': mergeArrays(results['others']), + }; + } else { + return { + 'in_args': results['in_args'][0], + 'returned': results['returned'][0], + 'others': results['others'][0], + }; + } + } + function search(e) { - var query, - obj, i, len, - results = {"in_args": [], "returned": [], "others": []}, - resultIndex; var params = getQueryStringParams(); + var query = getQuery(document.getElementsByClassName('search-input')[0].value); - query = getQuery(document.getElementsByClassName('search-input')[0].value); if (e) { e.preventDefault(); } @@ -1328,8 +1392,7 @@ } } - results = execQuery(query, index); - showResults(results); + showResults(execSearch(query, index)); } function buildIndex(rawSearchIndex) { diff --git a/src/test/rustdoc-js/multi-query.js b/src/test/rustdoc-js/multi-query.js new file mode 100644 index 0000000000000..3793ca6599c5f --- /dev/null +++ b/src/test/rustdoc-js/multi-query.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. + +const QUERY = 'str,u8'; + +const EXPECTED = { + 'others': [ + { 'path': 'std', 'name': 'str' }, + { 'path': 'std', 'name': 'u8' }, + { 'path': 'std::ffi', 'name': 'CStr' }, + { 'path': 'std::simd', 'name': 'u8x2' }, + ], +}; diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index 7c9ee2a49430b..1e6c4336a9e99 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -157,7 +157,8 @@ function main(argv) { // execQuery first parameter is built in getQuery (which takes in the search input). // execQuery last parameter is built in buildIndex. // buildIndex requires the hashmap from search-index. - var functionsToLoad = ["levenshtein", "validateResult", "getQuery", "buildIndex", "execQuery"]; + var functionsToLoad = ["levenshtein", "validateResult", "getQuery", "buildIndex", "execQuery", + "execSearch"]; finalJS += 'window = { "currentCrate": "std" };\n'; finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs); @@ -174,7 +175,7 @@ function main(argv) { 'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;'); const expected = loadedFile.EXPECTED; const query = loadedFile.QUERY; - var results = loaded.execQuery(loaded.getQuery(query), index); + var results = loaded.execSearch(loaded.getQuery(query), index); process.stdout.write('Checking "' + file + '" ... '); var error_text = []; for (var key in expected) { From d08f8978e7b883cb01ec8f1118b5eeb3ebc94ab4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 14 Apr 2018 17:13:46 +0200 Subject: [PATCH 6/8] Small size reduction --- src/librustdoc/html/layout.rs | 228 ++++++++++++++++------------------ 1 file changed, 106 insertions(+), 122 deletions(-) diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index aac5d0d2601de..88d28323e1ac5 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -37,128 +37,112 @@ pub fn render( -> io::Result<()> { write!(dst, -r##" - - - - - - - - - {title} - - - - {themes} - - - - {css_extension} - - {favicon} - {in_header} - - - - - {before_content} - - - -
- -
-
- - - -
{content}
- - - - - - - {after_content} - - - - - -"##, +"\ +\ +\ + \ + \ + \ + \ + \ + {title}\ + \ + \ + {themes}\ + \ + \ + \ + {css_extension}\ + {favicon}\ + {in_header}\ +\ +\ + \ + {before_content}\ + \ +
\ + \ +
\ +
\ + \ + \ +
{content}
\ +
\ +
\ + \ + {after_content}\ + \ + \ + \ +\ +", css_extension = if css_file_extension { format!("", root_path = page.root_path, From c83c7c91f5eaeef349d356bfb3272d619ac54401 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 14 Apr 2018 17:20:36 +0200 Subject: [PATCH 7/8] Add doc --- src/librustdoc/html/layout.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 88d28323e1ac5..583c9f2b67144 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -131,6 +131,10 @@ pub fn render( Search functions by type signature (e.g. \ vec -> usize or * -> vec)\

\ +

\ + Search multiple things at once by splitting your query with comma (e.g. \ + str,u8 or String,struct:Vec,test)\ +

\ \ \ \ From 01e8bebaf1964331a5704b5ee65adc216a923f0e Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 17 Apr 2018 10:23:06 +0900 Subject: [PATCH 8/8] Remove no longer necessary comparison to Vec::splice. `String::replace_range` was previously called `String::splice`, so this note was necessary to differentiate it from the `Vec` method. Now that it's renamed, this note no longer seems necessary. --- src/liballoc/string.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 11fb82c09d3aa..2f84d5f7f8676 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -1521,9 +1521,6 @@ impl String { /// and replaces it with the given string. /// The given string doesn't need to be the same length as the range. /// - /// Note: Unlike [`Vec::splice`], the replacement happens eagerly, and this - /// method does not return the removed chars. - /// /// # Panics /// /// Panics if the starting point or end point do not lie on a [`char`]