Skip to content

Commit 51126be

Browse files
committed
Auto merge of #93260 - matthiaskrgr:rollup-c5b9c76, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #92513 (std: Implement try_reserve and try_reserve_exact on PathBuf) - #93152 (Fix STD compilation for the ESP-IDF target (regression from CVE-2022-21658)) - #93186 (Fix link to CVE-2022-21658) - #93188 (rustdoc: fix bump down typing search on Safari) - #93212 (Remove unneeded cursor pointer rule on mobile sidebar) - #93231 (adjust sidebar link brightness) - #93241 (Fix brief appearance of rust logo in the sidebar) - #93253 (Update theme on pageshow event) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d2dc425 + ee35ed3 commit 51126be

File tree

11 files changed

+124
-15
lines changed

11 files changed

+124
-15
lines changed

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Version 1.58.1 (2022-01-19)
77
* [Fix wrong error message displayed when some imports are missing][91254]
88
* [Fix rustfmt not formatting generated files from stdin][92912]
99

10-
[CVE-2022-21658]: https://www.cve.org/CVERecord?id=CVE-2022-21658]
10+
[CVE-2022-21658]: https://www.cve.org/CVERecord?id=CVE-2022-21658
1111
[91254]: https://github.com/rust-lang/rust/pull/91254
1212
[92912]: https://github.com/rust-lang/rust/pull/92912
1313
[clippy/8075]: https://github.com/rust-lang/rust-clippy/pull/8075

library/std/src/path.rs

+19
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ mod tests;
7272

7373
use crate::borrow::{Borrow, Cow};
7474
use crate::cmp;
75+
use crate::collections::TryReserveError;
7576
use crate::error::Error;
7677
use crate::fmt;
7778
use crate::fs;
@@ -1512,6 +1513,15 @@ impl PathBuf {
15121513
self.inner.reserve(additional)
15131514
}
15141515

1516+
/// Invokes [`try_reserve`] on the underlying instance of [`OsString`].
1517+
///
1518+
/// [`try_reserve`]: OsString::try_reserve
1519+
#[unstable(feature = "try_reserve_2", issue = "91789")]
1520+
#[inline]
1521+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
1522+
self.inner.try_reserve(additional)
1523+
}
1524+
15151525
/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`].
15161526
///
15171527
/// [`reserve_exact`]: OsString::reserve_exact
@@ -1521,6 +1531,15 @@ impl PathBuf {
15211531
self.inner.reserve_exact(additional)
15221532
}
15231533

1534+
/// Invokes [`try_reserve_exact`] on the underlying instance of [`OsString`].
1535+
///
1536+
/// [`try_reserve_exact`]: OsString::try_reserve_exact
1537+
#[unstable(feature = "try_reserve_2", issue = "91789")]
1538+
#[inline]
1539+
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
1540+
self.inner.try_reserve_exact(additional)
1541+
}
1542+
15241543
/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`].
15251544
///
15261545
/// [`shrink_to_fit`]: OsString::shrink_to_fit

library/std/src/sys/unix/fs.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,8 @@ pub fn chroot(dir: &Path) -> io::Result<()> {
14481448

14491449
pub use remove_dir_impl::remove_dir_all;
14501450

1451-
// Fallback for REDOX
1452-
#[cfg(target_os = "redox")]
1451+
// Fallback for REDOX and ESP-IDF
1452+
#[cfg(any(target_os = "redox", target_os = "espidf"))]
14531453
mod remove_dir_impl {
14541454
pub use crate::sys_common::fs::remove_dir_all;
14551455
}
@@ -1573,7 +1573,11 @@ mod remove_dir_impl {
15731573
}
15741574

15751575
// Modern implementation using openat(), unlinkat() and fdopendir()
1576-
#[cfg(not(any(all(target_os = "macos", target_arch = "x86_64"), target_os = "redox")))]
1576+
#[cfg(not(any(
1577+
all(target_os = "macos", target_arch = "x86_64"),
1578+
target_os = "redox",
1579+
target_os = "espidf"
1580+
)))]
15771581
mod remove_dir_impl {
15781582
use super::{cstr, lstat, Dir, DirEntry, InnerReadDir, ReadDir};
15791583
use crate::ffi::CStr;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ nav.sub {
397397
}
398398

399399
.source .sidebar > *:not(:first-child) {
400-
transition: opacity 0.5s, visibility 0.2s;
400+
transition: opacity 0.5s;
401401
opacity: 0;
402402
visibility: hidden;
403403
}
@@ -1848,7 +1848,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
18481848
position: sticky;
18491849
z-index: 10;
18501850
font-size: 2rem;
1851-
cursor: pointer;
18521851
height: 45px;
18531852
width: 100%;
18541853
left: 0;

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

+23
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ pre, .rustdoc.source .example-wrap {
191191
color: #a37acc;
192192
}
193193

194+
.sidebar a { color: #53b1db; }
195+
.sidebar a.current.type { color: #53b1db; }
196+
.sidebar a.current.associatedtype { color: #53b1db; }
197+
194198
pre.rust .comment { color: #788797; }
195199
pre.rust .doccomment { color: #a1ac88; }
196200

@@ -485,6 +489,25 @@ a.result-static:focus {}
485489
a.result-primitive:focus {}
486490
a.result-keyword:focus {}
487491

492+
.sidebar a.current.enum {}
493+
.sidebar a.current.struct {}
494+
.sidebar a.current.foreigntype {}
495+
.sidebar a.current.attr,
496+
.sidebar a.current.derive,
497+
.sidebar a.current.macro {}
498+
.sidebar a.current.union {}
499+
.sidebar a.current.constant
500+
.sidebar a.current.static {}
501+
.sidebar a.current.primitive {}
502+
.sidebar a.current.externcrate
503+
.sidebar a.current.mod {}
504+
.sidebar a.current.trait {}
505+
.sidebar a.current.traitalias {}
506+
.sidebar a.current.fn,
507+
.sidebar a.current.method,
508+
.sidebar a.current.tymethod {}
509+
.sidebar a.current.keyword {}
510+
488511
@media (max-width: 700px) {
489512
.sidebar-menu {
490513
background-color: #14191f;

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

+22
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,28 @@ a.result-keyword:focus { background-color: #884719; }
148148
.content .fnname{ color: #2BAB63; }
149149
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #D2991D; }
150150

151+
.sidebar a { color: #fdbf35; }
152+
.sidebar a.current.enum { color: #12ece2; }
153+
.sidebar a.current.struct { color: #12ece2; }
154+
.sidebar a.current.type { color: #12ece2; }
155+
.sidebar a.current.associatedtype { color: #fdbf35; }
156+
.sidebar a.current.foreigntype { color: #12ece2; }
157+
.sidebar a.current.attr,
158+
.sidebar a.current.derive,
159+
.sidebar a.current.macro { color: #0be900; }
160+
.sidebar a.current.union { color: #12ece2; }
161+
.sidebar a.current.constant
162+
.sidebar a.current.static { color: #fdbf35; }
163+
.sidebar a.current.primitive { color: #12ece2; }
164+
.sidebar a.current.externcrate
165+
.sidebar a.current.mod { color: #fdbf35; }
166+
.sidebar a.current.trait { color: #cca7ff; }
167+
.sidebar a.current.traitalias { color: #cca7ff; }
168+
.sidebar a.current.fn,
169+
.sidebar a.current.method,
170+
.sidebar a.current.tymethod { color: #32d479; }
171+
.sidebar a.current.keyword { color: #fdbf35; }
172+
151173
pre.rust .comment { color: #8d8d8b; }
152174
pre.rust .doccomment { color: #8ca375; }
153175

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

+22
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,28 @@ a.result-keyword:focus { background-color: #afc6e4; }
148148
.content .fnname { color: #AD7C37; }
149149
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #3873AD; }
150150

151+
.sidebar a { color: #356da4; }
152+
.sidebar a.current.enum { color: #a63283; }
153+
.sidebar a.current.struct { color: #a63283; }
154+
.sidebar a.current.type { color: #a63283; }
155+
.sidebar a.current.associatedtype { color: #356da4; }
156+
.sidebar a.current.foreigntype { color: #356da4; }
157+
.sidebar a.current.attr,
158+
.sidebar a.current.derive,
159+
.sidebar a.current.macro { color: #067901; }
160+
.sidebar a.current.union { color: #a63283; }
161+
.sidebar a.current.constant
162+
.sidebar a.current.static { color: #356da4; }
163+
.sidebar a.current.primitive { color: #a63283; }
164+
.sidebar a.current.externcrate
165+
.sidebar a.current.mod { color: #356da4; }
166+
.sidebar a.current.trait { color: #6849c3; }
167+
.sidebar a.current.traitalias { color: #4b349e; }
168+
.sidebar a.current.fn,
169+
.sidebar a.current.method,
170+
.sidebar a.current.tymethod { color: #32d479; }
171+
.sidebar a.current.keyword { color: #356da4; }
172+
151173
nav.main .current {
152174
border-top-color: #000;
153175
border-bottom-color: #000;

src/librustdoc/html/static/js/storage.js

+25-6
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ var updateSystemTheme = (function() {
216216
};
217217
})();
218218

219+
function switchToSavedTheme() {
220+
switchTheme(
221+
window.currentTheme,
222+
window.mainTheme,
223+
getSettingValue("theme") || "light",
224+
false
225+
);
226+
}
227+
219228
if (getSettingValue("use-system-theme") !== "false" && window.matchMedia) {
220229
// update the preferred dark theme if the user is already using a dark theme
221230
// See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
@@ -228,10 +237,20 @@ if (getSettingValue("use-system-theme") !== "false" && window.matchMedia) {
228237
// call the function to initialize the theme at least once!
229238
updateSystemTheme();
230239
} else {
231-
switchTheme(
232-
window.currentTheme,
233-
window.mainTheme,
234-
getSettingValue("theme") || "light",
235-
false
236-
);
240+
switchToSavedTheme();
237241
}
242+
243+
// If we navigate away (for example to a settings page), and then use the back or
244+
// forward button to get back to a page, the theme may have changed in the meantime.
245+
// But scripts may not be re-loaded in such a case due to the bfcache
246+
// (https://web.dev/bfcache/). The "pageshow" event triggers on such navigations.
247+
// Use that opportunity to update the theme.
248+
// We use a setTimeout with a 0 timeout here to put the change on the event queue.
249+
// For some reason, if we try to change the theme while the `pageshow` event is
250+
// running, it sometimes fails to take effect. The problem manifests on Chrome,
251+
// specifically when talking to a remote website with no caching.
252+
window.addEventListener("pageshow", function(ev) {
253+
if (ev.persisted) {
254+
setTimeout(switchToSavedTheme, 0);
255+
}
256+
});

src/librustdoc/html/templates/page.html

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ <h2 class="location"></h2>
117117
</div> {#- -#}
118118
<form class="search-form"> {#- -#}
119119
<div class="search-container"> {#- -#}
120+
<span></span> {#- This empty span is a hacky fix for Safari - See #93184 -#}
120121
<input {# -#}
121122
class="search-input" {# -#}
122123
name="search" {# -#}

src/test/rustdoc-gui/anchors.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ assert-css: (".srclink", {"text-decoration": "underline solid rgb(56, 115, 173)"
2020

2121
assert-css: ("#top-doc-prose-title", {"color": "rgb(0, 0, 0)"})
2222

23-
assert-css: (".sidebar a", {"color": "rgb(56, 115, 173)"})
23+
assert-css: (".sidebar a", {"color": "rgb(53, 109, 164)"})
2424
assert-css: (".in-band a", {"color": "rgb(0, 0, 0)"})
2525

2626
// We move the cursor over the "Implementations" title so the anchor is displayed.

src/test/rustdoc-gui/sidebar.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ assert-text: (".sidebar > .location", "Crate test_docs")
99
// In modules, we only have one "location" element.
1010
assert-count: (".sidebar .location", 1)
1111
assert-text: ("#all-types", "All Items")
12-
assert-css: ("#all-types", {"color": "rgb(56, 115, 173)"})
12+
assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
1313
// We check that we have the crates list and that the "current" on is "test_docs".
1414
assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs")
1515
// And we're also supposed to have the list of items in the current module.
@@ -38,7 +38,7 @@ assert-property: ("html", {"scrollTop": "0"})
3838

3939
// We now go back to the crate page to click on the "lib2" crate link.
4040
goto: file://|DOC_PATH|/test_docs/index.html
41-
assert-css: (".sidebar-elems .crate > ul > li:first-child > a", {"color": "rgb(56, 115, 173)"})
41+
assert-css: (".sidebar-elems .crate > ul > li:first-child > a", {"color": "rgb(53, 109, 164)"})
4242
click: ".sidebar-elems .crate > ul > li:first-child > a"
4343

4444
// PAGE: lib2/index.html

0 commit comments

Comments
 (0)