From a8fa961696fcbdef7a74fdd80033c464c156f453 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Thu, 22 Jun 2023 12:16:48 -0700 Subject: [PATCH 01/12] Align search results horizontally for easy scanning The recent PR #110688 added info about an item's kind before its name in search results. However, because the kind and name are inline with no alignment, it's now hard to visually scan downward through the search results, looking at item names. This PR fixes that by horizontally aligning search results such that there are now two columns of information. --- src/librustdoc/html/static/css/rustdoc.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 21c1eb631e0..83b989fc080 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -891,8 +891,10 @@ so that we can apply CSS-filters to change the arrow color in themes */ color: var(--search-results-grey-color); } .search-results .result-name .typename { + display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; + width: 6rem; } .popover { From 6f61f6ba11a1917f3bf7b1bd8054c12bd4e7b6ec Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Fri, 23 Jun 2023 04:47:30 +0200 Subject: [PATCH 02/12] DirEntry::file_name: improve explanation --- library/std/src/fs.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 89dfdfafdb1..c2d82169dc3 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1755,8 +1755,14 @@ impl DirEntry { self.0.file_type().map(FileType) } - /// Returns the bare file name of this directory entry without any other - /// leading path component. + /// Returns the file name of this directory entry without any + /// leading path component(s). + /// + /// As an example, + /// the output of the function will result in "foo" for all the following paths: + /// - "./foo" + /// - "/the/foo" + /// - "../../foo" /// /// # Examples /// From 4a9f292e5005fcb0174fe83a329f19d47da21f2d Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 23 Jun 2023 11:15:34 +0100 Subject: [PATCH 03/12] Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std` This was added in rust-lang/compiler-builtins#526 to force all compiler-builtins intrinsics to use weak linkage. --- library/alloc/Cargo.toml | 1 + library/std/Cargo.toml | 1 + library/sysroot/Cargo.toml | 1 + 3 files changed, 3 insertions(+) diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml index 95c07abf731..e5f828c4c0b 100644 --- a/library/alloc/Cargo.toml +++ b/library/alloc/Cargo.toml @@ -35,3 +35,4 @@ compiler-builtins-mem = ['compiler_builtins/mem'] compiler-builtins-c = ["compiler_builtins/c"] compiler-builtins-no-asm = ["compiler_builtins/no-asm"] compiler-builtins-mangled-names = ["compiler_builtins/mangled-names"] +compiler-builtins-weak-intrinsics = ["compiler_builtins/weak-intrinsics"] diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index af74efa6bf8..c3447b4cc78 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -65,6 +65,7 @@ compiler-builtins-c = ["alloc/compiler-builtins-c"] compiler-builtins-mem = ["alloc/compiler-builtins-mem"] compiler-builtins-no-asm = ["alloc/compiler-builtins-no-asm"] compiler-builtins-mangled-names = ["alloc/compiler-builtins-mangled-names"] +compiler-builtins-weak-intrinsics = ["alloc/compiler-builtins-weak-intrinsics"] llvm-libunwind = ["unwind/llvm-libunwind"] system-llvm-libunwind = ["unwind/system-llvm-libunwind"] diff --git a/library/sysroot/Cargo.toml b/library/sysroot/Cargo.toml index 5356ee277cc..6ff24a8db59 100644 --- a/library/sysroot/Cargo.toml +++ b/library/sysroot/Cargo.toml @@ -17,6 +17,7 @@ compiler-builtins-c = ["std/compiler-builtins-c"] compiler-builtins-mem = ["std/compiler-builtins-mem"] compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"] compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"] +compiler-builtins-weak-intrinsics = ["std/compiler-builtins-weak-intrinsics"] llvm-libunwind = ["std/llvm-libunwind"] system-llvm-libunwind = ["std/system-llvm-libunwind"] panic-unwind = ["std/panic_unwind"] From c4fca7202b83053f12e1f47ec0a44c01de2ec2aa Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 09:51:53 -0700 Subject: [PATCH 04/12] Abbreviate long typenames so they don't get wrapped in results --- src/librustdoc/html/static/js/search.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 452348dc865..b8cc0a6db71 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -52,9 +52,9 @@ const longItemTypes = [ "enum variant", "macro", "primitive type", - "associated type", + "assoc type", "constant", - "associated constant", + "assoc const", "union", "foreign type", "keyword", From 12de5b7ff33fe37eb8ce5dd92efd1366e43e85aa Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 10:12:27 -0700 Subject: [PATCH 05/12] Make typenames a bit wider to support "existential type" --- src/librustdoc/html/static/css/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 83b989fc080..b4ee3482de3 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -894,7 +894,7 @@ so that we can apply CSS-filters to change the arrow color in themes */ display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; - width: 6rem; + width: 7rem; } .popover { From 5f433f33ed8d4a8ede25c36d2bb0543e8b101920 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Fri, 23 Jun 2023 12:02:55 -0700 Subject: [PATCH 06/12] Reduce typename width to 6.25rem This makes "existential type" look slightly cramped (though still readable), but it makes all other typenames look better. Existential types are currently very rare, and we can always tweak this later if necessary. --- src/librustdoc/html/static/css/rustdoc.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index b4ee3482de3..b6d90091bba 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -894,7 +894,7 @@ so that we can apply CSS-filters to change the arrow color in themes */ display: inline-block; color: var(--search-results-grey-color); font-size: 0.875rem; - width: 7rem; + width: 6.25rem; } .popover { From b556e28496209611c6ee7fef6f6ac6109af5c199 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 11:17:06 -0500 Subject: [PATCH 07/12] outline x.py alternate invocations to the dev guide almost no one on windows builds from source unless they're contributing, and `./x.py` just works on most unix systems. --- README.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 41b135972af..901213d2ca9 100644 --- a/README.md +++ b/README.md @@ -33,24 +33,13 @@ format: ``` This is how the documentation and examples assume you are running `x.py`. -Some alternative ways are: - -```sh -# On a Unix shell if you don't have the necessary `python3` command -./x [flags] - -# On the Windows Command Prompt (if .py files are configured to run Python) -x.py [flags] - -# You can also run Python yourself, e.g.: -python x.py [flags] -``` +See the [rustc dev guide][rustcguidebuild] if this does not work on your platform. More information about `x.py` can be found by running it with the `--help` flag or reading the [rustc dev guide][rustcguidebuild]. [gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html -[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html +[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#what-is-xpy ### Dependencies From dd314f6533c94125d08220b1ba188c6cf68226c7 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 11:17:59 -0500 Subject: [PATCH 08/12] give more helpful suggestions for a missing feature gate test --- src/tools/tidy/src/features.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 2fd4c797b43..7ad8f5c5c05 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -160,10 +160,10 @@ pub fn check( for &(name, _) in gate_untested.iter() { println!("Expected a gate test for the feature '{name}'."); println!( - "Hint: create a failing test file named 'feature-gate-{}.rs'\ - \n in the 'ui' test suite, with its failures due to\ - \n missing usage of `#![feature({})]`.", - name, name + "Hint: create a failing test file named 'tests/ui/feature-gates/feature-gate-{}.rs',\ + \n with its failures due to missing usage of `#![feature({})]`.", + name.replace("_", "-"), + name ); println!( "Hint: If you already have such a test and don't want to rename it,\ From e2eff0d4ab43946ea23998f1d48d7b4af5a71664 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 24 Jun 2023 19:56:29 +0100 Subject: [PATCH 09/12] Remove unnecessary `path` attribute --- library/std/src/sys/windows/c.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs index 5fc6136ba1f..54e1efb5c62 100644 --- a/library/std/src/sys/windows/c.rs +++ b/library/std/src/sys/windows/c.rs @@ -12,7 +12,6 @@ use crate::os::windows::io::{AsRawHandle, BorrowedHandle}; use crate::ptr; use core::ffi::NonZero_c_ulong; -#[path = "c/windows_sys.rs"] // c.rs is included from two places so we need to specify this mod windows_sys; pub use windows_sys::*; From fa7e965bf0af41ddd5865ee63782d3536263f964 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 13:09:48 -0500 Subject: [PATCH 10/12] Give a better error on Windows if python isn't installed Before: ``` PS C:\Users\vboxuser\rust> ./x x.ps1 PS C:\Users\vboxuser\rust> ``` After: ``` PS C:\Users\vboxuser\rust> ./x x.ps1 C:\Users\vboxuser\rust\x.ps1 : C:\Users\vboxuser\rust\x.ps1: error: did not find python installed help: consider installing it from https://www.python.org/downloads/windows/ At line:1 char:1 + ./x + ~~~ + CategoryInfo : NotInstalled: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,x.ps1 ``` The existing message from the shell script is already decent and I decided not to change it: ``` $ ./x Python was not found but can be installed from the Microsoft Store: ms-windows-store://pdp/?productid=9NJ46SX7X90P ``` --- x.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/x.ps1 b/x.ps1 index a156017628d..b036653e5b4 100755 --- a/x.ps1 +++ b/x.ps1 @@ -16,7 +16,13 @@ foreach ($arg in $args) { } function Get-Application($app) { - return Get-Command $app -ErrorAction SilentlyContinue -CommandType Application + $cmd = Get-Command $app -ErrorAction SilentlyContinue -CommandType Application | Select-Object -First 1 + if ($cmd.source -match '.*AppData\\Local\\Microsoft\\WindowsApps\\.*exe') { + # Windows for some reason puts a `python3.exe` executable in PATH that just opens the windows store. + # Ignore it. + return $false + } + return $cmd } function Invoke-Application($application, $arguments) { @@ -51,5 +57,7 @@ if (($null -ne $found) -and ($found.Length -ge 1)) { Invoke-Application $python $xpy_args } -Write-Error "${PSCommandPath}: error: did not find python installed" +$msg = "${PSCommandPath}: error: did not find python installed`n" +$msg += "help: consider installing it from https://www.python.org/downloads/" +Write-Error $msg -Category NotInstalled Exit 1 From 664ffa419eb4793d2c6e161d6f098b0104550ca2 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 13:16:39 -0500 Subject: [PATCH 11/12] Don't print "x.ps1" This is left over from adding `Get-Command -syntax`; it's not helpful. --- x.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x.ps1 b/x.ps1 index b036653e5b4..55f99901645 100755 --- a/x.ps1 +++ b/x.ps1 @@ -5,7 +5,7 @@ $ErrorActionPreference = "Stop" # syntax check -Get-Command -syntax ${PSCommandPath} +Get-Command -syntax ${PSCommandPath} >$null $xpy = Join-Path $PSScriptRoot x.py # Start-Process for some reason splits arguments on spaces. (Isn't powershell supposed to be simpler than bash?) From 9b97ae1d8c6e99a4832c84dec4d4b6faf5f583f6 Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 24 Jun 2023 14:30:35 -0700 Subject: [PATCH 12/12] rustdoc: Update GUI test --- tests/rustdoc-gui/search-result-display.goml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/rustdoc-gui/search-result-display.goml b/tests/rustdoc-gui/search-result-display.goml index afb3a44be30..6593c1a9c45 100644 --- a/tests/rustdoc-gui/search-result-display.goml +++ b/tests/rustdoc-gui/search-result-display.goml @@ -14,7 +14,8 @@ set-window-size: (600, 100) assert-size: (".search-results div.desc", {"width": 566}) // The result set is all on one line. -assert-css: (".search-results .result-name > span", {"display": "inline"}) +assert-css: (".search-results .result-name > span:not(.typename)", {"display": "inline"}) +assert-css: (".search-results .result-name > span.typename", {"display": "inline-block"}) // Check that the crate filter `