Skip to content

Commit 6c6d210

Browse files
committed
Auto merge of #130710 - GuillaumeGomez:rollup-mfuha68, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - #130658 (Fix docs of compare_bytes) - #130670 (delay uncapping the max_read_size in File::read_to_end) - #130690 (interpret: remove outdated FIXME) - #130692 (make unstable Result::flatten a const fn) - #130702 (Add some missing unstable book tracking issue links) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8ed95d1 + a34e0f5 commit 6c6d210

File tree

8 files changed

+34
-7
lines changed

8 files changed

+34
-7
lines changed

Diff for: compiler/rustc_const_eval/src/interpret/call.rs

-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
221221
}
222222

223223
// Fall back to exact equality.
224-
// FIXME: We are missing the rules for "repr(C) wrapping compatible types".
225224
Ok(caller == callee)
226225
}
227226

Diff for: library/core/src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2733,7 +2733,7 @@ extern "rust-intrinsic" {
27332733

27342734
/// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)`
27352735
/// as unsigned bytes, returning negative if `left` is less, zero if all the
2736-
/// bytes match, or positive if `right` is greater.
2736+
/// bytes match, or positive if `left` is greater.
27372737
///
27382738
/// This underlies things like `<[u8]>::cmp`, and will usually lower to `memcmp`.
27392739
///

Diff for: library/core/src/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,7 @@ impl<T> Option<Option<T>> {
25382538
#[stable(feature = "option_flattening", since = "1.40.0")]
25392539
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
25402540
pub const fn flatten(self) -> Option<T> {
2541+
// FIXME(const-hack): could be written with `and_then`
25412542
match self {
25422543
Some(inner) => inner,
25432544
None => None,

Diff for: library/core/src/result.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1676,8 +1676,13 @@ impl<T, E> Result<Result<T, E>, E> {
16761676
/// ```
16771677
#[inline]
16781678
#[unstable(feature = "result_flattening", issue = "70142")]
1679-
pub fn flatten(self) -> Result<T, E> {
1680-
self.and_then(convert::identity)
1679+
#[rustc_const_unstable(feature = "result_flattening", issue = "70142")]
1680+
pub const fn flatten(self) -> Result<T, E> {
1681+
// FIXME(const-hack): could be written with `and_then`
1682+
match self {
1683+
Ok(inner) => inner,
1684+
Err(e) => Err(e),
1685+
}
16811686
}
16821687
}
16831688

Diff for: library/std/src/io/mod.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,7 @@ where
398398
// - avoid passing large buffers to readers that always initialize the free capacity if they perform short reads (#23815, #23820)
399399
// - pass large buffers to readers that do not initialize the spare capacity. this can amortize per-call overheads
400400
// - and finally pass not-too-small and not-too-large buffers to Windows read APIs because they manage to suffer from both problems
401-
// at the same time, i.e. small reads suffer from syscall overhead, all reads incur initialization cost
402-
// proportional to buffer size (#110650)
401+
// at the same time, i.e. small reads suffer from syscall overhead, all reads incur costs proportional to buffer size (#110650)
403402
//
404403
pub(crate) fn default_read_to_end<R: Read + ?Sized>(
405404
r: &mut R,
@@ -444,6 +443,8 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(
444443
}
445444
}
446445

446+
let mut consecutive_short_reads = 0;
447+
447448
loop {
448449
if buf.len() == buf.capacity() && buf.capacity() == start_cap {
449450
// 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<R: Read + ?Sized>(
489490
return Ok(buf.len() - start_len);
490491
}
491492

493+
if bytes_read < buf_len {
494+
consecutive_short_reads += 1;
495+
} else {
496+
consecutive_short_reads = 0;
497+
}
498+
492499
// store how much was initialized but not filled
493500
initialized = unfilled_but_initialized;
494501

@@ -503,7 +510,10 @@ pub(crate) fn default_read_to_end<R: Read + ?Sized>(
503510
// The reader is returning short reads but it doesn't call ensure_init().
504511
// In that case we no longer need to restrict read sizes to avoid
505512
// initialization costs.
506-
if !was_fully_initialized {
513+
// When reading from disk we usually don't get any short reads except at EOF.
514+
// So we wait for at least 2 short reads before uncapping the read buffer;
515+
// this helps with the Windows issue.
516+
if !was_fully_initialized && consecutive_short_reads > 1 {
507517
max_read_size = usize::MAX;
508518
}
509519

Diff for: src/doc/unstable-book/src/compiler-flags/branch-protection.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# `branch-protection`
22

3+
The tracking issue for this feature is: [#113369](https://github.com/rust-lang/rust/issues/113369).
4+
5+
------------------------
6+
37
This option lets you enable branch authentication instructions on AArch64.
48
This option is only accepted when targeting AArch64 architectures.
59
It takes some combination of the following values, separated by a `,`.

Diff for: src/doc/unstable-book/src/language-features/more-qualified-paths.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
The `more_qualified_paths` feature can be used in order to enable the
44
use of qualified paths in patterns.
55

6+
The tracking issue for this feature is: [#86935](https://github.com/rust-lang/rust/issues/86935).
7+
8+
------------------------
9+
610
## Example
711

812
```rust

Diff for: src/doc/unstable-book/src/language-features/postfix-match.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
`postfix-match` adds the feature for matching upon values postfix
44
the expressions that generate the values.
55

6+
The tracking issue for this feature is: [#121618](https://github.com/rust-lang/rust/issues/121618).
7+
8+
------------------------
9+
610
```rust,edition2021
711
#![feature(postfix_match)]
812

0 commit comments

Comments
 (0)