diff --git a/compiler/rustc_codegen_ssa/src/back/command.rs b/compiler/rustc_codegen_ssa/src/back/command.rs index 17071ba1b5bf3..6c29692bd3bfe 100644 --- a/compiler/rustc_codegen_ssa/src/back/command.rs +++ b/compiler/rustc_codegen_ssa/src/back/command.rs @@ -105,12 +105,7 @@ impl Command { } Program::Lld(ref p, flavor) => { let mut c = process::Command::new(p); - c.arg("-flavor").arg(match flavor { - LldFlavor::Wasm => "wasm", - LldFlavor::Ld => "gnu", - LldFlavor::Link => "link", - LldFlavor::Ld64 => "darwin", - }); + c.arg("-flavor").arg(flavor.as_str()); if let LldFlavor::Wasm = flavor { // LLVM expects host-specific formatting for @file // arguments, but we always generate posix formatted files diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 04ec1e7f3c1af..00f85852493b2 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2698,37 +2698,20 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) { if let LinkerFlavor::Gcc = flavor { match ld_impl { LdImpl::Lld => { - if sess.target.lld_flavor == LldFlavor::Ld64 { - let tools_path = sess.get_tools_search_paths(false); - let ld64_exe = tools_path - .into_iter() - .map(|p| p.join("gcc-ld")) - .map(|p| { - p.join(if sess.host.is_like_windows { "ld64.exe" } else { "ld64" }) - }) - .find(|p| p.exists()) - .unwrap_or_else(|| sess.fatal("rust-lld (as ld64) not found")); - cmd.cmd().arg({ - let mut arg = OsString::from("-fuse-ld="); - arg.push(ld64_exe); - arg - }); - } else { - let tools_path = sess.get_tools_search_paths(false); - let lld_path = tools_path - .into_iter() - .map(|p| p.join("gcc-ld")) - .find(|p| { - p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }) - .exists() - }) - .unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found")); - cmd.cmd().arg({ - let mut arg = OsString::from("-B"); - arg.push(lld_path); - arg - }); - } + let tools_path = sess.get_tools_search_paths(false); + let gcc_ld_dir = tools_path + .into_iter() + .map(|p| p.join("gcc-ld")) + .find(|p| { + p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists() + }) + .unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found")); + cmd.arg({ + let mut arg = OsString::from("-B"); + arg.push(gcc_ld_dir); + arg + }); + cmd.arg(format!("-Wl,-rustc-lld-flavor={}", sess.target.lld_flavor.as_str())); } } } else { diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 832eeec3e8b27..6dd245b047cbe 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -108,6 +108,15 @@ pub enum LldFlavor { } impl LldFlavor { + pub fn as_str(&self) -> &'static str { + match self { + LldFlavor::Wasm => "wasm", + LldFlavor::Ld64 => "darwin", + LldFlavor::Ld => "gnu", + LldFlavor::Link => "link", + } + } + fn from_str(s: &str) -> Option { Some(match s { "darwin" => LldFlavor::Ld64, @@ -121,13 +130,7 @@ impl LldFlavor { impl ToJson for LldFlavor { fn to_json(&self) -> Json { - match *self { - LldFlavor::Ld64 => "darwin", - LldFlavor::Ld => "gnu", - LldFlavor::Link => "link", - LldFlavor::Wasm => "wasm", - } - .to_json() + self.as_str().to_json() } } diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 0b430f64e1edc..b35eba21e6bd6 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -1164,14 +1164,11 @@ impl Step for Assemble { // for `-Z gcc-ld=lld` let gcc_ld_dir = libdir_bin.join("gcc-ld"); t!(fs::create_dir(&gcc_ld_dir)); - for flavor in ["ld", "ld64"] { - let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper { - compiler: build_compiler, - target: target_compiler.host, - flavor_feature: flavor, - }); - builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe(flavor, target_compiler.host))); - } + let lld_wrapper_exe = builder.ensure(crate::tool::LldWrapper { + compiler: build_compiler, + target: target_compiler.host, + }); + builder.copy(&lld_wrapper_exe, &gcc_ld_dir.join(exe("ld", target_compiler.host))); } if builder.config.rust_codegen_backends.contains(&INTERNER.intern_str("llvm")) { diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 0be11e3fb467e..cc10d67c551db 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -407,11 +407,8 @@ impl Step for Rustc { let gcc_lld_src_dir = src_dir.join("gcc-ld"); let gcc_lld_dst_dir = dst_dir.join("gcc-ld"); t!(fs::create_dir(&gcc_lld_dst_dir)); - for flavor in ["ld", "ld64"] { - let exe_name = exe(flavor, compiler.host); - builder - .copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name)); - } + let exe_name = exe("ld", compiler.host); + builder.copy(&gcc_lld_src_dir.join(&exe_name), &gcc_lld_dst_dir.join(&exe_name)); } // Man pages diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 3b30e6de12a63..2f4d07d77a51f 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -656,7 +656,6 @@ impl Step for Cargo { pub struct LldWrapper { pub compiler: Compiler, pub target: TargetSelection, - pub flavor_feature: &'static str, } impl Step for LldWrapper { @@ -676,7 +675,7 @@ impl Step for LldWrapper { path: "src/tools/lld-wrapper", is_optional_tool: false, source_type: SourceType::InTree, - extra_features: vec![self.flavor_feature.to_owned()], + extra_features: Vec::new(), }) .expect("expected to build -- essential tool"); diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index b3ec1638fda74..03834411d1529 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.9.3 \ No newline at end of file +0.9.5 \ No newline at end of file diff --git a/src/doc/book b/src/doc/book index d9415b7cbfcb4..b4dd5f00b8719 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit d9415b7cbfcb4b24062683f429bd0ff535396362 +Subproject commit b4dd5f00b87190ad5ef42cbc2a88a783c6ae57ef diff --git a/src/doc/reference b/src/doc/reference index 8e36971959ff2..b74825d8f88b6 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 8e36971959ff238b5aa2575fbc7a2e09e1313e82 +Subproject commit b74825d8f88b685e239ade00f00de68ba4cd63d4 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index e9f93cfcf410b..2ed26865e8c29 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit e9f93cfcf410bc092c9107b8a41a82f144c761f2 +Subproject commit 2ed26865e8c29ef939dc913a97bd321cadd72a9a diff --git a/src/doc/rustc-dev-guide b/src/doc/rustc-dev-guide index 0c02acdb6f48f..554c00e4805df 160000 --- a/src/doc/rustc-dev-guide +++ b/src/doc/rustc-dev-guide @@ -1 +1 @@ -Subproject commit 0c02acdb6f48f03907a02ea8e537c3272b4fde9f +Subproject commit 554c00e4805df7f7bffac7db408437d62d6dfb9a diff --git a/src/librustdoc/html/static/.eslintrc.js b/src/librustdoc/html/static/.eslintrc.js index bf962303b3a3e..7afd09b34d30d 100644 --- a/src/librustdoc/html/static/.eslintrc.js +++ b/src/librustdoc/html/static/.eslintrc.js @@ -47,5 +47,12 @@ module.exports = { { "beforeColon": false, "afterColon": true, "mode": "strict" } ], "func-call-spacing": ["error", "never"], + "space-infix-ops": "error", + "space-before-function-paren": ["error", "never"], + "space-before-blocks": "error", + "comma-dangle": ["error", "always-multiline"], + "comma-style": ["error", "last"], + "max-len": ["error", { "code": 100, "tabWidth": 4 }], + "eol-last": ["error", "always"], } }; diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 4eb8029ee2db6..d0229bdb5f23c 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1415,30 +1415,6 @@ pre.rust { #settings-menu.rotate > a img { animation: rotating 2s linear infinite; } -#settings-menu #settings { - position: absolute; - right: 0; - z-index: 1; - display: block; - margin-top: 7px; - border-radius: 3px; - border: 1px solid; -} -#settings-menu #settings .setting-line { - margin: 0.6em; -} -/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */ -#settings-menu #settings::before { - content: ''; - position: absolute; - right: 11px; - border: solid; - border-width: 1px 1px 0 0; - display: inline-block; - padding: 4px; - transform: rotate(-45deg); - top: -5px; -} #help-button { font-family: "Fira Sans", Arial, sans-serif; diff --git a/src/librustdoc/html/static/css/settings.css b/src/librustdoc/html/static/css/settings.css index 07588748ad68e..c69ff04236dcb 100644 --- a/src/librustdoc/html/static/css/settings.css +++ b/src/librustdoc/html/static/css/settings.css @@ -46,9 +46,12 @@ .toggle { position: relative; display: inline-block; - width: 45px; + width: 100%; height: 27px; margin-right: 20px; + display: flex; + align-items: center; + cursor: pointer; } .toggle input { @@ -57,12 +60,12 @@ } .slider { - position: absolute; + position: relative; + width: 45px; + display: block; + height: 28px; + margin-right: 20px; cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; background-color: #ccc; transition: .3s; } @@ -95,3 +98,28 @@ input:checked + .slider:before { width: 100%; display: block; } + +div#settings { + position: absolute; + right: 0; + z-index: 1; + display: block; + margin-top: 7px; + border-radius: 3px; + border: 1px solid; +} +#settings .setting-line { + margin: 1.2em 0.6em; +} +/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */ +div#settings::before { + content: ''; + position: absolute; + right: 11px; + border: solid; + border-width: 1px 1px 0 0; + display: inline-block; + padding: 4px; + transform: rotate(-45deg); + top: -5px; +} diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 454c7f557b9bc..0fbc2d0e33c90 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -63,7 +63,7 @@ function showMain() { removeClass(document.getElementById(MAIN_ID), "hidden"); } -(function () { +(function() { window.rootPath = getVar("root-path"); window.currentCrate = getVar("current-crate"); window.searchJS = resourcePath("search", ".js"); @@ -929,7 +929,7 @@ function loadCss(cssFileName) { searchState.setup(); }()); -(function () { +(function() { let reset_button_timeout = null; window.copy_path = but => { diff --git a/src/librustdoc/html/static/js/scrape-examples.js b/src/librustdoc/html/static/js/scrape-examples.js index 7b9d86a851b19..fd7a1449763eb 100644 --- a/src/librustdoc/html/static/js/scrape-examples.js +++ b/src/librustdoc/html/static/js/scrape-examples.js @@ -2,7 +2,7 @@ "use strict"; -(function () { +(function() { // Number of lines shown when code viewer is not expanded const MAX_LINES = 10; diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js index 8770cc3f3b149..3d1d942eaa9ee 100644 --- a/src/librustdoc/html/static/js/settings.js +++ b/src/librustdoc/html/static/js/settings.js @@ -5,7 +5,7 @@ "use strict"; -(function () { +(function() { const isSettingsPage = window.location.pathname.endsWith("/settings.html"); function changeSetting(settingName, value) { @@ -130,12 +130,11 @@ } else { // This is a toggle. const checked = setting["default"] === true ? " checked" : ""; - output += ` - -
${setting_name}
`; + output += ``; } output += ""; } diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/source-script.js index 15e3bdf47b2b1..aaac878d3a37b 100644 --- a/src/librustdoc/html/static/js/source-script.js +++ b/src/librustdoc/html/static/js/source-script.js @@ -187,7 +187,7 @@ function highlightSourceLines(match) { } } -const handleSourceHighlight = (function () { +const handleSourceHighlight = (function() { let prev_line_id = 0; const set_fragment = name => { diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 3fcf66a817ee1..4fcf049923491 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -4,7 +4,7 @@ const darkThemes = ["dark", "ayu"]; window.currentTheme = document.getElementById("themeStyle"); window.mainTheme = document.getElementById("mainThemeStyle"); -const settingsDataset = (function () { +const settingsDataset = (function() { const settingsElement = document.getElementById("default-settings"); if (settingsElement === null) { return null; @@ -163,7 +163,7 @@ function useSystemTheme(value) { } } -const updateSystemTheme = (function () { +const updateSystemTheme = (function() { if (!window.matchMedia) { // fallback to the CSS computed value return () => { diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml index 9a9c45a9b7fe5..1b2d1e31f520c 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/src/test/rustdoc-gui/settings.goml @@ -34,7 +34,7 @@ wait-for: "#settings" // We check that the "Use system theme" is disabled. assert-property: ("#use-system-theme", {"checked": "false"}) -assert: "//*[@class='setting-line']/*[text()='Use system theme']" +assert: "//*[@class='setting-line']//span[text()='Use system theme']" // Meaning that only the "theme" menu is showing up. assert: ".setting-line:not(.hidden) #theme" assert: ".setting-line.hidden #preferred-dark-theme" @@ -55,7 +55,13 @@ assert: ".setting-line.hidden #theme" assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme") assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme") +// We now check that clicking on the "sliders"' text is like clicking on the slider. +// To test it, we use the "Disable keyboard shortcuts". +local-storage: {"rustdoc-disable-shortcuts": "false"} +click: ".setting-line:last-child .toggle .label" +assert-local-storage: {"rustdoc-disable-shortcuts": "true"} + // Now we go to the settings page to check that the CSS is loaded as expected. goto: file://|DOC_PATH|/settings.html wait-for: "#settings" -assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"}) +assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"}) diff --git a/src/tools/lld-wrapper/Cargo.toml b/src/tools/lld-wrapper/Cargo.toml index 66a586fd6c35e..bf5138b16d5bd 100644 --- a/src/tools/lld-wrapper/Cargo.toml +++ b/src/tools/lld-wrapper/Cargo.toml @@ -3,9 +3,3 @@ name = "lld-wrapper" version = "0.1.0" edition = "2021" license = "MIT OR Apache-2.0" - -[dependencies] - -[features] -ld = [] -ld64 = [] \ No newline at end of file diff --git a/src/tools/lld-wrapper/src/main.rs b/src/tools/lld-wrapper/src/main.rs index 8d19a054a1d25..90bd24a75e064 100644 --- a/src/tools/lld-wrapper/src/main.rs +++ b/src/tools/lld-wrapper/src/main.rs @@ -1,5 +1,4 @@ -//! Script to invoke the bundled rust-lld with the correct flavor. The flavor is selected by -//! feature. +//! Script to invoke the bundled rust-lld with the correct flavor. //! //! lld supports multiple command line interfaces. If `-flavor ` are passed as the first //! two arguments the `` command line interface is used to process the remaining arguments. @@ -8,59 +7,33 @@ //! In Rust with `-Z gcc-ld=lld` we have gcc or clang invoke rust-lld. Since there is no way to //! make gcc/clang pass `-flavor ` as the first two arguments in the linker invocation //! and since Windows does not support symbolic links for files this wrapper is used in place of a -//! symbolic link. It execs `../rust-lld -flavor ld` if the feature `ld` is enabled and -//! `../rust-lld -flavor ld64` if `ld64` is enabled. On Windows it spawns a `..\rust-lld.exe` +//! symbolic link. It execs `../rust-lld -flavor ` by propagating the flavor argument +//! passed to the wrapper as the first two arguments. On Windows it spawns a `..\rust-lld.exe` //! child process. -#[cfg(not(any(feature = "ld", feature = "ld64")))] -compile_error!("One of the features ld and ld64 must be enabled."); - -#[cfg(all(feature = "ld", feature = "ld64"))] -compile_error!("Only one of the feature ld or ld64 can be enabled."); - -#[cfg(feature = "ld")] -const FLAVOR: &str = "ld"; - -#[cfg(feature = "ld64")] -const FLAVOR: &str = "ld64"; - -use std::env; use std::fmt::Display; use std::path::{Path, PathBuf}; -use std::process; +use std::{env, process}; -trait ResultExt { +trait UnwrapOrExitWith { fn unwrap_or_exit_with(self, context: &str) -> T; } -impl ResultExt for Result -where - E: Display, -{ +impl UnwrapOrExitWith for Option { fn unwrap_or_exit_with(self, context: &str) -> T { - match self { - Ok(t) => t, - Err(e) => { - eprintln!("lld-wrapper: {}: {}", context, e); - process::exit(1); - } - } + self.unwrap_or_else(|| { + eprintln!("lld-wrapper: {}", context); + process::exit(1); + }) } } -trait OptionExt { - fn unwrap_or_exit_with(self, context: &str) -> T; -} - -impl OptionExt for Option { +impl UnwrapOrExitWith for Result { fn unwrap_or_exit_with(self, context: &str) -> T { - match self { - Some(t) => t, - None => { - eprintln!("lld-wrapper: {}", context); - process::exit(1); - } - } + self.unwrap_or_else(|err| { + eprintln!("lld-wrapper: {}: {}", context, err); + process::exit(1); + }) } } @@ -81,14 +54,28 @@ fn get_rust_lld_path(current_exe_path: &Path) -> PathBuf { } /// Returns the command for invoking rust-lld with the correct flavor. +/// LLD only accepts the flavor argument at the first two arguments, so move it there. /// /// Exits on error. fn get_rust_lld_command(current_exe_path: &Path) -> process::Command { let rust_lld_path = get_rust_lld_path(current_exe_path); let mut command = process::Command::new(rust_lld_path); + + let mut flavor = None; + let args = env::args_os() + .skip(1) + .filter(|arg| match arg.to_str().and_then(|s| s.strip_prefix("-rustc-lld-flavor=")) { + Some(suffix) => { + flavor = Some(suffix.to_string()); + false + } + None => true, + }) + .collect::>(); + command.arg("-flavor"); - command.arg(FLAVOR); - command.args(env::args_os().skip(1)); + command.arg(flavor.unwrap_or_exit_with("-rustc-lld-flavor= is not passed")); + command.args(args); command } @@ -101,20 +88,14 @@ fn exec_lld(mut command: process::Command) { #[cfg(not(unix))] fn exec_lld(mut command: process::Command) { - // Windows has no exec(), spawn a child process and wait for it + // Windows has no exec(), spawn a child process and wait for it. let exit_status = command.status().unwrap_or_exit_with("error running rust-lld child process"); - if !exit_status.success() { - match exit_status.code() { - Some(code) => { - // return the original lld exit code - process::exit(code) - } - None => { - eprintln!("lld-wrapper: rust-lld child process exited with error: {}", exit_status,); - process::exit(1); - } - } - } + let code = exit_status + .code() + .ok_or(exit_status) + .unwrap_or_exit_with("rust-lld child process exited with error"); + // Return the original lld exit code. + process::exit(code); } fn main() { diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js index 8532410a1bf3a..4599e12de5f33 100644 --- a/src/tools/rustdoc-gui/tester.js +++ b/src/tools/rustdoc-gui/tester.js @@ -19,6 +19,7 @@ function showHelp() { console.log(" --help : show this message then quit"); console.log(" --tests-folder [PATH] : location of the .GOML tests folder"); console.log(" --jobs [NUMBER] : number of threads to run tests on"); + console.log(" --executable-path [PATH] : path of the browser's executable to be used"); } function isNumeric(s) { @@ -34,6 +35,8 @@ function parseOptions(args) { "show_text": false, "no_headless": false, "jobs": -1, + "executable_path": null, + "no_sandbox": false, }; var correspondances = { "--doc-folder": "doc_folder", @@ -41,13 +44,16 @@ function parseOptions(args) { "--debug": "debug", "--show-text": "show_text", "--no-headless": "no_headless", + "--executable-path": "executable_path", + "--no-sandbox": "no_sandbox", }; for (var i = 0; i < args.length; ++i) { if (args[i] === "--doc-folder" || args[i] === "--tests-folder" || args[i] === "--file" - || args[i] === "--jobs") { + || args[i] === "--jobs" + || args[i] === "--executable-path") { i += 1; if (i >= args.length) { console.log("Missing argument after `" + args[i - 1] + "` option."); @@ -68,6 +74,9 @@ function parseOptions(args) { } else if (args[i] === "--help") { showHelp(); process.exit(0); + } else if (args[i] === "--no-sandbox") { + console.log("`--no-sandbox` is being used. Be very careful!"); + opts[correspondances[args[i]]] = true; } else if (correspondances[args[i]]) { opts[correspondances[args[i]]] = true; } else { @@ -147,10 +156,17 @@ async function main(argv) { if (opts["show_text"]) { args.push("--show-text"); } + if (opts["no_sandbox"]) { + args.push("--no-sandbox"); + } if (opts["no_headless"]) { args.push("--no-headless"); headless = false; } + if (opts["executable_path"] !== null) { + args.push("--executable-path"); + args.push(opts["executable_path"]); + } options.parseArguments(args); } catch (error) { console.error(`invalid argument: ${error}`);