Skip to content

Commit

Permalink
Auto merge of #47492 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 6 pull requests

- Successful merges: #47250, #47302, #47387, #47398, #47436, #47444
- Failed merges:
  • Loading branch information
bors committed Jan 17, 2018
2 parents da569fa + 83b8946 commit 2d3558e
Show file tree
Hide file tree
Showing 21 changed files with 465 additions and 73 deletions.
6 changes: 3 additions & 3 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ impl<'a> Builder<'a> {
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Rustdoc,
check::Linkcheck, check::Cargotest, check::Cargo, check::Rls, check::Docs,
check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy),
check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy,
check::RustdocJS),

Kind::Bench => describe!(check::Crate, check::CrateLibrustc),
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon,
Expand Down Expand Up @@ -443,7 +445,8 @@ impl<'a> Builder<'a> {
let out_dir = self.stage_out(compiler, mode);
cargo.env("CARGO_TARGET_DIR", out_dir)
.arg(cmd)
.arg("--target").arg(target);
.arg("--target")
.arg(target);

// If we were invoked from `make` then that's already got a jobserver
// set up for us so no need to tell Cargo about jobs all over again.
Expand Down
37 changes: 37 additions & 0 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,43 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
}

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocJS {
pub host: Interned<String>,
pub target: Interned<String>,
}

impl Step for RustdocJS {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;

fn should_run(run: ShouldRun) -> ShouldRun {
run.path("src/test/rustdoc-js")
}

fn make_run(run: RunConfig) {
run.builder.ensure(RustdocJS {
host: run.host,
target: run.target,
});
}

fn run(self, builder: &Builder) {
if let Some(ref nodejs) = builder.config.nodejs {
let mut command = Command::new(nodejs);
command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
builder.ensure(::doc::Std {
target: self.target,
stage: builder.top_stage,
});
builder.run(&mut command);
} else {
println!("No nodejs found, skipping \"src/test/rustdoc-js\" tests");
}
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct Tidy {
host: Interned<String>,
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ impl Step for Standalone {

#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Std {
stage: u32,
target: Interned<String>,
pub stage: u32,
pub target: Interned<String>,
}

impl Step for Std {
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,7 @@ impl<'a> Resolver<'a> {
if let Some(suggestion) = suggestion {
if suggestion != name {
if let MacroKind::Bang = kind {
err.span_suggestion(span, "you could try the macro",
format!("{}!", suggestion));
err.span_suggestion(span, "you could try the macro", suggestion.to_string());
} else {
err.span_suggestion(span, "try", suggestion.to_string());
}
Expand Down
13 changes: 4 additions & 9 deletions src/librustc_trans/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,15 +1360,10 @@ fn start_executing_work(tcx: TyCtxt,
let sess = tcx.sess;

// First up, convert our jobserver into a helper thread so we can use normal
// mpsc channels to manage our messages and such. Once we've got the helper
// thread then request `n-1` tokens because all of our work items are ready
// to go.
//
// Note that the `n-1` is here because we ourselves have a token (our
// process) and we'll use that token to execute at least one unit of work.
//
// After we've requested all these tokens then we'll, when we can, get
// tokens on `rx` above which will get managed in the main loop below.
// mpsc channels to manage our messages and such.
// After we've requested tokens then we'll, when we can,
// get tokens on `coordinator_receive` which will
// get managed in the main loop below.
let coordinator_send2 = coordinator_send.clone();
let helper = jobserver.into_helper_thread(move |token| {
drop(coordinator_send2.send(Box::new(Message::Token(token))));
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctest = false

[dependencies]
pulldown-cmark = { version = "0.1.0", default-features = false }
html-diff = "0.0.5"
html-diff = "0.0.6"
tempdir = "0.3"

[build-dependencies]
Expand Down
82 changes: 39 additions & 43 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,35 +353,33 @@
* This code is an unmodified version of the code written by Marco de Wit
* and was found at http://stackoverflow.com/a/18514751/745719
*/
var levenshtein = (function() {
var row2 = [];
return function(s1, s2) {
if (s1 === s2) {
return 0;
var levenshtein_row2 = [];
function levenshtein(s1, s2) {
if (s1 === s2) {
return 0;
}
var s1_len = s1.length, s2_len = s2.length;
if (s1_len && s2_len) {
var i1 = 0, i2 = 0, a, b, c, c2, row = levenshtein_row2;
while (i1 < s1_len) {
row[i1] = ++i1;
}
var s1_len = s1.length, s2_len = s2.length;
if (s1_len && s2_len) {
var i1 = 0, i2 = 0, a, b, c, c2, row = row2;
while (i1 < s1_len) {
row[i1] = ++i1;
}
while (i2 < s2_len) {
c2 = s2.charCodeAt(i2);
a = i2;
++i2;
b = i2;
for (i1 = 0; i1 < s1_len; ++i1) {
c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0);
a = row[i1];
b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c);
row[i1] = b;
}
while (i2 < s2_len) {
c2 = s2.charCodeAt(i2);
a = i2;
++i2;
b = i2;
for (i1 = 0; i1 < s1_len; ++i1) {
c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0);
a = row[i1];
b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c);
row[i1] = b;
}
return b;
}
return s1_len + s2_len;
};
})();
return b;
}
return s1_len + s2_len;
}

function initSearch(rawSearchIndex) {
var currentResults, index, searchIndex;
Expand All @@ -400,12 +398,20 @@
/**
* Executes the query and builds an index of results
* @param {[Object]} query [The user query]
* @param {[type]} max [The maximum results returned]
* @param {[type]} searchWords [The list of search words to query
* against]
* @return {[type]} [A search index of results]
*/
function execQuery(query, max, searchWords) {
function execQuery(query, searchWords) {
function itemTypeFromName(typename) {
for (var i = 0; i < itemTypes.length; ++i) {
if (itemTypes[i] === typename) {
return i;
}
}
return -1;
}

var valLower = query.query.toLowerCase(),
val = valLower,
typeFilter = itemTypeFromName(query.type),
Expand Down Expand Up @@ -1021,9 +1027,8 @@
return true;
}

function getQuery() {
var matches, type, query, raw =
document.getElementsByClassName('search-input')[0].value;
function getQuery(raw) {
var matches, type, query;
query = raw;

matches = query.match(/^(fn|mod|struct|enum|trait|type|const|macro)\s*:\s*/i);
Expand Down Expand Up @@ -1227,7 +1232,7 @@
}

function showResults(results) {
var output, query = getQuery();
var output, query = getQuery(document.getElementsByClassName('search-input')[0].value);

currentResults = query.id;
output = '<h1>Results for ' + escape(query.query) +
Expand Down Expand Up @@ -1271,7 +1276,7 @@
resultIndex;
var params = getQueryStringParams();

query = getQuery();
query = getQuery(document.getElementsByClassName('search-input')[0].value);
if (e) {
e.preventDefault();
}
Expand All @@ -1293,19 +1298,10 @@
}
}

results = execQuery(query, 20000, index);
results = execQuery(query, index);
showResults(results);
}

function itemTypeFromName(typename) {
for (var i = 0; i < itemTypes.length; ++i) {
if (itemTypes[i] === typename) {
return i;
}
}
return -1;
}

function buildIndex(rawSearchIndex) {
searchIndex = [];
var searchWords = [];
Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,8 @@ pub fn opts() -> Vec<RustcOptGroup> {
or `#![doc(html_playground_url=...)]`",
"URL")
}),
unstable("enable-commonmark", |o| {
o.optflag("", "enable-commonmark", "to enable commonmark doc rendering/testing")
unstable("disable-commonmark", |o| {
o.optflag("", "disable-commonmark", "to disable commonmark doc rendering/testing")
}),
unstable("display-warnings", |o| {
o.optflag("", "display-warnings", "to print code warnings when testing doc")
Expand Down Expand Up @@ -347,10 +347,10 @@ pub fn main_args(args: &[String]) -> isize {
let css_file_extension = matches.opt_str("e").map(|s| PathBuf::from(&s));
let cfgs = matches.opt_strs("cfg");

let render_type = if matches.opt_present("enable-commonmark") {
RenderType::Pulldown
} else {
let render_type = if matches.opt_present("disable-commonmark") {
RenderType::Hoedown
} else {
RenderType::Pulldown
};

if let Some(ref p) = css_file_extension {
Expand Down
25 changes: 25 additions & 0 deletions src/test/rustdoc-js/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const QUERY = 'String';

const EXPECTED = {
'others': [
{ 'path': 'std::string', 'name': 'String' },
{ 'path': 'std::ffi', 'name': 'OsString' },
{ 'path': 'std::ffi', 'name': 'CString' },
],
'in_args': [
{ 'path': 'std::str', 'name': 'eq' },
],
'returned': [
{ 'path': 'std::string::String', 'name': 'add' },
],
};
17 changes: 17 additions & 0 deletions src/test/rustdoc-js/enum-option.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const QUERY = 'enum:Option';

const EXPECTED = {
'others': [
{ 'path': 'std::option', 'name': 'Option' },
],
};
18 changes: 18 additions & 0 deletions src/test/rustdoc-js/fn-forget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const QUERY = 'fn:forget';

const EXPECTED = {
'others': [
{ 'path': 'std::mem', 'name': 'forget' },
{ 'path': 'std::fmt', 'name': 'format' },
],
};
22 changes: 22 additions & 0 deletions src/test/rustdoc-js/from_u.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

const QUERY = 'from_u';

const EXPECTED = {
'others': [
{ 'path': 'std::char', 'name': 'from_u32' },
{ 'path': 'std::str', 'name': 'from_utf8' },
{ 'path': 'std::string::String', 'name': 'from_utf8' },
{ 'path': 'std::boxed::Box', 'name': 'from_unique' },
{ 'path': 'std::i32', 'name': 'from_unsigned' },
{ 'path': 'std::i128', 'name': 'from_unsigned' },
],
};
Loading

0 comments on commit 2d3558e

Please sign in to comment.