diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs
index 6a691abae026d..9daee12ca2e97 100644
--- a/compiler/rustc_const_eval/src/const_eval/machine.rs
+++ b/compiler/rustc_const_eval/src/const_eval/machine.rs
@@ -641,7 +641,14 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
// way to implement exponential backoff.
let span = ecx.cur_span();
- ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span });
+ // We store a unique number in `force_duplicate` to evade `-Z deduplicate-diagnostics`.
+ // `new_steps` is guaranteed to be unique because `ecx.machine.num_evaluated_steps` is
+ // always increasing.
+ ecx.tcx.dcx().emit_warn(LongRunningWarn {
+ span,
+ item_span: ecx.tcx.span,
+ force_duplicate: new_steps,
+ });
}
}
diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs
index b66b5c0a00a2f..06ae5b30be066 100644
--- a/compiler/rustc_const_eval/src/errors.rs
+++ b/compiler/rustc_const_eval/src/errors.rs
@@ -209,6 +209,8 @@ pub struct LongRunningWarn {
pub span: Span,
#[help]
pub item_span: Span,
+ // Used for evading `-Z deduplicate-diagnostics`.
+ pub force_duplicate: usize,
}
#[derive(Subdiagnostic)]
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index e4ba5e47613b2..051d5153f2ebc 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -32,13 +32,17 @@
//!
//! Once you are familiar with the contents of the standard library you may
//! begin to find the verbosity of the prose distracting. At this stage in your
-//! development you may want to press the `[-]` button near the top of the
-//! page to collapse it into a more skimmable view.
-//!
-//! While you are looking at that `[-]` button also notice the `source`
-//! link. Rust's API documentation comes with the source code and you are
-//! encouraged to read it. The standard library source is generally high
-//! quality and a peek behind the curtains is often enlightening.
+//! development you may want to press the
+//! Summary button near the
+//! top of the page to collapse it into a more skimmable view.
+//!
+//! While you are looking at the top of the page, also notice the
+//! source link. Rust's API documentation comes with the source
+//! code and you are encouraged to read it. The standard library source is
+//! generally high quality and a peek behind the curtains is
+//! often enlightening.
//!
//! # What is in the standard library documentation?
//!
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
index e1ab1e7599e84..db7b239c0ae29 100644
--- a/src/bootstrap/src/core/build_steps/compile.rs
+++ b/src/bootstrap/src/core/build_steps/compile.rs
@@ -1057,6 +1057,10 @@ pub fn rustc_cargo(
// killed, rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");
+ if builder.config.llvm_enzyme {
+ cargo.rustflag("-l").rustflag("Enzyme-19");
+ }
+
// We currently don't support cross-crate LTO in stage0. This also isn't hugely necessary
// and may just be a time sink.
if compiler.stage != 0 {
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
index 2124890b94f67..d2c23ee843290 100644
--- a/src/bootstrap/src/core/builder.rs
+++ b/src/bootstrap/src/core/builder.rs
@@ -1592,12 +1592,6 @@ impl<'a> Builder<'a> {
rustflags.arg(sysroot_str);
}
- // https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20link.20new.20library.20into.20stage1.2Frustc
- if self.config.llvm_enzyme {
- rustflags.arg("-l");
- rustflags.arg("Enzyme-19");
- }
-
let use_new_symbol_mangling = match self.config.rust_new_symbol_mangling {
Some(setting) => {
// If an explicit setting is given, use that
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 6f4665db6f1de..050ba60318e6a 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -261,7 +261,9 @@ impl<'a, I: Iterator>> Iterator for CodeBlocks<'_, 'a, I> {
\
",
added_classes = added_classes.join(" "),
- text = Escape(&original_text),
+ text = Escape(
+ original_text.strip_suffix('\n').unwrap_or(&original_text)
+ ),
)
.into(),
));
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index e490099a92e14..3ec60c0efd216 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -524,15 +524,13 @@ fn test_ascii_with_prepending_hashtag() {
####.###..#....#....#..#.
#..#.#....#....#....#..#.
#..#.#....#....#....#..#.
-#..#.####.####.####..##..
-",
+#..#.####.####.####..##..",
);
t(
r#"```markdown
# hello
```"#,
"
\
-# hello
-
",
+# hello",
);
}
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs
index 0d6a4603cd292..14542f53afc70 100644
--- a/src/librustdoc/html/sources.rs
+++ b/src/librustdoc/html/sources.rs
@@ -26,8 +26,11 @@ pub(crate) fn render(cx: &mut Context<'_>, krate: &clean::Crate) -> Result<(), E
let dst = cx.dst.join("src").join(krate.name(cx.tcx()).as_str());
cx.shared.ensure_dir(&dst)?;
+ let crate_name = krate.name(cx.tcx());
+ let crate_name = crate_name.as_str();
- let mut collector = SourceCollector { dst, cx, emitted_local_sources: FxHashSet::default() };
+ let mut collector =
+ SourceCollector { dst, cx, emitted_local_sources: FxHashSet::default(), crate_name };
collector.visit_crate(krate);
Ok(())
}
@@ -115,6 +118,8 @@ struct SourceCollector<'a, 'tcx> {
/// Root destination to place all HTML output into
dst: PathBuf,
emitted_local_sources: FxHashSet,
+
+ crate_name: &'a str,
}
impl DocVisitor for SourceCollector<'_, '_> {
@@ -210,6 +215,9 @@ impl SourceCollector<'_, '_> {
},
);
+ let src_fname = p.file_name().expect("source has no filename").to_os_string();
+ let mut fname = src_fname.clone();
+
let root_path = PathBuf::from("../../").join(root_path.into_inner());
let mut root_path = root_path.to_string_lossy();
if let Some(c) = root_path.as_bytes().last()
@@ -217,12 +225,12 @@ impl SourceCollector<'_, '_> {
{
root_path += "/";
}
+ let mut file_path = Path::new(&self.crate_name).join(&*cur.borrow());
+ file_path.push(&fname);
+ fname.push(".html");
let mut cur = self.dst.join(cur.into_inner());
shared.ensure_dir(&cur)?;
- let src_fname = p.file_name().expect("source has no filename").to_os_string();
- let mut fname = src_fname.clone();
- fname.push(".html");
cur.push(&fname);
let title = format!("{} - source", src_fname.to_string_lossy());
@@ -250,7 +258,7 @@ impl SourceCollector<'_, '_> {
cx,
&root_path,
highlight::DecorationInfo::default(),
- SourceContext::Standalone,
+ SourceContext::Standalone { file_path },
)
},
&shared.style_files,
@@ -312,10 +320,11 @@ struct ScrapedSource<'a, Code: std::fmt::Display> {
struct Source {
lines: RangeInclusive,
code_html: Code,
+ file_path: Option<(String, String)>,
}
pub(crate) enum SourceContext<'a> {
- Standalone,
+ Standalone { file_path: PathBuf },
Embedded(ScrapedInfo<'a>),
}
@@ -344,9 +353,19 @@ pub(crate) fn print_src(
});
let lines = s.lines().count();
match source_context {
- SourceContext::Standalone => {
- Source { lines: (1..=lines), code_html: code }.render_into(&mut writer).unwrap()
+ SourceContext::Standalone { file_path } => Source {
+ lines: (1..=lines),
+ code_html: code,
+ file_path: if let Some(file_name) = file_path.file_name()
+ && let Some(file_path) = file_path.parent()
+ {
+ Some((file_path.display().to_string(), file_name.display().to_string()))
+ } else {
+ None
+ },
}
+ .render_into(&mut writer)
+ .unwrap(),
SourceContext::Embedded(info) => {
let lines = (1 + info.offset)..=(lines + info.offset);
ScrapedSource { info, lines, code_html: code }.render_into(&mut writer).unwrap();
diff --git a/src/librustdoc/html/static/css/noscript.css b/src/librustdoc/html/static/css/noscript.css
index e62b16267f102..477a79d63e948 100644
--- a/src/librustdoc/html/static/css/noscript.css
+++ b/src/librustdoc/html/static/css/noscript.css
@@ -61,6 +61,8 @@ nav.sub {
--copy-path-img-hover-filter: invert(35%);
--code-example-button-color: #7f7f7f;
--code-example-button-hover-color: #595959;
+ --settings-menu-filter: invert(50%);
+ --settings-menu-hover-filter: invert(35%);
--codeblock-error-hover-color: rgb(255, 0, 0);
--codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0);
@@ -87,7 +89,6 @@ nav.sub {
--search-tab-button-not-selected-background: #e6e6e6;
--search-tab-button-selected-border-top-color: #0089ff;
--search-tab-button-selected-background: #fff;
- --settings-menu-filter: none;
--stab-background-color: #fff5d6;
--stab-code-color: #000;
--code-highlight-kw-color: #8959a8;
@@ -192,6 +193,8 @@ nav.sub {
--search-tab-button-not-selected-background: #252525;
--search-tab-button-selected-border-top-color: #0089ff;
--search-tab-button-selected-background: #353535;
+ --settings-menu-filter: invert(50%);
+ --settings-menu-hover-filter: invert(65%);
--stab-background-color: #314559;
--stab-code-color: #e6e1cf;
--code-highlight-kw-color: #ab8ac1;
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 04b0eba745090..ae9727a4d4f57 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -34,6 +34,8 @@ xmlns="http://www.w3.org/2000/svg" fill="black" height="18px">\
');
--button-left-margin: 4px;
--button-border-radius: 2px;
+ --toolbar-button-border-radius: 6px;
+ --code-block-border-radius: 6px;
}
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
@@ -165,7 +167,7 @@ h1, h2, h3, h4 {
.main-heading h1 {
margin: 0;
padding: 0;
- flex-grow: 1;
+ grid-area: main-heading-h1;
/* We use overflow-wrap: break-word for Safari, which doesn't recognize
`anywhere`: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap */
overflow-wrap: break-word;
@@ -174,10 +176,28 @@ h1, h2, h3, h4 {
overflow-wrap: anywhere;
}
.main-heading {
- display: flex;
- flex-wrap: wrap;
+ position: relative;
+ display: grid;
+ grid-template-areas:
+ "main-heading-breadcrumbs main-heading-breadcrumbs"
+ "main-heading-h1 main-heading-toolbar"
+ "main-heading-sub-heading main-heading-toolbar";
+ grid-template-columns: 1fr max-content;
+ grid-template-rows: 25px min-content min-content;
padding-bottom: 6px;
- margin-bottom: 15px;
+ margin-bottom: 11px;
+}
+.rustdoc-breadcrumbs {
+ grid-area: main-heading-breadcrumbs;
+ height: 25px;
+ line-height: 1.25;
+ display: flex;
+ align-items: end;
+}
+.rustdoc-breadcrumbs a {
+ padding: 4px 0;
+ margin: -4px 0;
+ z-index: 1;
}
/* The only headings that get underlines are:
Markdown-generated headings within the top-doc
@@ -218,11 +238,13 @@ h1, h2, h3, h4, h5, h6,
.search-results .result-name,
.item-name > a,
.out-of-band,
+.sub-heading,
span.since,
a.src,
-#help-button > a,
+rustdoc-toolbar,
summary.hideme,
.scraped-example-list,
+.rustdoc-breadcrumbs,
/* This selector is for the items listed in the "all items" page. */
ul.all-items {
font-family: "Fira Sans", Arial, NanumBarunGothic, sans-serif;
@@ -891,14 +913,27 @@ both the code example and the line numbers, so we need to remove the radius in t
overflow-x: auto;
}
-.out-of-band {
+.sub-heading {
+ font-size: 1rem;
flex-grow: 0;
- font-size: 1.125rem;
+ grid-area: main-heading-sub-heading;
+ line-height: 1.25;
+ padding-bottom: 4px;
+}
+
+.main-heading rustdoc-toolbar, .main-heading .out-of-band {
+ grid-area: main-heading-toolbar;
+}
+rustdoc-toolbar {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
}
.docblock code, .docblock-short code,
pre, .rustdoc.src .example-wrap, .example-wrap .src-line-numbers {
background-color: var(--code-block-background-color);
+ border-radius: var(--code-block-border-radius);
}
#main-content {
@@ -945,7 +980,7 @@ div.where {
nav.sub {
flex-grow: 1;
flex-flow: row nowrap;
- margin: 4px 0 25px 0;
+ margin: 4px 0 0 0;
display: flex;
align-items: center;
}
@@ -956,7 +991,7 @@ nav.sub {
flex-grow: 1;
}
.src nav.sub {
- margin: 0 0 15px 0;
+ margin: 0 0 -10px 0;
}
.section-header {
@@ -1066,6 +1101,11 @@ table,
with boxes (i.e. from the flex layout) */
align-items: baseline;
}
+.search-results-title + .sub-heading {
+ color: var(--main-color);
+ display: flex;
+ align-items: center;
+}
#crate-search-div {
/* ensures that 100% in properties of #crate-search-div:after
are relative to the size of this div */
@@ -1289,10 +1329,16 @@ so that we can apply CSS-filters to change the arrow color in themes */
border-color: var(--settings-input-color) !important;
}
+#settings.popover {
+ --popover-arrow-offset: 202px;
+ top: calc(100% - 16px);
+}
+
/* use larger max-width for help popover, but not for help.html */
#help.popover {
max-width: 600px;
- --popover-arrow-offset: 48px;
+ --popover-arrow-offset: 118px;
+ top: calc(100% - 16px);
}
#help dt {
@@ -1300,10 +1346,15 @@ so that we can apply CSS-filters to change the arrow color in themes */
clear: left;
margin-right: 0.5rem;
}
+#help dd {
+ margin-bottom: 0.5rem;
+}
#help span.top, #help span.bottom {
text-align: center;
display: block;
font-size: 1.125rem;
+ padding: 0 0.5rem;
+ text-wrap-style: balance;
}
#help span.top {
margin: 10px 0;
@@ -1315,10 +1366,13 @@ so that we can apply CSS-filters to change the arrow color in themes */
clear: both;
border-top: 1px solid var(--border-color);
}
+.side-by-side {
+ display: flex;
+ margin-bottom: 20px;
+}
.side-by-side > div {
width: 50%;
- float: left;
- padding: 0 20px 20px 17px;
+ padding: 0 20px 0 17px;
}
.item-info .stab {
@@ -1381,7 +1435,9 @@ so that we can apply CSS-filters to change the arrow color in themes */
}
.rightside:not(a),
-.out-of-band {
+.out-of-band,
+.sub-heading,
+rustdoc-toolbar {
color: var(--right-side-color);
}
@@ -1595,8 +1651,8 @@ instead, we check that it's not a "finger" cursor.
display: block;
}
-.out-of-band > span.since {
- font-size: 1.25rem;
+.main-heading span.since::before {
+ content: "Since ";
}
.sub-variant h4 {
@@ -1698,6 +1754,7 @@ a.tooltip:hover::after {
}
#search-tabs {
+ margin-top: 0.25rem;
display: flex;
flex-direction: row;
gap: 1px;
@@ -1759,9 +1816,10 @@ a.tooltip:hover::after {
border-bottom: 1px solid var(--border-color);
}
-#settings-menu, #help-button {
+#settings-menu, #help-button, button#toggle-all-docs {
margin-left: var(--button-left-margin);
display: flex;
+ line-height: 1.25;
}
#sidebar-button {
display: none;
@@ -1785,33 +1843,36 @@ a.tooltip:hover::after {
.hide-sidebar .src #sidebar-button {
position: static;
}
-#settings-menu > a, #help-button > a, #sidebar-button > a {
+#settings-menu > a, #help-button > a, #sidebar-button > a, button#toggle-all-docs {
display: flex;
align-items: center;
justify-content: center;
- background-color: var(--button-background-color);
- border: 1px solid var(--border-color);
+ flex-direction: column;
+ border: 1px solid transparent;
border-radius: var(--button-border-radius);
- color: var(--settings-button-color);
- /* Rare exception to specifying font sizes in rem. Since this is acting
- as an icon, it's okay to specify their sizes in pixels. */
- font-size: 20px;
+ color: var(--main-color);
+}
+#settings-menu > a, #help-button > a, button#toggle-all-docs {
+ width: 80px;
+ border-radius: var(--toolbar-button-border-radius);
+}
+#sidebar-button > a {
+ background-color: var(--button-background-color);
+ border-color: var(--border-color);
width: 33px;
}
-#settings-menu > a:hover, #settings-menu > a:focus,
-#help-button > a:hover, #help-button > a:focus,
-#sidebar-button > a:hover, #sidebar-button > a:focus {
+#settings-menu > a:hover, #settings-menu > a:focus-visible,
+#help-button > a:hover, #help-button > a:focus-visible,
+#sidebar-button > a:hover, #sidebar-button > a:focus-visible,
+button#toggle-all-docs:hover, button#toggle-all-docs:focus-visible {
border-color: var(--settings-button-border-focus);
+ text-decoration: none;
}
-#settings-menu > a {
- line-height: 0;
- font-size: 0;
-}
#settings-menu > a:before {
/* Wheel */
- content: url('data:image/svg+xml,');
- width: 22px;
- height: 22px;
+ width: 18px;
+ height: 18px;
+ filter: var(--settings-menu-filter);
+}
+
+button#toggle-all-docs:before {
+ /* Custom arrow icon */
+ content: url('data:image/svg+xml,');
+ width: 18px;
+ height: 18px;
+ filter: var(--settings-menu-filter);
+}
+
+#help-button > a:before {
+ /* Question mark with circle */
+ content: url('data:image/svg+xml,');
+ width: 18px;
+ height: 18px;
+ filter: var(--settings-menu-filter);
+}
+
+button#toggle-all-docs:before,
+#help-button > a:before,
+#settings-menu > a:before {
filter: var(--settings-menu-filter);
+ margin: 8px;
+}
+
+@media not (pointer: coarse) {
+ button#toggle-all-docs:hover:before,
+ #help-button > a:hover:before,
+ #settings-menu > a:hover:before {
+ filter: var(--settings-menu-hover-filter);
+ }
+}
+
+button[disabled]#toggle-all-docs {
+ opacity: 0.25;
+ border: solid 1px var(--main-background-color);
+ background-size: cover;
+}
+
+button[disabled]#toggle-all-docs:hover {
+ border: solid 1px var(--main-background-color);
+ cursor: not-allowed;
+}
+
+rustdoc-toolbar span.label {
+ font-size: 1rem;
+ flex-grow: 1;
+ padding-bottom: 4px;
}
#sidebar-button > a:before {
/* sidebar resizer image */
content: url('data:image/svg+xml,');
width: 22px;
@@ -1948,10 +2063,10 @@ details.toggle > summary.hideme > span {
}
details.toggle > summary::before {
- /* toggle plus */
- background: url('data:image/svg+xml,') no-repeat top left;
+ /* arrow pointing left */
+ background: url('data:image/svg+xml,');
content: "";
cursor: pointer;
width: 16px;
@@ -2034,10 +2149,10 @@ details.toggle[open] > summary.hideme > span {
}
details.toggle[open] > summary::before {
- /* toggle minus */
- background: url('data:image/svg+xml,') no-repeat top left;
+ /* arrow pointing down */
+ background: url('data:image/svg+xml,');
}
details.toggle[open] > summary::after {
@@ -2090,6 +2205,12 @@ However, it's not needed with smaller screen width because the doc/code block is
#search-tabs .count {
display: block;
}
+ .side-by-side {
+ flex-direction: column-reverse;
+ }
+ .side-by-side > div {
+ width: auto;
+ }
}
/*
@@ -2106,6 +2227,25 @@ in src-script.js and main.js
scroll-margin-top: 45px;
}
+ /* We don't display this button on mobile devices. */
+ #copy-path {
+ display: none;
+ }
+
+ /* Text label takes up too much space at this size. */
+ rustdoc-toolbar span.label {
+ display: none;
+ }
+ #settings-menu > a, #help-button > a, button#toggle-all-docs {
+ width: 33px;
+ }
+ #settings.popover {
+ --popover-arrow-offset: 86px;
+ }
+ #help.popover {
+ --popover-arrow-offset: 48px;
+ }
+
.rustdoc {
/* Sidebar should overlay main content, rather than pushing main content to the right.
Turn off `display: flex` on the body element. */
@@ -2117,20 +2257,6 @@ in src-script.js and main.js
padding-top: 0px;
}
- .main-heading {
- flex-direction: column;
- }
-
- .out-of-band {
- text-align: left;
- margin-left: initial;
- padding: initial;
- }
-
- .out-of-band .since::before {
- content: "Since ";
- }
-
/* Hide the logo and item name from the sidebar. Those are displayed
in the mobile-topbar instead. */
.sidebar .logo-container,
@@ -2163,6 +2289,9 @@ in src-script.js and main.js
.src .search-form {
margin-left: 40px;
}
+ .src .main-heading {
+ margin-left: 8px;
+ }
.hide-sidebar .search-form {
margin-left: 32px;
}
@@ -2234,16 +2363,11 @@ in src-script.js and main.js
left: -11px;
}
- /* We don't display these buttons on mobile devices. */
- #copy-path, #help-button {
- display: none;
- }
-
/* sidebar button becomes topbar button */
#sidebar-button > a:before {
content: url('data:image/svg+xml,');
width: 22px;
@@ -2305,7 +2429,7 @@ in src-script.js and main.js
}
.src nav.sub {
- margin: 0;
+ margin: 0 0 -25px 0;
padding: var(--nav-sub-mobile-padding);
}
}
@@ -2543,6 +2667,8 @@ by default.
--copy-path-img-hover-filter: invert(35%);
--code-example-button-color: #7f7f7f;
--code-example-button-hover-color: #595959;
+ --settings-menu-filter: invert(50%);
+ --settings-menu-hover-filter: invert(35%);
--codeblock-error-hover-color: rgb(255, 0, 0);
--codeblock-error-color: rgba(255, 0, 0, .5);
--codeblock-ignore-hover-color: rgb(255, 142, 0);
@@ -2569,7 +2695,6 @@ by default.
--search-tab-button-not-selected-background: #e6e6e6;
--search-tab-button-selected-border-top-color: #0089ff;
--search-tab-button-selected-background: #fff;
- --settings-menu-filter: none;
--stab-background-color: #fff5d6;
--stab-code-color: #000;
--code-highlight-kw-color: #8959a8;
@@ -2673,7 +2798,8 @@ by default.
--search-tab-button-not-selected-background: #252525;
--search-tab-button-selected-border-top-color: #0089ff;
--search-tab-button-selected-background: #353535;
- --settings-menu-filter: none;
+ --settings-menu-filter: invert(50%);
+ --settings-menu-hover-filter: invert(65%);
--stab-background-color: #314559;
--stab-code-color: #e6e1cf;
--code-highlight-kw-color: #ab8ac1;
@@ -2784,7 +2910,8 @@ Original by Dempfi (https://github.com/dempfi/ayu)
--search-tab-button-not-selected-background: transparent !important;
--search-tab-button-selected-border-top-color: none;
--search-tab-button-selected-background: #141920 !important;
- --settings-menu-filter: invert(100%);
+ --settings-menu-filter: invert(70%);
+ --settings-menu-hover-filter: invert(100%);
--stab-background-color: #314559;
--stab-code-color: #e6e1cf;
--code-highlight-kw-color: #ff7733;
diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index a0ec45b5ef38c..0d556e0a68274 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -1,6 +1,6 @@
// Local js definitions:
/* global addClass, getSettingValue, hasClass, searchState, updateLocalStorage */
-/* global onEach, onEachLazy, removeClass, getVar */
+/* global onEachLazy, removeClass, getVar */
"use strict";
@@ -19,17 +19,25 @@ function resourcePath(basename, extension) {
function hideMain() {
addClass(document.getElementById(MAIN_ID), "hidden");
+ const toggle = document.getElementById("toggle-all-docs");
+ if (toggle) {
+ toggle.setAttribute("disabled", "disabled");
+ }
}
function showMain() {
- removeClass(document.getElementById(MAIN_ID), "hidden");
-}
-
-function blurHandler(event, parentElem, hideCallback) {
- if (!parentElem.contains(document.activeElement) &&
- !parentElem.contains(event.relatedTarget)
- ) {
- hideCallback();
+ const main = document.getElementById(MAIN_ID);
+ removeClass(main, "hidden");
+ const mainHeading = main.querySelector(".main-heading");
+ if (mainHeading && searchState.rustdocToolbar) {
+ if (searchState.rustdocToolbar.parentElement) {
+ searchState.rustdocToolbar.parentElement.removeChild(searchState.rustdocToolbar);
+ }
+ mainHeading.appendChild(searchState.rustdocToolbar);
+ }
+ const toggle = document.getElementById("toggle-all-docs");
+ if (toggle) {
+ toggle.removeAttribute("disabled");
}
}
@@ -167,6 +175,14 @@ function switchDisplayedElement(elemToDisplay) {
el.appendChild(elemToDisplay);
hideMain();
removeClass(el, "hidden");
+
+ const mainHeading = elemToDisplay.querySelector(".main-heading");
+ if (mainHeading && searchState.rustdocToolbar) {
+ if (searchState.rustdocToolbar.parentElement) {
+ searchState.rustdocToolbar.parentElement.removeChild(searchState.rustdocToolbar);
+ }
+ mainHeading.appendChild(searchState.rustdocToolbar);
+ }
}
function browserSupportsHistoryApi() {
@@ -194,33 +210,36 @@ function preLoadCss(cssUrl) {
document.head.append(script);
}
- getSettingsButton().onclick = event => {
- if (event.ctrlKey || event.altKey || event.metaKey) {
- return;
- }
- window.hideAllModals(false);
- addClass(getSettingsButton(), "rotate");
- event.preventDefault();
- // Sending request for the CSS and the JS files at the same time so it will
- // hopefully be loaded when the JS will generate the settings content.
- loadScript(getVar("static-root-path") + getVar("settings-js"));
- // Pre-load all theme CSS files, so that switching feels seamless.
- //
- // When loading settings.html as a standalone page, the equivalent HTML is
- // generated in context.rs.
- setTimeout(() => {
- const themes = getVar("themes").split(",");
- for (const theme of themes) {
- // if there are no themes, do nothing
- // "".split(",") == [""]
- if (theme !== "") {
- preLoadCss(getVar("root-path") + theme + ".css");
- }
+ if (getSettingsButton()) {
+ getSettingsButton().onclick = event => {
+ if (event.ctrlKey || event.altKey || event.metaKey) {
+ return;
}
- }, 0);
- };
+ window.hideAllModals(false);
+ addClass(getSettingsButton(), "rotate");
+ event.preventDefault();
+ // Sending request for the CSS and the JS files at the same time so it will
+ // hopefully be loaded when the JS will generate the settings content.
+ loadScript(getVar("static-root-path") + getVar("settings-js"));
+ // Pre-load all theme CSS files, so that switching feels seamless.
+ //
+ // When loading settings.html as a standalone page, the equivalent HTML is
+ // generated in context.rs.
+ setTimeout(() => {
+ const themes = getVar("themes").split(",");
+ for (const theme of themes) {
+ // if there are no themes, do nothing
+ // "".split(",") == [""]
+ if (theme !== "") {
+ preLoadCss(getVar("root-path") + theme + ".css");
+ }
+ }
+ }, 0);
+ };
+ }
window.searchState = {
+ rustdocToolbar: document.querySelector("rustdoc-toolbar"),
loadingText: "Loading search results...",
input: document.getElementsByClassName("search-input")[0],
outputElement: () => {
@@ -919,8 +938,7 @@ function preLoadCss(cssUrl) {
e.open = true;
}
});
- innerToggle.title = "collapse all docs";
- innerToggle.children[0].innerText = "\u2212"; // "\u2212" is "−" minus sign
+ innerToggle.children[0].innerText = "Summary";
}
function collapseAllDocs() {
@@ -934,8 +952,7 @@ function preLoadCss(cssUrl) {
e.open = false;
}
});
- innerToggle.title = "expand all docs";
- innerToggle.children[0].innerText = "+";
+ innerToggle.children[0].innerText = "Show all";
}
function toggleAllDocs() {
@@ -986,7 +1003,13 @@ function preLoadCss(cssUrl) {
}());
window.rustdoc_add_line_numbers_to_examples = () => {
- onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
+ if (document.querySelector(".rustdoc.src")) {
+ // We are in the source code page, nothing to be done here!
+ return;
+ }
+ onEachLazy(document.querySelectorAll(
+ ":not(.scraped-example) > .example-wrap > pre:not(.example-line-numbers)",
+ ), x => {
const parent = x.parentNode;
const line_numbers = parent.querySelectorAll(".example-line-numbers");
if (line_numbers.length > 0) {
@@ -1005,12 +1028,8 @@ function preLoadCss(cssUrl) {
};
window.rustdoc_remove_line_numbers_from_examples = () => {
- onEachLazy(document.getElementsByClassName("rust-example-rendered"), x => {
- const parent = x.parentNode;
- const line_numbers = parent.querySelectorAll(".example-line-numbers");
- for (const node of line_numbers) {
- parent.removeChild(node);
- }
+ onEachLazy(document.querySelectorAll(".example-wrap > .example-line-numbers"), x => {
+ x.parentNode.removeChild(x);
});
};
@@ -1328,7 +1347,13 @@ function preLoadCss(cssUrl) {
}
function helpBlurHandler(event) {
- blurHandler(event, getHelpButton(), window.hidePopoverMenus);
+ if (!getHelpButton().contains(document.activeElement) &&
+ !getHelpButton().contains(event.relatedTarget) &&
+ !getSettingsButton().contains(document.activeElement) &&
+ !getSettingsButton().contains(event.relatedTarget)
+ ) {
+ window.hidePopoverMenus();
+ }
}
function buildHelpMenu() {
@@ -1431,9 +1456,13 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
* Hide all the popover menus.
*/
window.hidePopoverMenus = () => {
- onEachLazy(document.querySelectorAll(".search-form .popover"), elem => {
+ onEachLazy(document.querySelectorAll("rustdoc-toolbar .popover"), elem => {
elem.style.display = "none";
});
+ const button = getHelpButton();
+ if (button) {
+ removeClass(button, "help-open");
+ }
};
/**
@@ -1458,7 +1487,9 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
function showHelp() {
// Prevent `blur` events from being dispatched as a result of closing
// other modals.
- getHelpButton().querySelector("a").focus();
+ const button = getHelpButton();
+ addClass(button, "help-open");
+ button.querySelector("a").focus();
const menu = getHelpMenu(true);
if (menu.style.display === "none") {
window.hideAllModals();
@@ -1466,28 +1497,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
}
}
+ const helpLink = document.querySelector(`#${HELP_BUTTON_ID} > a`);
if (isHelpPage) {
- showHelp();
- document.querySelector(`#${HELP_BUTTON_ID} > a`).addEventListener("click", event => {
- // Already on the help page, make help button a no-op.
- const target = event.target;
- if (target.tagName !== "A" ||
- target.parentElement.id !== HELP_BUTTON_ID ||
- event.ctrlKey ||
- event.altKey ||
- event.metaKey) {
- return;
- }
- event.preventDefault();
- });
- } else {
- document.querySelector(`#${HELP_BUTTON_ID} > a`).addEventListener("click", event => {
+ buildHelpMenu();
+ } else if (helpLink) {
+ helpLink.addEventListener("click", event => {
// By default, have help button open docs in a popover.
// If user clicks with a moderator, though, use default browser behavior,
// probably opening in a new window or tab.
- const target = event.target;
- if (target.tagName !== "A" ||
- target.parentElement.id !== HELP_BUTTON_ID ||
+ if (!helpLink.contains(helpLink) ||
event.ctrlKey ||
event.altKey ||
event.metaKey) {
@@ -1810,14 +1828,11 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
return;
}
but.onclick = () => {
- const parent = but.parentElement;
const path = [];
-
- onEach(parent.childNodes, child => {
- if (child.tagName === "A") {
- path.push(child.textContent);
- }
+ onEachLazy(document.querySelectorAll(".rustdoc-breadcrumbs a"), a => {
+ path.push(a.textContent);
});
+ path.push(document.querySelector("title").textContent.split(" ")[0]);
copyContentToClipboard(path.join("::"));
copyButtonAnimation(but);
diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js
index 4da0bbc787d9e..eed64d024c046 100644
--- a/src/librustdoc/html/static/js/search.js
+++ b/src/librustdoc/html/static/js/search.js
@@ -3597,15 +3597,16 @@ async function showResults(results, go_to_first, filterCrates) {
let crates = "";
if (rawSearchIndex.size > 1) {
- crates = " in ";
}
- let output = `
Results${crates}
`;
+ let output = `
\
+
Results
${crates}
`;
if (results.query.error !== null) {
const error = results.query.error;
error.forEach((value, index) => {
@@ -3662,6 +3663,9 @@ async function showResults(results, go_to_first, filterCrates) {
resultsElem.appendChild(ret_returned[0]);
search.innerHTML = output;
+ if (searchState.rustdocToolbar) {
+ search.querySelector(".main-heading").appendChild(searchState.rustdocToolbar);
+ }
const crateSearch = document.getElementById("crate-search");
if (crateSearch) {
crateSearch.addEventListener("input", updateCrate);
diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js
index c52a19ef98738..183663b94fc28 100644
--- a/src/librustdoc/html/static/js/settings.js
+++ b/src/librustdoc/html/static/js/settings.js
@@ -1,7 +1,7 @@
// Local js definitions:
/* global getSettingValue, updateLocalStorage, updateTheme */
-/* global addClass, removeClass, onEach, onEachLazy, blurHandler */
-/* global MAIN_ID, getVar, getSettingsButton */
+/* global addClass, removeClass, onEach, onEachLazy */
+/* global MAIN_ID, getVar, getSettingsButton, getHelpButton */
"use strict";
@@ -267,15 +267,16 @@
}
function settingsBlurHandler(event) {
- blurHandler(event, getSettingsButton(), window.hidePopoverMenus);
+ if (!getHelpButton().contains(document.activeElement) &&
+ !getHelpButton().contains(event.relatedTarget) &&
+ !getSettingsButton().contains(document.activeElement) &&
+ !getSettingsButton().contains(event.relatedTarget)
+ ) {
+ window.hidePopoverMenus();
+ }
}
- if (isSettingsPage) {
- // We replace the existing "onclick" callback to do nothing if clicked.
- getSettingsButton().onclick = event => {
- event.preventDefault();
- };
- } else {
+ if (!isSettingsPage) {
// We replace the existing "onclick" callback.
const settingsButton = getSettingsButton();
const settingsMenu = document.getElementById("settings");
diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js
index d75fb7a7fb5ab..d77804d045e36 100644
--- a/src/librustdoc/html/static/js/storage.js
+++ b/src/librustdoc/html/static/js/storage.js
@@ -274,16 +274,29 @@ class RustdocSearchElement extends HTMLElement {
spellcheck="false"
placeholder="Type ‘S’ or ‘/’ to search, ‘?’ for more options…"
type="search">
-
+{% match file_path %}
+{% when Some with ((path, name)) %}
+
{# #}
+
{# #}
+
{{path}}/
+ {{name}}
+
{# #}
+ {# #}
+
+{% else %}
+{% endmatch %}
+
{# #}
{# https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag#data-nosnippet-attr
Do not show "1 2 3 4 5 ..." in web search results. #}
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 6649e1721a48b..5f303d96c40df 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -10,6 +10,7 @@
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![feature(never_type)]
+#![feature(os_str_display)]
#![feature(round_char_boundary)]
#![feature(test)]
#![feature(type_alias_impl_trait)]
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 7b23aa3463923..09581bd03f863 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -1963,7 +1963,7 @@ impl<'test> TestCx<'test> {
#[rustfmt::skip]
let tidy_args = [
- "--new-blocklevel-tags", "rustdoc-search",
+ "--new-blocklevel-tags", "rustdoc-search,rustdoc-toolbar",
"--indent", "yes",
"--indent-spaces", "2",
"--wrap", "0",
diff --git a/src/tools/html-checker/main.rs b/src/tools/html-checker/main.rs
index ecfbb1955e779..5cdc4d53ab500 100644
--- a/src/tools/html-checker/main.rs
+++ b/src/tools/html-checker/main.rs
@@ -31,7 +31,7 @@ fn check_html_file(file: &Path) -> usize {
.arg("--mute-id") // this option is useful in case we want to mute more warnings
.arg("yes")
.arg("--new-blocklevel-tags")
- .arg("rustdoc-search") // custom elements
+ .arg("rustdoc-search,rustdoc-toolbar") // custom elements
.arg("--mute")
.arg(&to_mute_s)
.arg(file);
diff --git a/tests/rustdoc-gui/anchors.goml b/tests/rustdoc-gui/anchors.goml
index 61b2e8880c602..3168c8e17c52f 100644
--- a/tests/rustdoc-gui/anchors.goml
+++ b/tests/rustdoc-gui/anchors.goml
@@ -12,8 +12,7 @@ define-function: (
call-function: ("switch-theme", {"theme": |theme|})
assert-css: ("#toggle-all-docs", {"color": |main_color|})
- assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})
- assert-css: (".main-heading a:nth-of-type(2)", {"color": |main_heading_type_color|})
+ assert-css: (".main-heading h1 span", {"color": |main_heading_type_color|})
assert-css: (
".rightside a.src",
{"color": |src_link_color|, "text-decoration": "none solid " + |src_link_color|},
@@ -55,7 +54,7 @@ define-function: (
assert-css: ("#top-doc-prose-title", {"color": |title_color|})
assert-css: (".sidebar .block a", {"color": |sidebar_link_color|})
- assert-css: (".main-heading h1 a", {"color": |title_color|})
+ assert-css: (".main-heading h1", {"color": |title_color|})
// We move the cursor over the "Implementations" title so the anchor is displayed.
move-cursor-to: "h2#implementations"
diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml
index fed916ac24675..53f756dfcd64a 100644
--- a/tests/rustdoc-gui/docblock-code-block-line-number.goml
+++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml
@@ -87,7 +87,7 @@ assert-css: ("#settings", {"display": "block"})
// Then, click the toggle button.
click: "input#line-numbers"
-wait-for: 100 // wait-for-false does not exist
+wait-for: 100 // FIXME: `wait-for-false` does not exist
assert-false: "pre.example-line-numbers"
assert-local-storage: {"rustdoc-line-numbers": "false" }
@@ -107,6 +107,8 @@ assert-css: (
click: "input#line-numbers"
wait-for: "pre.example-line-numbers"
assert-local-storage: {"rustdoc-line-numbers": "true" }
+wait-for: 100 // FIXME: `wait-for-false` does not exist
+assert: "pre.example-line-numbers"
// Same check with scraped examples line numbers.
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
@@ -145,9 +147,6 @@ assert-css: (
ALL,
)
-// Checking line numbers on scraped code examples.
-go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
-
define-function: (
"check-padding",
[path, padding_bottom],
@@ -157,19 +156,19 @@ define-function: (
"padding-bottom": "0px",
"padding-left": "0px",
"padding-right": "0px",
- })
+ }, ALL)
assert-css: (|path| + " .src-line-numbers > pre", {
"padding-top": "14px",
"padding-bottom": |padding_bottom|,
"padding-left": "0px",
"padding-right": "0px",
- })
+ }, ALL)
assert-css: (|path| + " .src-line-numbers > pre > span", {
"padding-top": "0px",
"padding-bottom": "0px",
"padding-left": "8px",
"padding-right": "8px",
- })
+ }, ALL)
},
)
@@ -188,6 +187,35 @@ call-function: ("check-padding", {
"padding_bottom": "14px",
})
+define-function: ("check-line-numbers-existence", [], block {
+ assert-local-storage: {"rustdoc-line-numbers": "true" }
+ assert-false: ".example-line-numbers"
+ click: "#settings-menu"
+ wait-for: "#settings"
+
+ // Then, click the toggle button.
+ click: "input#line-numbers"
+ wait-for: 100 // FIXME: `wait-for-false` does not exist
+ assert-local-storage-false: {"rustdoc-line-numbers": "true" }
+ assert-false: ".example-line-numbers"
+ // Line numbers should still be there.
+ assert: ".src-line-numbers"
+ // Now disabling the setting.
+ click: "input#line-numbers"
+ wait-for: 100 // FIXME: `wait-for-false` does not exist
+ assert-local-storage: {"rustdoc-line-numbers": "true" }
+ assert-false: ".example-line-numbers"
+ // Line numbers should still be there.
+ assert: ".src-line-numbers"
+ // Closing settings menu.
+ click: "#settings-menu"
+ wait-for-css: ("#settings", {"display": "none"})
+})
+
+// Checking that turning off the line numbers setting won't remove line numbers from scraped
+// examples.
+call-function: ("check-line-numbers-existence", {})
+
// Now checking the line numbers in the source code page.
click: ".src"
assert-css: (".src-line-numbers", {
@@ -202,3 +230,28 @@ assert-css: (".src-line-numbers > a", {
"padding-left": "8px",
"padding-right": "8px",
})
+// Checking that turning off the line numbers setting won't remove line numbers.
+call-function: ("check-line-numbers-existence", {})
+
+// Now checking that even non-rust code blocks have line numbers generated.
+go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html"
+assert-local-storage: {"rustdoc-line-numbers": "true" }
+assert: ".example-wrap > pre.language-txt"
+assert: ".example-wrap > pre.rust"
+assert-count: (".example-wrap", 2)
+assert-count: (".example-wrap > pre.example-line-numbers", 2)
+
+click: "#settings-menu"
+wait-for: "#settings"
+
+// Then, click the toggle button.
+click: "input#line-numbers"
+wait-for: 100 // FIXME: `wait-for-false` does not exist
+assert-local-storage-false: {"rustdoc-line-numbers": "true" }
+assert-count: (".example-wrap > pre.example-line-numbers", 0)
+
+// Now turning off the setting.
+click: "input#line-numbers"
+wait-for: 100 // FIXME: `wait-for-false` does not exist
+assert-local-storage: {"rustdoc-line-numbers": "true" }
+assert-count: (".example-wrap > pre.example-line-numbers", 2)
diff --git a/tests/rustdoc-gui/help-page.goml b/tests/rustdoc-gui/help-page.goml
index f1a2675128ce4..6d6e353ae362b 100644
--- a/tests/rustdoc-gui/help-page.goml
+++ b/tests/rustdoc-gui/help-page.goml
@@ -4,7 +4,7 @@ set-window-size: (1000, 1000) // Try desktop size first.
wait-for: "#help"
assert-css: ("#help", {"display": "block"})
assert-css: ("#help dd", {"font-size": "16px"})
-click: "#help-button > a"
+assert-false: "#help-button > a"
assert-css: ("#help", {"display": "block"})
compare-elements-property: (".sub", "#help", ["offsetWidth"])
compare-elements-position: (".sub", "#help", ["x"])
@@ -50,7 +50,8 @@ call-function: ("check-colors", {
})
// This test ensures that opening the help popover without switching pages works.
-go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a"
+wait-for: "#search-tabs" // Waiting for the search.js to load.
set-window-size: (1000, 1000) // Only supported on desktop.
assert-false: "#help"
click: "#help-button > a"
@@ -62,7 +63,8 @@ compare-elements-property-false: (".sub", "#help", ["offsetWidth"])
compare-elements-position-false: (".sub", "#help", ["x"])
// This test ensures that the "the rustdoc book" anchor link within the help popover works.
-go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=a"
+wait-for: "#search-tabs" // Waiting for the search.js to load.
set-window-size: (1000, 1000) // Popover only appears when the screen width is >700px.
assert-false: "#help"
click: "#help-button > a"
diff --git a/tests/rustdoc-gui/item-info.goml b/tests/rustdoc-gui/item-info.goml
index 7a0194c6cc1f6..c8aa7b31cadc6 100644
--- a/tests/rustdoc-gui/item-info.goml
+++ b/tests/rustdoc-gui/item-info.goml
@@ -20,7 +20,7 @@ store-position: (
{"x": second_line_x, "y": second_line_y},
)
assert: |first_line_x| != |second_line_x| && |first_line_x| == 516 && |second_line_x| == 272
-assert: |first_line_y| != |second_line_y| && |first_line_y| == 688 && |second_line_y| == 711
+assert: |first_line_y| != |second_line_y| && |first_line_y| == 714 && |second_line_y| == 737
// Now we ensure that they're not rendered on the same line.
set-window-size: (1100, 800)
diff --git a/tests/rustdoc-gui/mobile.goml b/tests/rustdoc-gui/mobile.goml
index e576385cd5370..a9eee53dd1d50 100644
--- a/tests/rustdoc-gui/mobile.goml
+++ b/tests/rustdoc-gui/mobile.goml
@@ -5,23 +5,8 @@ set-window-size: (400, 600)
set-font-size: 18
wait-for: 100 // wait a bit for the resize and the font-size change to be fully taken into account.
-// The out-of-band info (source, stable version, collapse) should be below the
-// h1 when the screen gets narrow enough.
-assert-css: (".main-heading", {
- "display": "flex",
- "flex-direction": "column"
-})
-
assert-property: (".mobile-topbar h2", {"offsetHeight": 33})
-// Note: We can't use assert-text here because the 'Since' is set by CSS and
-// is therefore not part of the DOM.
-assert-css: (".content .out-of-band .since::before", { "content": "\"Since \"" })
-
-set-window-size: (1000, 1000)
-wait-for: 100 // wait a bit for the resize to be fully taken into account.
-assert-css-false: (".content .out-of-band .since::before", { "content": "\"Since \"" })
-
// On the settings page, the theme buttons should not line-wrap. Instead, they should
// all be placed as a group on a line below the setting name "Theme."
go-to: "file://" + |DOC_PATH| + "/settings.html"
diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml
index e2a8a43007eb0..b8fa26b17f6b6 100644
--- a/tests/rustdoc-gui/notable-trait.goml
+++ b/tests/rustdoc-gui/notable-trait.goml
@@ -248,12 +248,13 @@ click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
assert-count: ("//*[@class='tooltip popover']", 1)
assert-false: "//*[@class='sidebar shown']"
-// Also check the focus handling for the help button.
+// Also check the focus handling for the settings button.
set-window-size: (1100, 600)
reload:
assert-count: ("//*[@class='tooltip popover']", 0)
click: "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']"
assert-count: ("//*[@class='tooltip popover']", 1)
-click: "#help-button a"
+click: "#settings-menu a"
+wait-for: "#settings"
assert-count: ("//*[@class='tooltip popover']", 0)
assert-false: "#method\.create_an_iterator_from_read .tooltip:focus"
diff --git a/tests/rustdoc-gui/pocket-menu.goml b/tests/rustdoc-gui/pocket-menu.goml
index ec31f492abe7c..4a062fec7516d 100644
--- a/tests/rustdoc-gui/pocket-menu.goml
+++ b/tests/rustdoc-gui/pocket-menu.goml
@@ -1,6 +1,7 @@
// This test ensures that the "pocket menus" are working as expected.
include: "utils.goml"
-go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=test"
+wait-for: "#crate-search"
// First we check that the help menu doesn't exist yet.
assert-false: "#help-button .popover"
// Then we display the help menu.
diff --git a/tests/rustdoc-gui/scrape-examples-layout.goml b/tests/rustdoc-gui/scrape-examples-layout.goml
index be14e202b37d0..fd0774c91b675 100644
--- a/tests/rustdoc-gui/scrape-examples-layout.goml
+++ b/tests/rustdoc-gui/scrape-examples-layout.goml
@@ -80,8 +80,8 @@ click: ".scraped-example .button-holder .expand"
store-value: (offset_y, 4)
// First with desktop
-assert-position: (".scraped-example", {"y": 226})
-assert-position: (".scraped-example .prev", {"y": 226 + |offset_y|})
+assert-position: (".scraped-example", {"y": 252})
+assert-position: (".scraped-example .prev", {"y": 252 + |offset_y|})
// Gradient background should be at the top of the code block.
assert-css: (".scraped-example .example-wrap::before", {"top": "0px"})
@@ -90,8 +90,8 @@ assert-css: (".scraped-example .example-wrap::after", {"bottom": "0px"})
// Then with mobile
set-window-size: (600, 600)
store-size: (".scraped-example .scraped-example-title", {"height": title_height})
-assert-position: (".scraped-example", {"y": 284})
-assert-position: (".scraped-example .prev", {"y": 284 + |offset_y| + |title_height|})
+assert-position: (".scraped-example", {"y": 281})
+assert-position: (".scraped-example .prev", {"y": 281 + |offset_y| + |title_height|})
define-function: (
"check_title_and_code_position",
diff --git a/tests/rustdoc-gui/search-filter.goml b/tests/rustdoc-gui/search-filter.goml
index d6421599a207b..c5038e0892b04 100644
--- a/tests/rustdoc-gui/search-filter.goml
+++ b/tests/rustdoc-gui/search-filter.goml
@@ -56,7 +56,8 @@ assert-property: ("#crate-search", {"value": "lib2"})
assert-false: "#results .externcrate"
// Checking that the text for the "title" is correct (the "all crates" comes from the "").
-assert-text: (".search-results-title", "Results in all crates", STARTS_WITH)
+assert-text: (".search-results-title", "Results", STARTS_WITH)
+assert-text: (".search-results-title + .sub-heading", " in all crates", STARTS_WITH)
// Checking the display of the crate filter.
// We start with the light theme.
@@ -84,6 +85,6 @@ wait-for-css: ("#crate-search", {
click: "#theme-ayu"
wait-for-css: ("#crate-search", {
"border": "1px solid #5c6773",
- "color": "#fff",
+ "color": "#c5c5c5",
"background-color": "#0f1419",
})
diff --git a/tests/rustdoc-gui/search-form-elements.goml b/tests/rustdoc-gui/search-form-elements.goml
index 63d2ceb3e7c1c..efe39f7a9d1bf 100644
--- a/tests/rustdoc-gui/search-form-elements.goml
+++ b/tests/rustdoc-gui/search-form-elements.goml
@@ -1,13 +1,14 @@
// This test ensures that the elements in ".search-form" have the expected display.
include: "utils.goml"
-go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
+go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=test"
+wait-for: "#search-tabs" // Waiting for the search.js to load.
show-text: true
define-function: (
"check-search-colors",
[
theme, border, background, search_input_color, search_input_border_focus,
- menu_button_border, menu_button_a_color, menu_button_a_border_hover, menu_a_color,
+ menu_button_a_color, menu_button_a_border_hover, menu_a_color,
],
block {
call-function: ("switch-theme", {"theme": |theme|})
@@ -29,30 +30,22 @@ define-function: (
"color": |search_input_color|,
},
)
- assert-css: (
- "#help-button",
- {"border-color": |menu_button_border|},
- )
assert-css: (
"#help-button > a",
{
"color": |menu_button_a_color|,
- "border-color": |border|,
- "background-color": |background|,
+ "border-color": "transparent",
+ "background-color": "transparent",
},
)
// Hover help button.
move-cursor-to: "#help-button"
- assert-css: (
- "#help-button:hover",
- {"border-color": |menu_button_border|},
- )
assert-css: (
"#help-button > a",
{
"color": |menu_button_a_color|,
"border-color": |menu_button_a_border_hover|,
- "background-color": |background|,
+ "background-color": "transparent",
},
)
// Link color inside
@@ -63,30 +56,22 @@ define-function: (
"color": |menu_a_color|,
},
)
- assert-css: (
- "#settings-menu",
- {"border-color": |menu_button_border|},
- )
assert-css: (
"#settings-menu > a",
{
"color": |menu_button_a_color|,
- "border-color": |border|,
- "background-color": |background|,
+ "border-color": "transparent",
+ "background-color": "transparent",
},
)
// Hover settings menu.
move-cursor-to: "#settings-menu"
- assert-css: (
- "#settings-menu:hover",
- {"border-color": |menu_button_border|},
- )
assert-css: (
"#settings-menu:hover > a",
{
"color": |menu_button_a_color|,
"border-color": |menu_button_a_border_hover|,
- "background-color": |background|,
+ "background-color": "transparent",
},
)
},
@@ -100,8 +85,7 @@ call-function: (
"background": "#141920",
"search_input_color": "#fff",
"search_input_border_focus": "#5c6773",
- "menu_button_border": "#c5c5c5",
- "menu_button_a_color": "#fff",
+ "menu_button_a_color": "#c5c5c5",
"menu_button_a_border_hover": "#e0e0e0",
"menu_a_color": "#39afd7",
}
@@ -114,8 +98,7 @@ call-function: (
"background": "#f0f0f0",
"search_input_color": "#111",
"search_input_border_focus": "#008dfd",
- "menu_button_border": "#ddd",
- "menu_button_a_color": "#000",
+ "menu_button_a_color": "#ddd",
"menu_button_a_border_hover": "#ffb900",
"menu_a_color": "#d2991d",
}
@@ -128,7 +111,6 @@ call-function: (
"background": "#fff",
"search_input_color": "#000",
"search_input_border_focus": "#66afe9",
- "menu_button_border": "#000",
"menu_button_a_color": "#000",
"menu_button_a_border_hover": "#717171",
"menu_a_color": "#3873ad",
diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml
index 3ca46f3c56931..156244f92b4f5 100644
--- a/tests/rustdoc-gui/search-result-display.goml
+++ b/tests/rustdoc-gui/search-result-display.goml
@@ -50,8 +50,11 @@ compare-elements-size-near: (
set-window-size: (900, 900)
// First we check the current width, height and position.
-assert-css: ("#crate-search", {"width": "223px"})
-assert-css: (".search-results-title", {"height": "50px", "width": "640px"})
+assert-css: ("#crate-search", {"width": "159px"})
+store-size: (".search-results-title", {
+ "height": search_results_title_height,
+ "width": search_results_title_width,
+})
assert-css: ("#search", {"width": "640px"})
// Then we update the text of one of the `