diff options
| author | bors <bors@rust-lang.org> | 2021-03-23 02:01:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-23 02:01:14 +0000 |
| commit | 2bd94f4aa9683158c7df96b9661be193c39a55ed (patch) | |
| tree | ef88985b7237c4b6f77c27e17e9fbce5577d29f1 /src | |
| parent | 5d04957a4b4714f71d38326fc96a0b0ef6dc5800 (diff) | |
| parent | 263c85875cb3aceced6cc712961234fc61d71cba (diff) | |
| download | rust-2bd94f4aa9683158c7df96b9661be193c39a55ed.tar.gz rust-2bd94f4aa9683158c7df96b9661be193c39a55ed.zip | |
Auto merge of #83398 - JohnTitor:rollup-om80krv, r=JohnTitor
Rollup of 7 pull requests Successful merges: - #80705 (Update Source Code Pro and include italics) - #81917 (Update RELEASES.md for 1.51.0) - #82732 (Remove theme.js file) - #83356 (rustdoc: Replace pair of `Option`s with an enum) - #83384 (rename :pat2018 -> :pat2015) - #83385 (:arrow_up: rust-analyzer) - #83389 (add rust-analyzer rustc_private option in librustdoc Cargo.toml) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
19 files changed, 143 insertions, 114 deletions
diff --git a/src/librustdoc/Cargo.toml b/src/librustdoc/Cargo.toml index 2d0722396fc..eb38adb0b73 100644 --- a/src/librustdoc/Cargo.toml +++ b/src/librustdoc/Cargo.toml @@ -29,3 +29,6 @@ features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] [dev-dependencies] expect-test = "1.0" + +[package.metadata.rust-analyzer] +rustc_private = true diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index a717b304566..68d70f27c8c 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -88,7 +88,6 @@ crate fn render<T: Print, S: Print>( </button>\ <div id=\"theme-choices\" role=\"menu\"></div>\ </div>\ - <script src=\"{static_root_path}theme{suffix}.js\"></script>\ <nav class=\"sub\">\ <form class=\"search-form\">\ <div class=\"search-container\">\ diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 1505fe0369d..b39f9f87892 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -690,25 +690,29 @@ crate fn find_testable_code<T: doctest::Tester>( } crate struct ExtraInfo<'tcx> { - hir_id: Option<HirId>, - item_did: Option<DefId>, + id: ExtraInfoId, sp: Span, tcx: TyCtxt<'tcx>, } +enum ExtraInfoId { + Hir(HirId), + Def(DefId), +} + impl<'tcx> ExtraInfo<'tcx> { crate fn new(tcx: TyCtxt<'tcx>, hir_id: HirId, sp: Span) -> ExtraInfo<'tcx> { - ExtraInfo { hir_id: Some(hir_id), item_did: None, sp, tcx } + ExtraInfo { id: ExtraInfoId::Hir(hir_id), sp, tcx } } crate fn new_did(tcx: TyCtxt<'tcx>, did: DefId, sp: Span) -> ExtraInfo<'tcx> { - ExtraInfo { hir_id: None, item_did: Some(did), sp, tcx } + ExtraInfo { id: ExtraInfoId::Def(did), sp, tcx } } fn error_invalid_codeblock_attr(&self, msg: &str, help: &str) { - let hir_id = match (self.hir_id, self.item_did) { - (Some(h), _) => h, - (None, Some(item_did)) => { + let hir_id = match self.id { + ExtraInfoId::Hir(hir_id) => hir_id, + ExtraInfoId::Def(item_did) => { match item_did.as_local() { Some(item_did) => self.tcx.hir().local_def_id_to_hir_id(item_did), None => { @@ -717,7 +721,6 @@ impl<'tcx> ExtraInfo<'tcx> { } } } - (None, None) => return, }; self.tcx.struct_span_lint_hir( crate::lint::INVALID_CODEBLOCK_ATTRIBUTES, diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 02ad01aa29a..501d8e8e02e 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -30,8 +30,9 @@ crate static FILES_UNVERSIONED: Lazy<FxHashMap<&str, &[u8]>> = Lazy::new(|| { "SourceSerifPro-Bold.ttf.woff" => static_files::source_serif_pro::BOLD, "SourceSerifPro-It.ttf.woff" => static_files::source_serif_pro::ITALIC, "SourceSerifPro-LICENSE.md" => static_files::source_serif_pro::LICENSE, - "SourceCodePro-Regular.woff" => static_files::source_code_pro::REGULAR, - "SourceCodePro-Semibold.woff" => static_files::source_code_pro::SEMIBOLD, + "SourceCodePro-Regular.ttf.woff" => static_files::source_code_pro::REGULAR, + "SourceCodePro-Semibold.ttf.woff" => static_files::source_code_pro::SEMIBOLD, + "SourceCodePro-It.ttf.woff" => static_files::source_code_pro::ITALIC, "SourceCodePro-LICENSE.txt" => static_files::source_code_pro::LICENSE, "LICENSE-MIT.txt" => static_files::LICENSE_MIT, "LICENSE-APACHE.txt" => static_files::LICENSE_APACHE, @@ -129,65 +130,14 @@ pub(super) fn write_shared( let mut themes: Vec<&String> = themes.iter().collect(); themes.sort(); - // To avoid theme switch latencies as much as possible, we put everything theme related - // at the beginning of the html files into another js file. - let theme_js = format!( - r#"var themes = document.getElementById("theme-choices"); -var themePicker = document.getElementById("theme-picker"); - -function showThemeButtonState() {{ - themes.style.display = "block"; - themePicker.style.borderBottomRightRadius = "0"; - themePicker.style.borderBottomLeftRadius = "0"; -}} - -function hideThemeButtonState() {{ - themes.style.display = "none"; - themePicker.style.borderBottomRightRadius = "3px"; - themePicker.style.borderBottomLeftRadius = "3px"; -}} - -function switchThemeButtonState() {{ - if (themes.style.display === "block") {{ - hideThemeButtonState(); - }} else {{ - showThemeButtonState(); - }} -}}; - -function handleThemeButtonsBlur(e) {{ - var active = document.activeElement; - var related = e.relatedTarget; - - if (active.id !== "theme-picker" && - (!active.parentNode || active.parentNode.id !== "theme-choices") && - (!related || - (related.id !== "theme-picker" && - (!related.parentNode || related.parentNode.id !== "theme-choices")))) {{ - hideThemeButtonState(); - }} -}} - -themePicker.onclick = switchThemeButtonState; -themePicker.onblur = handleThemeButtonsBlur; -{}.forEach(function(item) {{ - var but = document.createElement("button"); - but.textContent = item; - but.onclick = function(el) {{ - switchTheme(currentTheme, mainTheme, item, true); - useSystemTheme(false); - }}; - but.onblur = handleThemeButtonsBlur; - themes.appendChild(but); -}});"#, - serde_json::to_string(&themes).unwrap() - ); - - write_minify(&cx.shared.fs, cx.path("theme.js"), &theme_js, options.enable_minification)?; + write_minify( &cx.shared.fs, cx.path("main.js"), - static_files::MAIN_JS, + &static_files::MAIN_JS.replace( + "/* INSERT THEMES HERE */", + &format!(" = {}", serde_json::to_string(&themes).unwrap()), + ), options.enable_minification, )?; write_minify( diff --git a/src/librustdoc/html/static/COPYRIGHT.txt b/src/librustdoc/html/static/COPYRIGHT.txt index af77776cca4..24bdca6544d 100644 --- a/src/librustdoc/html/static/COPYRIGHT.txt +++ b/src/librustdoc/html/static/COPYRIGHT.txt @@ -23,7 +23,8 @@ included, and carry their own copyright notices and license terms: Copyright (c) Nicolas Gallagher and Jonathan Neal. Licensed under the MIT license (see LICENSE-MIT.txt). -* Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff): +* Source Code Pro (SourceCodePro-Regular.ttf.woff, + SourceCodePro-Semibold.ttf.woff, SourceCodePro-It.ttf.woff): Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark diff --git a/src/librustdoc/html/static/SourceCodePro-It.ttf.woff b/src/librustdoc/html/static/SourceCodePro-It.ttf.woff new file mode 100644 index 00000000000..8d68f2febdd --- /dev/null +++ b/src/librustdoc/html/static/SourceCodePro-It.ttf.woff Binary files differdiff --git a/src/librustdoc/html/static/SourceCodePro-Regular.ttf.woff b/src/librustdoc/html/static/SourceCodePro-Regular.ttf.woff new file mode 100644 index 00000000000..7be076e1fca --- /dev/null +++ b/src/librustdoc/html/static/SourceCodePro-Regular.ttf.woff Binary files differdiff --git a/src/librustdoc/html/static/SourceCodePro-Regular.woff b/src/librustdoc/html/static/SourceCodePro-Regular.woff deleted file mode 100644 index 5576670903a..00000000000 --- a/src/librustdoc/html/static/SourceCodePro-Regular.woff +++ /dev/null Binary files differdiff --git a/src/librustdoc/html/static/SourceCodePro-Semibold.ttf.woff b/src/librustdoc/html/static/SourceCodePro-Semibold.ttf.woff new file mode 100644 index 00000000000..61bc67b8025 --- /dev/null +++ b/src/librustdoc/html/static/SourceCodePro-Semibold.ttf.woff Binary files differdiff --git a/src/librustdoc/html/static/SourceCodePro-Semibold.woff b/src/librustdoc/html/static/SourceCodePro-Semibold.woff deleted file mode 100644 index ca972a11dc4..00000000000 --- a/src/librustdoc/html/static/SourceCodePro-Semibold.woff +++ /dev/null Binary files differdiff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index f1ecaaa619c..da2952bbebd 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2,7 +2,7 @@ // Local js definitions: /* global addClass, getSettingValue, hasClass */ /* global onEach, onEachLazy, hasOwnProperty, removeClass, updateLocalStorage */ -/* global hideThemeButtonState, showThemeButtonState */ +/* global switchTheme, useSystemTheme */ if (!String.prototype.startsWith) { String.prototype.startsWith = function(searchString, position) { @@ -85,12 +85,15 @@ function getSearchElement() { return document.getElementById("search"); } +var THEME_PICKER_ELEMENT_ID = "theme-picker"; +var THEMES_ELEMENT_ID = "theme-choices"; + function getThemesElement() { - return document.getElementById("theme-choices"); + return document.getElementById(THEMES_ELEMENT_ID); } function getThemePickerElement() { - return document.getElementById("theme-picker"); + return document.getElementById(THEME_PICKER_ELEMENT_ID); } // Returns the current URL without any query parameter or hash. @@ -108,6 +111,65 @@ function defocusSearchBar() { getSearchInput().blur(); } +function showThemeButtonState() { + var themePicker = getThemePickerElement(); + var themeChoices = getThemesElement(); + + themeChoices.style.display = "block"; + themePicker.style.borderBottomRightRadius = "0"; + themePicker.style.borderBottomLeftRadius = "0"; +} + +function hideThemeButtonState() { + var themePicker = getThemePickerElement(); + var themeChoices = getThemesElement(); + + themeChoices.style.display = "none"; + themePicker.style.borderBottomRightRadius = "3px"; + themePicker.style.borderBottomLeftRadius = "3px"; +} + +// Set up the theme picker list. +(function () { + var themeChoices = getThemesElement(); + var themePicker = getThemePickerElement(); + var availableThemes/* INSERT THEMES HERE */; + + function switchThemeButtonState() { + if (themeChoices.style.display === "block") { + hideThemeButtonState(); + } else { + showThemeButtonState(); + } + } + + function handleThemeButtonsBlur(e) { + var active = document.activeElement; + var related = e.relatedTarget; + + if (active.id !== THEME_PICKER_ELEMENT_ID && + (!active.parentNode || active.parentNode.id !== THEMES_ELEMENT_ID) && + (!related || + (related.id !== THEME_PICKER_ELEMENT_ID && + (!related.parentNode || related.parentNode.id !== THEMES_ELEMENT_ID)))) { + hideThemeButtonState(); + } + } + + themePicker.onclick = switchThemeButtonState; + themePicker.onblur = handleThemeButtonsBlur; + availableThemes.forEach(function(item) { + var but = document.createElement("button"); + but.textContent = item; + but.onclick = function() { + switchTheme(window.currentTheme, window.mainTheme, item, true); + useSystemTheme(false); + }; + but.onblur = handleThemeButtonsBlur; + themeChoices.appendChild(but); + }); +}()); + (function() { "use strict"; @@ -461,8 +523,7 @@ function defocusSearchBar() { break; default: - var themePicker = getThemePickerElement(); - if (themePicker.parentNode.contains(ev.target)) { + if (getThemePickerElement().parentNode.contains(ev.target)) { handleThemeKeyDown(ev); } } @@ -475,7 +536,7 @@ function defocusSearchBar() { switch (getVirtualKey(ev)) { case "ArrowUp": ev.preventDefault(); - if (active.previousElementSibling && ev.target.id !== "theme-picker") { + if (active.previousElementSibling && ev.target.id !== THEME_PICKER_ELEMENT_ID) { active.previousElementSibling.focus(); } else { showThemeButtonState(); @@ -484,7 +545,7 @@ function defocusSearchBar() { break; case "ArrowDown": ev.preventDefault(); - if (active.nextElementSibling && ev.target.id !== "theme-picker") { + if (active.nextElementSibling && ev.target.id !== THEME_PICKER_ELEMENT_ID) { active.nextElementSibling.focus(); } else { showThemeButtonState(); @@ -494,7 +555,7 @@ function defocusSearchBar() { case "Enter": case "Return": case "Space": - if (ev.target.id === "theme-picker" && themes.style.display === "none") { + if (ev.target.id === THEME_PICKER_ELEMENT_ID && themes.style.display === "none") { ev.preventDefault(); showThemeButtonState(); themes.firstElementChild.focus(); diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 4f287cde73b..a65b4ce3a03 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -48,14 +48,21 @@ font-weight: 400; /* Avoid using locally installed font because bad versions are in circulation: * see https://github.com/rust-lang/rust/issues/24355 */ - src: url("SourceCodePro-Regular.woff") format('woff'); + src: url("SourceCodePro-Regular.ttf.woff") format('woff'); + font-display: swap; +} +@font-face { + font-family: 'Source Code Pro'; + font-style: italic; + font-weight: 400; + src: url("SourceCodePro-It.ttf.woff") format('woff'); font-display: swap; } @font-face { font-family: 'Source Code Pro'; font-style: normal; font-weight: 600; - src: url("SourceCodePro-Semibold.woff") format('woff'); + src: url("SourceCodePro-Semibold.ttf.woff") format('woff'); font-display: swap; } diff --git a/src/librustdoc/html/static/storage.js b/src/librustdoc/html/static/storage.js index b8b6fcbaf3a..c68128516d2 100644 --- a/src/librustdoc/html/static/storage.js +++ b/src/librustdoc/html/static/storage.js @@ -2,8 +2,8 @@ /* global resourcesSuffix */ var darkThemes = ["dark", "ayu"]; -var currentTheme = document.getElementById("themeStyle"); -var mainTheme = document.getElementById("mainThemeStyle"); +window.currentTheme = document.getElementById("themeStyle"); +window.mainTheme = document.getElementById("mainThemeStyle"); var settingsDataset = (function () { var settingsElement = document.getElementById("default-settings"); @@ -137,7 +137,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) { } } -// This function is called from "theme.js", generated in `html/render/mod.rs`. +// This function is called from "main.js". // eslint-disable-next-line no-unused-vars function useSystemTheme(value) { if (value === undefined) { @@ -161,8 +161,8 @@ var updateSystemTheme = (function() { .getPropertyValue('content'); switchTheme( - currentTheme, - mainTheme, + window.currentTheme, + window.mainTheme, JSON.parse(cssTheme) || "light", true ); @@ -180,10 +180,10 @@ var updateSystemTheme = (function() { if (mql.matches) { // prefers a dark theme - switchTheme(currentTheme, mainTheme, darkTheme, true); + switchTheme(window.currentTheme, window.mainTheme, darkTheme, true); } else { // prefers a light theme, or has no preference - switchTheme(currentTheme, mainTheme, lightTheme, true); + switchTheme(window.currentTheme, window.mainTheme, lightTheme, true); } // note: we save the theme so that it doesn't suddenly change when @@ -212,8 +212,8 @@ if (getSettingValue("use-system-theme") !== "false" && window.matchMedia) { updateSystemTheme(); } else { switchTheme( - currentTheme, - mainTheme, + window.currentTheme, + window.mainTheme, getSettingValue("theme") || "light", false ); diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index 701e106df67..83d4a11e620 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -107,11 +107,15 @@ crate mod source_serif_pro { /// Files related to the Source Code Pro font. crate mod source_code_pro { - /// The file `SourceCodePro-Regular.woff`, the Regular variant of the Source Code Pro font. - crate static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.woff"); + /// The file `SourceCodePro-Regular.ttf.woff`, the Regular variant of the Source Code Pro font. + crate static REGULAR: &[u8] = include_bytes!("static/SourceCodePro-Regular.ttf.woff"); - /// The file `SourceCodePro-Semibold.woff`, the Semibold variant of the Source Code Pro font. - crate static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.woff"); + /// The file `SourceCodePro-Semibold.ttf.woff`, the Semibold variant of the Source Code Pro + /// font. + crate static SEMIBOLD: &[u8] = include_bytes!("static/SourceCodePro-Semibold.ttf.woff"); + + /// The file `SourceCodePro-It.ttf.woff`, the Italic variant of the Source Code Pro font. + crate static ITALIC: &[u8] = include_bytes!("static/SourceCodePro-It.ttf.woff"); /// The file `SourceCodePro-LICENSE.txt`, the license text of the Source Code Pro font. crate static LICENSE: &[u8] = include_bytes!("static/SourceCodePro-LICENSE.txt"); diff --git a/src/test/run-make-fulldeps/print-unversioned-files/unversioned-files.txt b/src/test/run-make-fulldeps/print-unversioned-files/unversioned-files.txt index c5a9bf24381..befbdab0ad9 100644 --- a/src/test/run-make-fulldeps/print-unversioned-files/unversioned-files.txt +++ b/src/test/run-make-fulldeps/print-unversioned-files/unversioned-files.txt @@ -6,9 +6,10 @@ FiraSans-Regular.woff FiraSans-Regular.woff2 LICENSE-APACHE.txt LICENSE-MIT.txt +SourceCodePro-It.ttf.woff SourceCodePro-LICENSE.txt -SourceCodePro-Regular.woff -SourceCodePro-Semibold.woff +SourceCodePro-Regular.ttf.woff +SourceCodePro-Semibold.ttf.woff SourceSerifPro-Bold.ttf.woff SourceSerifPro-It.ttf.woff SourceSerifPro-LICENSE.md diff --git a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs index bd8a21ea36a..430a9437cee 100644 --- a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs +++ b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.rs @@ -1,8 +1,8 @@ // Feature gate test for `edition_macro_pats` feature. macro_rules! foo { - ($x:pat2018) => {}; //~ERROR `pat2018` and `pat2021` are unstable - ($x:pat2021) => {}; //~ERROR `pat2018` and `pat2021` are unstable + ($x:pat2015) => {}; //~ERROR `pat2015` and `pat2021` are unstable + ($x:pat2021) => {}; //~ERROR `pat2015` and `pat2021` are unstable } fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr index 89bfb239d9e..d25bcaf929b 100644 --- a/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr +++ b/src/test/ui/feature-gates/feature-gate-edition_macro_pats.stderr @@ -1,13 +1,13 @@ -error[E0658]: `pat2018` and `pat2021` are unstable. +error[E0658]: `pat2015` and `pat2021` are unstable. --> $DIR/feature-gate-edition_macro_pats.rs:4:9 | -LL | ($x:pat2018) => {}; +LL | ($x:pat2015) => {}; | ^^^^^^^ | = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information = help: add `#![feature(edition_macro_pats)]` to the crate attributes to enable -error[E0658]: `pat2018` and `pat2021` are unstable. +error[E0658]: `pat2015` and `pat2021` are unstable. --> $DIR/feature-gate-edition_macro_pats.rs:5:9 | LL | ($x:pat2021) => {}; diff --git a/src/test/ui/macros/edition-macro-pats.rs b/src/test/ui/macros/edition-macro-pats.rs index b8f9f12f413..58f92710305 100644 --- a/src/test/ui/macros/edition-macro-pats.rs +++ b/src/test/ui/macros/edition-macro-pats.rs @@ -3,7 +3,7 @@ #![feature(edition_macro_pats)] macro_rules! foo { - (a $x:pat2018) => {}; + (a $x:pat2015) => {}; (b $x:pat2021) => {}; } diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer -Subproject 5ba7852cf153688d5b5035a9a2a2145aa7334d7 +Subproject 858ad554374a8b1ad67692558a0878391abfdd8 |
