From d44a5fd00b63b91569ac5812c12833a440f1e698 Mon Sep 17 00:00:00 2001 From: EqualMa Date: Sat, 21 Sep 2024 18:27:49 +0800 Subject: [PATCH 1/5] Fix docs of compare_bytes --- library/core/src/intrinsics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 7870a62ea81..3b2a6e820c6 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2733,7 +2733,7 @@ extern "rust-intrinsic" { /// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)` /// as unsigned bytes, returning negative if `left` is less, zero if all the - /// bytes match, or positive if `right` is greater. + /// bytes match, or positive if `left` is greater. /// /// This underlies things like `<[u8]>::cmp`, and will usually lower to `memcmp`. /// From ca1a2a645725709f6f02da243ab34a6fbba5d8e3 Mon Sep 17 00:00:00 2001 From: The 8472 Date: Sat, 21 Sep 2024 18:50:29 +0200 Subject: [PATCH 2/5] wait for two short reads before uncapping the max read size for disk IO: 1st short read = probably at end of file 2nd short read = confirming that it's indeed EOF --- library/std/src/io/mod.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 2a4262b2367..80eb4f0ce96 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -398,8 +398,7 @@ where // - avoid passing large buffers to readers that always initialize the free capacity if they perform short reads (#23815, #23820) // - pass large buffers to readers that do not initialize the spare capacity. this can amortize per-call overheads // - and finally pass not-too-small and not-too-large buffers to Windows read APIs because they manage to suffer from both problems -// at the same time, i.e. small reads suffer from syscall overhead, all reads incur initialization cost -// proportional to buffer size (#110650) +// at the same time, i.e. small reads suffer from syscall overhead, all reads incur costs proportional to buffer size (#110650) // pub(crate) fn default_read_to_end( r: &mut R, @@ -444,6 +443,8 @@ pub(crate) fn default_read_to_end( } } + let mut consecutive_short_reads = 0; + loop { if buf.len() == buf.capacity() && buf.capacity() == start_cap { // The buffer might be an exact fit. Let's read into a probe buffer @@ -489,6 +490,12 @@ pub(crate) fn default_read_to_end( return Ok(buf.len() - start_len); } + if bytes_read < buf_len { + consecutive_short_reads += 1; + } else { + consecutive_short_reads = 0; + } + // store how much was initialized but not filled initialized = unfilled_but_initialized; @@ -503,7 +510,10 @@ pub(crate) fn default_read_to_end( // The reader is returning short reads but it doesn't call ensure_init(). // In that case we no longer need to restrict read sizes to avoid // initialization costs. - if !was_fully_initialized { + // When reading from disk we usually don't get any short reads except at EOF. + // So we wait for at least 2 short reads before uncapping the read buffer; + // this helps with the Windows issue. + if !was_fully_initialized && consecutive_short_reads > 1 { max_read_size = usize::MAX; } From 27400ea4ed350f0a32e8423323d830c3ed139eeb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 22 Sep 2024 08:18:30 +0200 Subject: [PATCH 3/5] interpret: remove outdated FIXME --- compiler/rustc_const_eval/src/interpret/call.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 0f2b22f035b..9e7ed74fd5a 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -221,7 +221,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } // Fall back to exact equality. - // FIXME: We are missing the rules for "repr(C) wrapping compatible types". Ok(caller == callee) } From 89c3cbafb8d212468e899660af5b95f3b9df4bc6 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 22 Sep 2024 08:40:25 +0200 Subject: [PATCH 4/5] make unstable Result::flatten a const fn --- library/core/src/option.rs | 1 + library/core/src/result.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 5ba13969605..30c667e2494 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -2538,6 +2538,7 @@ impl Option> { #[stable(feature = "option_flattening", since = "1.40.0")] #[rustc_const_unstable(feature = "const_option", issue = "67441")] pub const fn flatten(self) -> Option { + // FIXME(const-hack): could be written with `and_then` match self { Some(inner) => inner, None => None, diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 9edd58259ba..610edae48d3 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -1676,8 +1676,13 @@ impl Result, E> { /// ``` #[inline] #[unstable(feature = "result_flattening", issue = "70142")] - pub fn flatten(self) -> Result { - self.and_then(convert::identity) + #[rustc_const_unstable(feature = "result_flattening", issue = "70142")] + pub const fn flatten(self) -> Result { + // FIXME(const-hack): could be written with `and_then` + match self { + Ok(inner) => inner, + Err(e) => Err(e), + } } } From 0510f06ad7d2c6dc39ac49938f6f83396d99b6c9 Mon Sep 17 00:00:00 2001 From: clubby789 Date: Sun, 22 Sep 2024 14:03:48 +0000 Subject: [PATCH 5/5] Add some missing tracking issue links --- src/doc/unstable-book/src/compiler-flags/branch-protection.md | 4 ++++ .../src/language-features/more-qualified-paths.md | 4 ++++ src/doc/unstable-book/src/language-features/postfix-match.md | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/doc/unstable-book/src/compiler-flags/branch-protection.md b/src/doc/unstable-book/src/compiler-flags/branch-protection.md index ca5664835f2..9276220f447 100644 --- a/src/doc/unstable-book/src/compiler-flags/branch-protection.md +++ b/src/doc/unstable-book/src/compiler-flags/branch-protection.md @@ -1,5 +1,9 @@ # `branch-protection` +The tracking issue for this feature is: [#113369](https://github.com/rust-lang/rust/issues/113369). + +------------------------ + This option lets you enable branch authentication instructions on AArch64. This option is only accepted when targeting AArch64 architectures. It takes some combination of the following values, separated by a `,`. diff --git a/src/doc/unstable-book/src/language-features/more-qualified-paths.md b/src/doc/unstable-book/src/language-features/more-qualified-paths.md index 857af577a6c..1a31ba8e14f 100644 --- a/src/doc/unstable-book/src/language-features/more-qualified-paths.md +++ b/src/doc/unstable-book/src/language-features/more-qualified-paths.md @@ -3,6 +3,10 @@ The `more_qualified_paths` feature can be used in order to enable the use of qualified paths in patterns. +The tracking issue for this feature is: [#86935](https://github.com/rust-lang/rust/issues/86935). + +------------------------ + ## Example ```rust diff --git a/src/doc/unstable-book/src/language-features/postfix-match.md b/src/doc/unstable-book/src/language-features/postfix-match.md index cd6b6a7442c..c931a85b141 100644 --- a/src/doc/unstable-book/src/language-features/postfix-match.md +++ b/src/doc/unstable-book/src/language-features/postfix-match.md @@ -3,6 +3,10 @@ `postfix-match` adds the feature for matching upon values postfix the expressions that generate the values. +The tracking issue for this feature is: [#121618](https://github.com/rust-lang/rust/issues/121618). + +------------------------ + ```rust,edition2021 #![feature(postfix_match)]