Skip to content

Commit 047132d

Browse files
committed
Auto merge of #47492 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 6 pull requests - Successful merges: #47250, #47302, #47387, #47398, #47436, #47444 - Failed merges:
2 parents da569fa + 83b8946 commit 047132d

File tree

21 files changed

+465
-73
lines changed

21 files changed

+465
-73
lines changed

src/Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/builder.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ impl<'a> Builder<'a> {
254254
Kind::Test => describe!(check::Tidy, check::Bootstrap, check::DefaultCompiletest,
255255
check::HostCompiletest, check::Crate, check::CrateLibrustc, check::Rustdoc,
256256
check::Linkcheck, check::Cargotest, check::Cargo, check::Rls, check::Docs,
257-
check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy),
257+
check::ErrorIndex, check::Distcheck, check::Rustfmt, check::Miri, check::Clippy,
258+
check::RustdocJS),
259+
258260
Kind::Bench => describe!(check::Crate, check::CrateLibrustc),
259261
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
260262
doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon,
@@ -443,7 +445,8 @@ impl<'a> Builder<'a> {
443445
let out_dir = self.stage_out(compiler, mode);
444446
cargo.env("CARGO_TARGET_DIR", out_dir)
445447
.arg(cmd)
446-
.arg("--target").arg(target);
448+
.arg("--target")
449+
.arg(target);
447450

448451
// If we were invoked from `make` then that's already got a jobserver
449452
// set up for us so no need to tell Cargo about jobs all over again.

src/bootstrap/check.rs

+37
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,43 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
424424
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
425425
}
426426

427+
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
428+
pub struct RustdocJS {
429+
pub host: Interned<String>,
430+
pub target: Interned<String>,
431+
}
432+
433+
impl Step for RustdocJS {
434+
type Output = ();
435+
const DEFAULT: bool = true;
436+
const ONLY_HOSTS: bool = true;
437+
438+
fn should_run(run: ShouldRun) -> ShouldRun {
439+
run.path("src/test/rustdoc-js")
440+
}
441+
442+
fn make_run(run: RunConfig) {
443+
run.builder.ensure(RustdocJS {
444+
host: run.host,
445+
target: run.target,
446+
});
447+
}
448+
449+
fn run(self, builder: &Builder) {
450+
if let Some(ref nodejs) = builder.config.nodejs {
451+
let mut command = Command::new(nodejs);
452+
command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
453+
builder.ensure(::doc::Std {
454+
target: self.target,
455+
stage: builder.top_stage,
456+
});
457+
builder.run(&mut command);
458+
} else {
459+
println!("No nodejs found, skipping \"src/test/rustdoc-js\" tests");
460+
}
461+
}
462+
}
463+
427464
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
428465
pub struct Tidy {
429466
host: Interned<String>,

src/bootstrap/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ impl Step for Standalone {
419419

420420
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
421421
pub struct Std {
422-
stage: u32,
423-
target: Interned<String>,
422+
pub stage: u32,
423+
pub target: Interned<String>,
424424
}
425425

426426
impl Step for Std {

src/librustc_resolve/macros.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,7 @@ impl<'a> Resolver<'a> {
691691
if let Some(suggestion) = suggestion {
692692
if suggestion != name {
693693
if let MacroKind::Bang = kind {
694-
err.span_suggestion(span, "you could try the macro",
695-
format!("{}!", suggestion));
694+
err.span_suggestion(span, "you could try the macro", suggestion.to_string());
696695
} else {
697696
err.span_suggestion(span, "try", suggestion.to_string());
698697
}

src/librustc_trans/back/write.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1360,15 +1360,10 @@ fn start_executing_work(tcx: TyCtxt,
13601360
let sess = tcx.sess;
13611361

13621362
// First up, convert our jobserver into a helper thread so we can use normal
1363-
// mpsc channels to manage our messages and such. Once we've got the helper
1364-
// thread then request `n-1` tokens because all of our work items are ready
1365-
// to go.
1366-
//
1367-
// Note that the `n-1` is here because we ourselves have a token (our
1368-
// process) and we'll use that token to execute at least one unit of work.
1369-
//
1370-
// After we've requested all these tokens then we'll, when we can, get
1371-
// tokens on `rx` above which will get managed in the main loop below.
1363+
// mpsc channels to manage our messages and such.
1364+
// After we've requested tokens then we'll, when we can,
1365+
// get tokens on `coordinator_receive` which will
1366+
// get managed in the main loop below.
13721367
let coordinator_send2 = coordinator_send.clone();
13731368
let helper = jobserver.into_helper_thread(move |token| {
13741369
drop(coordinator_send2.send(Box::new(Message::Token(token))));

src/librustdoc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212

1313
[dependencies]
1414
pulldown-cmark = { version = "0.1.0", default-features = false }
15-
html-diff = "0.0.5"
15+
html-diff = "0.0.6"
1616
tempdir = "0.3"
1717

1818
[build-dependencies]

src/librustdoc/html/static/main.js

+39-43
Original file line numberDiff line numberDiff line change
@@ -353,35 +353,33 @@
353353
* This code is an unmodified version of the code written by Marco de Wit
354354
* and was found at http://stackoverflow.com/a/18514751/745719
355355
*/
356-
var levenshtein = (function() {
357-
var row2 = [];
358-
return function(s1, s2) {
359-
if (s1 === s2) {
360-
return 0;
356+
var levenshtein_row2 = [];
357+
function levenshtein(s1, s2) {
358+
if (s1 === s2) {
359+
return 0;
360+
}
361+
var s1_len = s1.length, s2_len = s2.length;
362+
if (s1_len && s2_len) {
363+
var i1 = 0, i2 = 0, a, b, c, c2, row = levenshtein_row2;
364+
while (i1 < s1_len) {
365+
row[i1] = ++i1;
361366
}
362-
var s1_len = s1.length, s2_len = s2.length;
363-
if (s1_len && s2_len) {
364-
var i1 = 0, i2 = 0, a, b, c, c2, row = row2;
365-
while (i1 < s1_len) {
366-
row[i1] = ++i1;
367-
}
368-
while (i2 < s2_len) {
369-
c2 = s2.charCodeAt(i2);
370-
a = i2;
371-
++i2;
372-
b = i2;
373-
for (i1 = 0; i1 < s1_len; ++i1) {
374-
c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0);
375-
a = row[i1];
376-
b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c);
377-
row[i1] = b;
378-
}
367+
while (i2 < s2_len) {
368+
c2 = s2.charCodeAt(i2);
369+
a = i2;
370+
++i2;
371+
b = i2;
372+
for (i1 = 0; i1 < s1_len; ++i1) {
373+
c = a + (s1.charCodeAt(i1) !== c2 ? 1 : 0);
374+
a = row[i1];
375+
b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c);
376+
row[i1] = b;
379377
}
380-
return b;
381378
}
382-
return s1_len + s2_len;
383-
};
384-
})();
379+
return b;
380+
}
381+
return s1_len + s2_len;
382+
}
385383

386384
function initSearch(rawSearchIndex) {
387385
var currentResults, index, searchIndex;
@@ -400,12 +398,20 @@
400398
/**
401399
* Executes the query and builds an index of results
402400
* @param {[Object]} query [The user query]
403-
* @param {[type]} max [The maximum results returned]
404401
* @param {[type]} searchWords [The list of search words to query
405402
* against]
406403
* @return {[type]} [A search index of results]
407404
*/
408-
function execQuery(query, max, searchWords) {
405+
function execQuery(query, searchWords) {
406+
function itemTypeFromName(typename) {
407+
for (var i = 0; i < itemTypes.length; ++i) {
408+
if (itemTypes[i] === typename) {
409+
return i;
410+
}
411+
}
412+
return -1;
413+
}
414+
409415
var valLower = query.query.toLowerCase(),
410416
val = valLower,
411417
typeFilter = itemTypeFromName(query.type),
@@ -1021,9 +1027,8 @@
10211027
return true;
10221028
}
10231029

1024-
function getQuery() {
1025-
var matches, type, query, raw =
1026-
document.getElementsByClassName('search-input')[0].value;
1030+
function getQuery(raw) {
1031+
var matches, type, query;
10271032
query = raw;
10281033

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

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

12321237
currentResults = query.id;
12331238
output = '<h1>Results for ' + escape(query.query) +
@@ -1271,7 +1276,7 @@
12711276
resultIndex;
12721277
var params = getQueryStringParams();
12731278

1274-
query = getQuery();
1279+
query = getQuery(document.getElementsByClassName('search-input')[0].value);
12751280
if (e) {
12761281
e.preventDefault();
12771282
}
@@ -1293,19 +1298,10 @@
12931298
}
12941299
}
12951300

1296-
results = execQuery(query, 20000, index);
1301+
results = execQuery(query, index);
12971302
showResults(results);
12981303
}
12991304

1300-
function itemTypeFromName(typename) {
1301-
for (var i = 0; i < itemTypes.length; ++i) {
1302-
if (itemTypes[i] === typename) {
1303-
return i;
1304-
}
1305-
}
1306-
return -1;
1307-
}
1308-
13091305
function buildIndex(rawSearchIndex) {
13101306
searchIndex = [];
13111307
var searchWords = [];

src/librustdoc/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ pub fn opts() -> Vec<RustcOptGroup> {
242242
or `#![doc(html_playground_url=...)]`",
243243
"URL")
244244
}),
245-
unstable("enable-commonmark", |o| {
246-
o.optflag("", "enable-commonmark", "to enable commonmark doc rendering/testing")
245+
unstable("disable-commonmark", |o| {
246+
o.optflag("", "disable-commonmark", "to disable commonmark doc rendering/testing")
247247
}),
248248
unstable("display-warnings", |o| {
249249
o.optflag("", "display-warnings", "to print code warnings when testing doc")
@@ -347,10 +347,10 @@ pub fn main_args(args: &[String]) -> isize {
347347
let css_file_extension = matches.opt_str("e").map(|s| PathBuf::from(&s));
348348
let cfgs = matches.opt_strs("cfg");
349349

350-
let render_type = if matches.opt_present("enable-commonmark") {
351-
RenderType::Pulldown
352-
} else {
350+
let render_type = if matches.opt_present("disable-commonmark") {
353351
RenderType::Hoedown
352+
} else {
353+
RenderType::Pulldown
354354
};
355355

356356
if let Some(ref p) = css_file_extension {

src/test/rustdoc-js/basic.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
const QUERY = 'String';
12+
13+
const EXPECTED = {
14+
'others': [
15+
{ 'path': 'std::string', 'name': 'String' },
16+
{ 'path': 'std::ffi', 'name': 'OsString' },
17+
{ 'path': 'std::ffi', 'name': 'CString' },
18+
],
19+
'in_args': [
20+
{ 'path': 'std::str', 'name': 'eq' },
21+
],
22+
'returned': [
23+
{ 'path': 'std::string::String', 'name': 'add' },
24+
],
25+
};

src/test/rustdoc-js/enum-option.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
const QUERY = 'enum:Option';
12+
13+
const EXPECTED = {
14+
'others': [
15+
{ 'path': 'std::option', 'name': 'Option' },
16+
],
17+
};

src/test/rustdoc-js/fn-forget.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
const QUERY = 'fn:forget';
12+
13+
const EXPECTED = {
14+
'others': [
15+
{ 'path': 'std::mem', 'name': 'forget' },
16+
{ 'path': 'std::fmt', 'name': 'format' },
17+
],
18+
};

src/test/rustdoc-js/from_u.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
const QUERY = 'from_u';
12+
13+
const EXPECTED = {
14+
'others': [
15+
{ 'path': 'std::char', 'name': 'from_u32' },
16+
{ 'path': 'std::str', 'name': 'from_utf8' },
17+
{ 'path': 'std::string::String', 'name': 'from_utf8' },
18+
{ 'path': 'std::boxed::Box', 'name': 'from_unique' },
19+
{ 'path': 'std::i32', 'name': 'from_unsigned' },
20+
{ 'path': 'std::i128', 'name': 'from_unsigned' },
21+
],
22+
};

0 commit comments

Comments
 (0)