Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #93260

Merged
merged 19 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
edae82e
std: Implement try_reserve and try_reserve_exact on PathBuf
Xuanwo Jan 3, 2022
495c7b3
Fix STD compilation for the ESP-IDF target
ivmarkov Jan 21, 2022
91b9b6a
Fix link to CVE-2022-21658
kraai Jan 22, 2022
9f30dd9
Remove unneeded cursor pointer rule on mobile sidebar
GuillaumeGomez Jan 22, 2022
9c3ffd7
adjust sidebar link brightness
conradludgate Jan 23, 2022
a0748d9
tweak all sidebar colours
conradludgate Jan 23, 2022
f00b02b
remove duplicate rule
conradludgate Jan 23, 2022
d889a4e
Fix brief appearance of rust logo in the sidebar
GuillaumeGomez Jan 23, 2022
ca3d0e2
update tests
conradludgate Jan 23, 2022
bc8ef4c
rustdoc: fix bump down typing search on Safari
jsha Jan 23, 2022
b30725e
Update theme on pageshow event
jsha Jan 23, 2022
b92a1e9
Rollup merge of #92513 - Xuanwo:path-buf, r=dtolnay
matthiaskrgr Jan 24, 2022
144aeed
Rollup merge of #93152 - ivmarkov:master, r=m-ou-se
matthiaskrgr Jan 24, 2022
8491fb3
Rollup merge of #93186 - kraai:fix-CVE-2022-21658-link, r=m-ou-se
matthiaskrgr Jan 24, 2022
cce8023
Rollup merge of #93188 - jsha:fix-safari-bumpy-search, r=camelid
matthiaskrgr Jan 24, 2022
26f14bb
Rollup merge of #93212 - GuillaumeGomez:cursor-pointer-mobile-sidebar…
matthiaskrgr Jan 24, 2022
ed1fea8
Rollup merge of #93231 - conradludgate:doc-link-brightness, r=notriddle
matthiaskrgr Jan 24, 2022
d1aa2f7
Rollup merge of #93241 - GuillaumeGomez:rust-logo-appearance, r=jsha
matthiaskrgr Jan 24, 2022
ee35ed3
Rollup merge of #93253 - jsha:theme-on-show, r=GuillaumeGomez
matthiaskrgr Jan 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Version 1.58.1 (2022-01-19)
* [Fix wrong error message displayed when some imports are missing][91254]
* [Fix rustfmt not formatting generated files from stdin][92912]

[CVE-2022-21658]: https://www.cve.org/CVERecord?id=CVE-2022-21658]
[CVE-2022-21658]: https://www.cve.org/CVERecord?id=CVE-2022-21658
[91254]: https://github.com/rust-lang/rust/pull/91254
[92912]: https://github.com/rust-lang/rust/pull/92912
[clippy/8075]: https://github.com/rust-lang/rust-clippy/pull/8075
Expand Down
19 changes: 19 additions & 0 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ mod tests;

use crate::borrow::{Borrow, Cow};
use crate::cmp;
use crate::collections::TryReserveError;
use crate::error::Error;
use crate::fmt;
use crate::fs;
Expand Down Expand Up @@ -1512,6 +1513,15 @@ impl PathBuf {
self.inner.reserve(additional)
}

/// Invokes [`try_reserve`] on the underlying instance of [`OsString`].
///
/// [`try_reserve`]: OsString::try_reserve
#[unstable(feature = "try_reserve_2", issue = "91789")]
#[inline]
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
self.inner.try_reserve(additional)
}

/// Invokes [`reserve_exact`] on the underlying instance of [`OsString`].
///
/// [`reserve_exact`]: OsString::reserve_exact
Expand All @@ -1521,6 +1531,15 @@ impl PathBuf {
self.inner.reserve_exact(additional)
}

/// Invokes [`try_reserve_exact`] on the underlying instance of [`OsString`].
///
/// [`try_reserve_exact`]: OsString::try_reserve_exact
#[unstable(feature = "try_reserve_2", issue = "91789")]
#[inline]
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
self.inner.try_reserve_exact(additional)
}

/// Invokes [`shrink_to_fit`] on the underlying instance of [`OsString`].
///
/// [`shrink_to_fit`]: OsString::shrink_to_fit
Expand Down
10 changes: 7 additions & 3 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,8 @@ pub fn chroot(dir: &Path) -> io::Result<()> {

pub use remove_dir_impl::remove_dir_all;

// Fallback for REDOX
#[cfg(target_os = "redox")]
// Fallback for REDOX and ESP-IDF
#[cfg(any(target_os = "redox", target_os = "espidf"))]
mod remove_dir_impl {
pub use crate::sys_common::fs::remove_dir_all;
}
Expand Down Expand Up @@ -1573,7 +1573,11 @@ mod remove_dir_impl {
}

// Modern implementation using openat(), unlinkat() and fdopendir()
#[cfg(not(any(all(target_os = "macos", target_arch = "x86_64"), target_os = "redox")))]
#[cfg(not(any(
all(target_os = "macos", target_arch = "x86_64"),
target_os = "redox",
target_os = "espidf"
)))]
mod remove_dir_impl {
use super::{cstr, lstat, Dir, DirEntry, InnerReadDir, ReadDir};
use crate::ffi::CStr;
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ nav.sub {
}

.source .sidebar > *:not(:first-child) {
transition: opacity 0.5s, visibility 0.2s;
transition: opacity 0.5s;
opacity: 0;
visibility: hidden;
}
Expand Down Expand Up @@ -1848,7 +1848,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
position: sticky;
z-index: 10;
font-size: 2rem;
cursor: pointer;
height: 45px;
width: 100%;
left: 0;
Expand Down
23 changes: 23 additions & 0 deletions src/librustdoc/html/static/css/themes/ayu.css
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ pre, .rustdoc.source .example-wrap {
color: #a37acc;
}

.sidebar a { color: #53b1db; }
.sidebar a.current.type { color: #53b1db; }
.sidebar a.current.associatedtype { color: #53b1db; }

pre.rust .comment { color: #788797; }
pre.rust .doccomment { color: #a1ac88; }

Expand Down Expand Up @@ -485,6 +489,25 @@ a.result-static:focus {}
a.result-primitive:focus {}
a.result-keyword:focus {}

.sidebar a.current.enum {}
.sidebar a.current.struct {}
.sidebar a.current.foreigntype {}
.sidebar a.current.attr,
.sidebar a.current.derive,
.sidebar a.current.macro {}
.sidebar a.current.union {}
.sidebar a.current.constant
.sidebar a.current.static {}
.sidebar a.current.primitive {}
.sidebar a.current.externcrate
.sidebar a.current.mod {}
.sidebar a.current.trait {}
.sidebar a.current.traitalias {}
.sidebar a.current.fn,
.sidebar a.current.method,
.sidebar a.current.tymethod {}
.sidebar a.current.keyword {}

@media (max-width: 700px) {
.sidebar-menu {
background-color: #14191f;
Expand Down
22 changes: 22 additions & 0 deletions src/librustdoc/html/static/css/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,28 @@ a.result-keyword:focus { background-color: #884719; }
.content .fnname{ color: #2BAB63; }
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #D2991D; }

.sidebar a { color: #fdbf35; }
.sidebar a.current.enum { color: #12ece2; }
.sidebar a.current.struct { color: #12ece2; }
.sidebar a.current.type { color: #12ece2; }
.sidebar a.current.associatedtype { color: #fdbf35; }
.sidebar a.current.foreigntype { color: #12ece2; }
.sidebar a.current.attr,
.sidebar a.current.derive,
.sidebar a.current.macro { color: #0be900; }
.sidebar a.current.union { color: #12ece2; }
.sidebar a.current.constant
.sidebar a.current.static { color: #fdbf35; }
.sidebar a.current.primitive { color: #12ece2; }
.sidebar a.current.externcrate
.sidebar a.current.mod { color: #fdbf35; }
.sidebar a.current.trait { color: #cca7ff; }
.sidebar a.current.traitalias { color: #cca7ff; }
.sidebar a.current.fn,
.sidebar a.current.method,
.sidebar a.current.tymethod { color: #32d479; }
.sidebar a.current.keyword { color: #fdbf35; }

pre.rust .comment { color: #8d8d8b; }
pre.rust .doccomment { color: #8ca375; }

Expand Down
22 changes: 22 additions & 0 deletions src/librustdoc/html/static/css/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,28 @@ a.result-keyword:focus { background-color: #afc6e4; }
.content .fnname { color: #AD7C37; }
.content span.keyword, .content a.keyword, .block a.current.keyword { color: #3873AD; }

.sidebar a { color: #356da4; }
.sidebar a.current.enum { color: #a63283; }
.sidebar a.current.struct { color: #a63283; }
.sidebar a.current.type { color: #a63283; }
.sidebar a.current.associatedtype { color: #356da4; }
.sidebar a.current.foreigntype { color: #356da4; }
.sidebar a.current.attr,
.sidebar a.current.derive,
.sidebar a.current.macro { color: #067901; }
.sidebar a.current.union { color: #a63283; }
.sidebar a.current.constant
.sidebar a.current.static { color: #356da4; }
.sidebar a.current.primitive { color: #a63283; }
.sidebar a.current.externcrate
.sidebar a.current.mod { color: #356da4; }
.sidebar a.current.trait { color: #6849c3; }
.sidebar a.current.traitalias { color: #4b349e; }
.sidebar a.current.fn,
.sidebar a.current.method,
.sidebar a.current.tymethod { color: #32d479; }
.sidebar a.current.keyword { color: #356da4; }

nav.main .current {
border-top-color: #000;
border-bottom-color: #000;
Expand Down
31 changes: 25 additions & 6 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ var updateSystemTheme = (function() {
};
})();

function switchToSavedTheme() {
switchTheme(
window.currentTheme,
window.mainTheme,
getSettingValue("theme") || "light",
false
);
}

if (getSettingValue("use-system-theme") !== "false" && window.matchMedia) {
// update the preferred dark theme if the user is already using a dark theme
// See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
Expand All @@ -228,10 +237,20 @@ if (getSettingValue("use-system-theme") !== "false" && window.matchMedia) {
// call the function to initialize the theme at least once!
updateSystemTheme();
} else {
switchTheme(
window.currentTheme,
window.mainTheme,
getSettingValue("theme") || "light",
false
);
switchToSavedTheme();
}

// If we navigate away (for example to a settings page), and then use the back or
// forward button to get back to a page, the theme may have changed in the meantime.
// But scripts may not be re-loaded in such a case due to the bfcache
// (https://web.dev/bfcache/). The "pageshow" event triggers on such navigations.
// Use that opportunity to update the theme.
// We use a setTimeout with a 0 timeout here to put the change on the event queue.
// For some reason, if we try to change the theme while the `pageshow` event is
// running, it sometimes fails to take effect. The problem manifests on Chrome,
// specifically when talking to a remote website with no caching.
window.addEventListener("pageshow", function(ev) {
if (ev.persisted) {
setTimeout(switchToSavedTheme, 0);
}
});
1 change: 1 addition & 0 deletions src/librustdoc/html/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ <h2 class="location"></h2>
</div> {#- -#}
<form class="search-form"> {#- -#}
<div class="search-container"> {#- -#}
<span></span> {#- This empty span is a hacky fix for Safari - See #93184 -#}
<input {# -#}
class="search-input" {# -#}
name="search" {# -#}
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/anchors.goml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ assert-css: (".srclink", {"text-decoration": "underline solid rgb(56, 115, 173)"

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

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

// We move the cursor over the "Implementations" title so the anchor is displayed.
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-gui/sidebar.goml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assert-text: (".sidebar > .location", "Crate test_docs")
// In modules, we only have one "location" element.
assert-count: (".sidebar .location", 1)
assert-text: ("#all-types", "All Items")
assert-css: ("#all-types", {"color": "rgb(56, 115, 173)"})
assert-css: ("#all-types", {"color": "rgb(53, 109, 164)"})
// We check that we have the crates list and that the "current" on is "test_docs".
assert-text: (".sidebar-elems .crate > ul > li > a.current", "test_docs")
// And we're also supposed to have the list of items in the current module.
Expand Down Expand Up @@ -38,7 +38,7 @@ assert-property: ("html", {"scrollTop": "0"})

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

// PAGE: lib2/index.html
Expand Down