Skip to content

Commit 2557603

Browse files
committed
Auto merge of #98864 - RalfJung:rollup-ptzklyc, r=RalfJung
Rollup of 4 pull requests Successful merges: - #94831 (Link to stabilization section in std-dev-guide for library tracking issue template) - #98764 (add Miri to the nightly docs) - #98773 (rustdoc: use <details> tag for the source code sidebar) - #98799 (Fix bug in `rustdoc -Whelp`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 495b216 + ce76d73 commit 2557603

File tree

20 files changed

+207
-514
lines changed

20 files changed

+207
-514
lines changed

.github/ISSUE_TEMPLATE/library_tracking_issue.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ If the feature is changed later, please add those PRs here as well.
5050
-->
5151

5252
- [ ] Implementation: #...
53-
- [ ] Final comment period (FCP)
53+
- [ ] Final comment period (FCP)[^1]
5454
- [ ] Stabilization PR
5555

5656
<!--
@@ -81,3 +81,5 @@ Zulip, or the internals forum) here.
8181
-->
8282

8383
- None yet.
84+
85+
[^1]: https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

compiler/rustc_driver/src/lib.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,10 @@ Available lint options:
849849
};
850850

851851
println!("Lint checks provided by rustc:\n");
852-
println!(" {} {:7.7} {}", padded("name"), "default", "meaning");
853-
println!(" {} {:7.7} {}", padded("----"), "-------", "-------");
854852

855853
let print_lints = |lints: Vec<&Lint>| {
854+
println!(" {} {:7.7} {}", padded("name"), "default", "meaning");
855+
println!(" {} {:7.7} {}", padded("----"), "-------", "-------");
856856
for lint in lints {
857857
let name = lint.name_lower().replace('_', "-");
858858
println!(
@@ -884,11 +884,15 @@ Available lint options:
884884
};
885885

886886
println!("Lint groups provided by rustc:\n");
887-
println!(" {} sub-lints", padded("name"));
888-
println!(" {} ---------", padded("----"));
889-
println!(" {} all lints that are set to issue warnings", padded("warnings"));
890887

891-
let print_lint_groups = |lints: Vec<(&'static str, Vec<LintId>)>| {
888+
let print_lint_groups = |lints: Vec<(&'static str, Vec<LintId>)>, all_warnings| {
889+
println!(" {} sub-lints", padded("name"));
890+
println!(" {} ---------", padded("----"));
891+
892+
if all_warnings {
893+
println!(" {} all lints that are set to issue warnings", padded("warnings"));
894+
}
895+
892896
for (name, to) in lints {
893897
let name = name.to_lowercase().replace('_', "-");
894898
let desc = to
@@ -901,7 +905,7 @@ Available lint options:
901905
println!("\n");
902906
};
903907

904-
print_lint_groups(builtin_groups);
908+
print_lint_groups(builtin_groups, true);
905909

906910
match (loaded_plugins, plugin.len(), plugin_groups.len()) {
907911
(false, 0, _) | (false, _, 0) => {
@@ -916,7 +920,7 @@ Available lint options:
916920
}
917921
if g > 0 {
918922
println!("Lint groups provided by plugins loaded by this crate:\n");
919-
print_lint_groups(plugin_groups);
923+
print_lint_groups(plugin_groups, false);
920924
}
921925
}
922926
}

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ impl<'a> Builder<'a> {
694694
doc::RustcBook,
695695
doc::CargoBook,
696696
doc::Clippy,
697+
doc::Miri,
697698
doc::EmbeddedBook,
698699
doc::EditionGuide,
699700
),

src/bootstrap/doc.rs

+29-5
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ impl Step for Rustc {
643643
}
644644

645645
macro_rules! tool_doc {
646-
($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?] $(,)?) => {
646+
($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?], in_tree = $in_tree:expr $(,)?) => {
647647
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
648648
pub struct $tool {
649649
target: TargetSelection,
@@ -699,6 +699,12 @@ macro_rules! tool_doc {
699699
t!(fs::create_dir_all(&out_dir));
700700
t!(symlink_dir_force(&builder.config, &out, &out_dir));
701701

702+
let source_type = if $in_tree == true {
703+
SourceType::InTree
704+
} else {
705+
SourceType::Submodule
706+
};
707+
702708
// Build cargo command.
703709
let mut cargo = prepare_tool_cargo(
704710
builder,
@@ -707,7 +713,7 @@ macro_rules! tool_doc {
707713
target,
708714
"doc",
709715
$path,
710-
SourceType::InTree,
716+
source_type,
711717
&[],
712718
);
713719

@@ -723,20 +729,38 @@ macro_rules! tool_doc {
723729
cargo.rustdocflag("--show-type-layout");
724730
cargo.rustdocflag("--generate-link-to-definition");
725731
cargo.rustdocflag("-Zunstable-options");
726-
builder.run(&mut cargo.into());
732+
if $in_tree == true {
733+
builder.run(&mut cargo.into());
734+
} else {
735+
// Allow out-of-tree docs to fail (since the tool might be in a broken state).
736+
if !builder.try_run(&mut cargo.into()) {
737+
builder.info(&format!(
738+
"WARNING: tool {} failed to document; ignoring failure because it is an out-of-tree tool",
739+
stringify!($tool).to_lowercase(),
740+
));
741+
}
742+
}
727743
}
728744
}
729745
}
730746
}
731747

732-
tool_doc!(Rustdoc, "rustdoc-tool", "src/tools/rustdoc", ["rustdoc", "rustdoc-json-types"]);
748+
tool_doc!(
749+
Rustdoc,
750+
"rustdoc-tool",
751+
"src/tools/rustdoc",
752+
["rustdoc", "rustdoc-json-types"],
753+
in_tree = true
754+
);
733755
tool_doc!(
734756
Rustfmt,
735757
"rustfmt-nightly",
736758
"src/tools/rustfmt",
737759
["rustfmt-nightly", "rustfmt-config_proc_macro"],
760+
in_tree = true
738761
);
739-
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]);
762+
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"], in_tree = true);
763+
tool_doc!(Miri, "miri", "src/tools/miri", ["miri"], in_tree = false);
740764

741765
#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
742766
pub struct ErrorIndex {

src/librustdoc/config.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,7 @@ impl Options {
353353
print_flag_list("-C", config::CG_OPTIONS);
354354
return Err(0);
355355
}
356-
let w_flags = matches.opt_strs("W");
357-
if w_flags.iter().any(|x| *x == "help") {
358-
print_flag_list("-W", config::DB_OPTIONS);
359-
return Err(0);
360-
}
356+
361357
if matches.opt_strs("passes") == ["list"] {
362358
println!("Available passes for running rustdoc:");
363359
for pass in passes::PASSES {
@@ -439,15 +435,19 @@ impl Options {
439435
return Err(0);
440436
}
441437

442-
if matches.free.is_empty() {
438+
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
439+
440+
let input = PathBuf::from(if describe_lints {
441+
"" // dummy, this won't be used
442+
} else if matches.free.is_empty() {
443443
diag.struct_err("missing file operand").emit();
444444
return Err(1);
445-
}
446-
if matches.free.len() > 1 {
445+
} else if matches.free.len() > 1 {
447446
diag.struct_err("too many file operands").emit();
448447
return Err(1);
449-
}
450-
let input = PathBuf::from(&matches.free[0]);
448+
} else {
449+
&matches.free[0]
450+
});
451451

452452
let libs = matches
453453
.opt_strs("L")
@@ -698,8 +698,6 @@ impl Options {
698698
let with_examples = matches.opt_strs("with-examples");
699699
let call_locations = crate::scrape_examples::load_call_locations(with_examples, &diag)?;
700700

701-
let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
702-
703701
Ok(Options {
704702
input,
705703
proc_macro_crate,

src/librustdoc/html/static/css/rustdoc.css

+11-26
Original file line numberDiff line numberDiff line change
@@ -1578,38 +1578,23 @@ kbd {
15781578
margin-bottom: 1em;
15791579
}
15801580

1581-
div.children {
1582-
padding-left: 27px;
1583-
display: none;
1581+
details.dir-entry {
1582+
padding-left: 4px;
15841583
}
1585-
div.name {
1584+
1585+
details.dir-entry > summary {
1586+
margin: 0 0 0 13px;
1587+
list-style-position: outside;
15861588
cursor: pointer;
1587-
position: relative;
1588-
margin-left: 16px;
15891589
}
1590-
div.files > a {
1591-
display: block;
1592-
padding: 0 3px;
1593-
}
1594-
div.files > a:hover, div.name:hover {
1595-
background-color: #a14b4b;
1590+
1591+
details.dir-entry div.folders, details.dir-entry div.files {
1592+
padding-left: 23px;
15961593
}
1597-
div.name.expand + .children {
1594+
1595+
details.dir-entry a {
15981596
display: block;
15991597
}
1600-
div.name::before {
1601-
content: "\25B6";
1602-
padding-left: 4px;
1603-
font-size: 0.625rem;
1604-
position: absolute;
1605-
left: -16px;
1606-
top: 4px;
1607-
}
1608-
div.name.expand::before {
1609-
transform: rotate(90deg);
1610-
left: -15px;
1611-
top: 2px;
1612-
}
16131598

16141599
/* The hideme class is used on summary tags that contain a span with
16151600
placeholder text shown only when the toggle is closed. For instance,

src/librustdoc/html/static/css/themes/ayu.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -575,11 +575,12 @@ kbd {
575575
color: #fff;
576576
border-bottom-color: #5c6773;
577577
}
578-
#source-sidebar div.files > a:hover, div.name:hover {
578+
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
579+
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
579580
background-color: #14191f;
580581
color: #ffb44c;
581582
}
582-
#source-sidebar div.files > .selected {
583+
#source-sidebar div.files > a.selected {
583584
background-color: #14191f;
584585
color: #ffb44c;
585586
}

src/librustdoc/html/static/css/themes/dark.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,11 @@ kbd {
432432
#source-sidebar > .title {
433433
border-bottom-color: #ccc;
434434
}
435-
#source-sidebar div.files > a:hover, div.name:hover {
435+
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
436+
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
436437
background-color: #444;
437438
}
438-
#source-sidebar div.files > .selected {
439+
#source-sidebar div.files > a.selected {
439440
background-color: #333;
440441
}
441442

src/librustdoc/html/static/css/themes/light.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,13 @@ kbd {
414414
#source-sidebar > .title {
415415
border-bottom-color: #ccc;
416416
}
417-
#source-sidebar div.files > a:hover, div.name:hover {
417+
#source-sidebar div.files > a:hover, details.dir-entry summary:hover,
418+
#source-sidebar div.files > a:focus, details.dir-entry summary:focus {
418419
background-color: #E0E0E0;
419420
}
420-
#source-sidebar div.files > .selected {
421+
#source-sidebar div.files > a.selected {
421422
background-color: #fff;
422423
}
423-
424424
.scraped-example-list .scrape-help {
425425
border-color: #555;
426426
color: #333;

src/librustdoc/html/static/js/source-script.js

+12-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* global sourcesIndex */
33

44
// Local js definitions:
5-
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, browserSupportsHistoryApi */
5+
/* global addClass, getCurrentValue, onEachLazy, removeClass, browserSupportsHistoryApi */
66
/* global updateLocalStorage */
77

88
"use strict";
@@ -13,33 +13,27 @@ const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-p
1313
let oldScrollPosition = 0;
1414

1515
function createDirEntry(elem, parent, fullPath, hasFoundFile) {
16-
const name = document.createElement("div");
17-
name.className = "name";
16+
const dirEntry = document.createElement("details");
17+
const summary = document.createElement("summary");
18+
19+
dirEntry.className = "dir-entry";
1820

1921
fullPath += elem["name"] + "/";
2022

21-
name.onclick = ev => {
22-
if (hasClass(ev.target, "expand")) {
23-
removeClass(ev.target, "expand");
24-
} else {
25-
addClass(ev.target, "expand");
26-
}
27-
};
28-
name.innerText = elem["name"];
23+
summary.innerText = elem["name"];
24+
dirEntry.appendChild(summary);
2925

30-
const children = document.createElement("div");
31-
children.className = "children";
3226
const folders = document.createElement("div");
3327
folders.className = "folders";
3428
if (elem.dirs) {
3529
for (const dir of elem.dirs) {
3630
if (createDirEntry(dir, folders, fullPath, hasFoundFile)) {
37-
addClass(name, "expand");
31+
dirEntry.open = true;
3832
hasFoundFile = true;
3933
}
4034
}
4135
}
42-
children.appendChild(folders);
36+
dirEntry.appendChild(folders);
4337

4438
const files = document.createElement("div");
4539
files.className = "files";
@@ -51,15 +45,14 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
5145
const w = window.location.href.split("#")[0];
5246
if (!hasFoundFile && w === file.href) {
5347
file.className = "selected";
54-
addClass(name, "expand");
48+
dirEntry.open = true;
5549
hasFoundFile = true;
5650
}
5751
files.appendChild(file);
5852
}
5953
}
60-
children.appendChild(files);
61-
parent.appendChild(name);
62-
parent.appendChild(children);
54+
dirEntry.appendChild(files);
55+
parent.appendChild(dirEntry);
6356
return hasFoundFile;
6457
}
6558

0 commit comments

Comments
 (0)