Skip to content

Commit 9e124c4

Browse files
committed
Auto merge of #110076 - Nilstrieb:rollup-22yp01c, r=Nilstrieb
Rollup of 5 pull requests Successful merges: - #110030 (rustdoc: clean up JS) - #110037 (rustdoc: add test and bug fix for theme defaults) - #110065 (Fix wrong type in docs: i16 -> u16) - #110068 (Temporarily remove myself from reviewers list) - #110075 (Fix a typo in `config.example.toml`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents c49c4fb + f80c60c commit 9e124c4

File tree

7 files changed

+38
-33
lines changed

7 files changed

+38
-33
lines changed

config.example.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Use different pre-set defaults than the global defaults.
1717
#
1818
# See `src/bootstrap/defaults` for more information.
19-
# Note that this has no default value (x.py uses the defaults in `config.toml.example`).
19+
# Note that this has no default value (x.py uses the defaults in `config.example.toml`).
2020
#profile = <none>
2121

2222
# Keeps track of the last version of `x.py` used.

library/core/src/num/shells/u16.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Redundant constants module for the [`i16` primitive type][i16].
1+
//! Redundant constants module for the [`u16` primitive type][u16].
22
//!
33
//! New code should use the associated constants directly on the primitive type.
44

src/librustdoc/html/static/js/main.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,7 @@ function preLoadCss(cssUrl) {
332332
};
333333

334334
function getPageId() {
335-
if (window.location.hash) {
336-
const tmp = window.location.hash.replace(/^#/, "");
337-
if (tmp.length > 0) {
338-
return tmp;
339-
}
340-
}
341-
return null;
335+
return window.location.hash.replace(/^#/, "");
342336
}
343337

344338
const toggleAllDocsId = "toggle-all-docs";
@@ -707,7 +701,7 @@ function preLoadCss(cssUrl) {
707701
});
708702

709703
const pageId = getPageId();
710-
if (pageId !== null) {
704+
if (pageId !== "") {
711705
expandSection(pageId);
712706
}
713707
}());

src/librustdoc/html/static/js/settings.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,8 @@
8686
if (settingId === "theme") {
8787
const useSystem = getSettingValue("use-system-theme");
8888
if (useSystem === "true" || settingValue === null) {
89-
if (useSystem !== "false") {
90-
settingValue = "system preference";
91-
} else {
92-
// This is the default theme.
93-
settingValue = "light";
94-
}
89+
// "light" is the default theme
90+
settingValue = useSystem === "false" ? "light" : "system preference";
9591
}
9692
}
9793
if (settingValue !== null && settingValue !== "null") {

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

+6-14
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ function removeClass(elem, className) {
5353
* @param {boolean} [reversed] - Whether to iterate in reverse
5454
*/
5555
function onEach(arr, func, reversed) {
56-
if (arr && arr.length > 0 && func) {
56+
if (arr && arr.length > 0) {
5757
if (reversed) {
58-
const length = arr.length;
59-
for (let i = length - 1; i >= 0; --i) {
58+
for (let i = arr.length - 1; i >= 0; --i) {
6059
if (func(arr[i])) {
6160
return true;
6261
}
@@ -150,26 +149,19 @@ const updateTheme = (function() {
150149
* … dictates that it should be.
151150
*/
152151
function updateTheme() {
153-
const use = (theme, saveTheme) => {
154-
switchTheme(theme, saveTheme);
155-
};
156-
157152
// maybe the user has disabled the setting in the meantime!
158153
if (getSettingValue("use-system-theme") !== "false") {
159154
const lightTheme = getSettingValue("preferred-light-theme") || "light";
160155
const darkTheme = getSettingValue("preferred-dark-theme") || "dark";
156+
updateLocalStorage("use-system-theme", "true");
161157

162-
if (mql.matches) {
163-
use(darkTheme, true);
164-
} else {
165-
// prefers a light theme, or has no preference
166-
use(lightTheme, true);
167-
}
158+
// use light theme if user prefers it, or has no preference
159+
switchTheme(mql.matches ? darkTheme : lightTheme, true);
168160
// note: we save the theme so that it doesn't suddenly change when
169161
// the user disables "use-system-theme" and reloads the page or
170162
// navigates to another page
171163
} else {
172-
use(getSettingValue("theme"), false);
164+
switchTheme(getSettingValue("theme"), false);
173165
}
174166
}
175167

tests/rustdoc-gui/theme-defaults.goml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Ensure that the theme picker always starts with the actual defaults.
2+
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
3+
click: "#settings-menu"
4+
wait-for: "#theme-system-preference"
5+
assert: "#theme-system-preference:checked"
6+
assert: "#preferred-light-theme-light:checked"
7+
assert: "#preferred-dark-theme-dark:checked"
8+
assert-false: "#preferred-dark-theme-ayu:checked"
9+
10+
// Test legacy migration from old theme setup without system-preference matching.
11+
// See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
12+
local-storage: {
13+
"rustdoc-preferred-light-theme": null,
14+
"rustdoc-preferred-dark-theme": null,
15+
"rustdoc-use-system-theme": null,
16+
"rustdoc-theme": "ayu"
17+
}
18+
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
19+
click: "#settings-menu"
20+
wait-for: "#theme-system-preference"
21+
assert: "#theme-system-preference:checked"
22+
assert: "#preferred-light-theme-light:checked"
23+
assert-false: "#preferred-dark-theme-dark:checked"
24+
assert: "#preferred-dark-theme-ayu:checked"

triagebot.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,8 @@ cc = ["@rust-lang/style"]
470470

471471
[mentions."Cargo.lock"]
472472
message = """
473-
These commits modify the `Cargo.lock` file. Random changes to `Cargo.lock` can be introduced when switching branches and rebasing PRs.
474-
This was probably unintentional and should be reverted before this PR is merged.
473+
These commits modify the `Cargo.lock` file. Random changes to `Cargo.lock` can be introduced when switching branches and rebasing PRs.
474+
This was probably unintentional and should be reverted before this PR is merged.
475475
476476
If this was intentional then you can ignore this comment.
477477
"""
@@ -499,7 +499,6 @@ compiler-team = [
499499
]
500500
compiler-team-contributors = [
501501
"@compiler-errors",
502-
"@eholk",
503502
"@jackh726",
504503
"@TaKO8Ki",
505504
"@WaffleLapkin",

0 commit comments

Comments
 (0)