Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b4e2e4a

Browse files
committedJun 20, 2024
Auto merge of rust-lang#126736 - matthiaskrgr:rollup-rb20oe3, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#126380 (Add std Xtensa targets support) - rust-lang#126636 (Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s ) - rust-lang#126659 (More status-quo tests for the `#[coverage(..)]` attribute) - rust-lang#126711 (Make Option::as_[mut_]slice const) - rust-lang#126717 (Clean up some comments near `use` declarations) - rust-lang#126719 (Fix assertion failure for some `Expect` diagnostics.) - rust-lang#126730 (Add opaque type corner case test) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e057232 + 0829ab8 commit b4e2e4a

File tree

27 files changed

+56
-22
lines changed

27 files changed

+56
-22
lines changed
 

‎alloc/src/boxed/thin.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// Based on
2-
// https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs
3-
// by matthieu-m
1+
//! Based on
2+
//! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs>
3+
//! by matthieu-m
4+
45
use crate::alloc::{self, Layout, LayoutError};
56
use core::error::Error;
67
use core::fmt::{self, Debug, Display, Formatter};

‎alloc/src/vec/in_place_collect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
//! }
155155
//! vec.truncate(write_idx);
156156
//! ```
157+
157158
use crate::alloc::{handle_alloc_error, Global};
158159
use core::alloc::Allocator;
159160
use core::alloc::Layout;

‎core/src/option.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,8 @@ impl<T> Option<T> {
797797
#[inline]
798798
#[must_use]
799799
#[stable(feature = "option_as_slice", since = "1.75.0")]
800-
pub fn as_slice(&self) -> &[T] {
800+
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
801+
pub const fn as_slice(&self) -> &[T] {
801802
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
802803
// to the payload, with a length of 1, so this is equivalent to
803804
// `slice::from_ref`, and thus is safe.
@@ -811,7 +812,7 @@ impl<T> Option<T> {
811812
unsafe {
812813
slice::from_raw_parts(
813814
(self as *const Self).byte_add(core::mem::offset_of!(Self, Some.0)).cast(),
814-
usize::from(self.is_some()),
815+
self.is_some() as usize,
815816
)
816817
}
817818
}
@@ -851,7 +852,8 @@ impl<T> Option<T> {
851852
#[inline]
852853
#[must_use]
853854
#[stable(feature = "option_as_slice", since = "1.75.0")]
854-
pub fn as_mut_slice(&mut self) -> &mut [T] {
855+
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
856+
pub const fn as_mut_slice(&mut self) -> &mut [T] {
855857
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
856858
// to the payload, with a length of 1, so this is equivalent to
857859
// `slice::from_mut`, and thus is safe.
@@ -867,7 +869,7 @@ impl<T> Option<T> {
867869
unsafe {
868870
slice::from_raw_parts_mut(
869871
(self as *mut Self).byte_add(core::mem::offset_of!(Self, Some.0)).cast(),
870-
usize::from(self.is_some()),
872+
self.is_some() as usize,
871873
)
872874
}
873875
}

‎core/src/str/count.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//! Note: Because the term "leading byte" can sometimes be ambiguous (for
1818
//! example, it could also refer to the first byte of a slice), we'll often use
1919
//! the term "non-continuation byte" to refer to these bytes in the code.
20+
2021
use core::intrinsics::unlikely;
2122

2223
const USIZE_SIZE: usize = core::mem::size_of::<usize>();

‎core/tests/iter/adapters/map_windows.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
33
#[cfg(not(panic = "abort"))]
44
mod drop_checks {
55
//! These tests mainly make sure the elements are correctly dropped.
6+
67
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};
78

89
#[derive(Debug)]

‎core/tests/net/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// FIXME: These tests are all excellent candidates for AFL fuzz testing
2+
23
use core::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
34
use core::str::FromStr;
45

‎core/tests/num/ieee754.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
//! standard. That is why they accept wildly diverse inputs or may seem to duplicate other tests.
2828
//! Please consider this carefully when adding, removing, or reorganizing these tests. They are
2929
//! here so that it is clear what tests are required by the standard and what can be changed.
30+
3031
use ::core::str::FromStr;
3132

3233
// IEEE 754 for many tests is applied to specific bit patterns.

‎core/tests/option.rs

+9
Original file line numberDiff line numberDiff line change
@@ -574,4 +574,13 @@ fn as_slice() {
574574
assert_eq!(Some(43).as_mut_slice(), &[43]);
575575
assert_eq!(None::<i32>.as_slice(), &[]);
576576
assert_eq!(None::<i32>.as_mut_slice(), &[]);
577+
578+
const A: &[u32] = Some(44).as_slice();
579+
const B: &[u32] = None.as_slice();
580+
const _: () = {
581+
let [45] = Some(45).as_mut_slice() else { panic!() };
582+
let []: &[u32] = None.as_mut_slice() else { panic!() };
583+
};
584+
assert_eq!(A, &[44]);
585+
assert_eq!(B, &[]);
577586
}

‎core/tests/pin_macro.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// edition:2021
2+
23
use core::{
34
marker::PhantomPinned,
45
mem::{drop as stuff, transmute},

‎panic_unwind/src/miri.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Unwinding panics for Miri.
2+
23
use alloc::boxed::Box;
34
use core::any::Any;
45

‎portable-simd/crates/core_simd/examples/dot_product.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Code taken from the `packed_simd` crate
2-
// Run this code with `cargo test --example dot_product`
3-
//use std::iter::zip;
1+
//! Code taken from the `packed_simd` crate.
2+
//! Run this code with `cargo test --example dot_product`.
43
54
#![feature(array_chunks)]
65
#![feature(slice_as_chunks)]

‎portable-simd/crates/core_simd/src/ops/assign.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Assignment operators
2+
23
use super::*;
34
use core::ops::{AddAssign, MulAssign}; // commutative binary op-assignment
45
use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign}; // commutative bit binary op-assignment

‎portable-simd/crates/core_simd/src/ops/deref.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//! Ideally, Rust would take care of this itself,
33
//! and method calls usually handle the LHS implicitly.
44
//! But this is not the case with arithmetic ops.
5+
56
use super::*;
67

78
macro_rules! deref_lhs {

‎std/src/hash/random.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//! outside this crate.
77
//!
88
//! [`collections`]: crate::collections
9+
910
#[allow(deprecated)]
1011
use super::{BuildHasher, Hasher, SipHasher13};
1112
use crate::cell::Cell;

‎std/src/io/buffered/bufreader/buffer.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
///! An encapsulation of `BufReader`'s buffer management logic.
2-
///
3-
/// This module factors out the basic functionality of `BufReader` in order to protect two core
4-
/// invariants:
5-
/// * `filled` bytes of `buf` are always initialized
6-
/// * `pos` is always <= `filled`
7-
/// Since this module encapsulates the buffer management logic, we can ensure that the range
8-
/// `pos..filled` is always a valid index into the initialized region of the buffer. This means
9-
/// that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so
10-
/// without encountering any runtime bounds checks.
1+
//! An encapsulation of `BufReader`'s buffer management logic.
2+
//!
3+
//! This module factors out the basic functionality of `BufReader` in order to protect two core
4+
//! invariants:
5+
//! * `filled` bytes of `buf` are always initialized
6+
//! * `pos` is always <= `filled`
7+
//! Since this module encapsulates the buffer management logic, we can ensure that the range
8+
//! `pos..filled` is always a valid index into the initialized region of the buffer. This means
9+
//! that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so
10+
//! without encountering any runtime bounds checks.
11+
1112
use crate::cmp;
1213
use crate::io::{self, BorrowedBuf, Read};
1314
use crate::mem::MaybeUninit;

‎std/src/sys/os_str/wtf8.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/// The underlying OsString/OsStr implementation on Windows is a
2-
/// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
1+
//! The underlying OsString/OsStr implementation on Windows is a
2+
//! wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
3+
34
use crate::borrow::Cow;
45
use crate::collections::TryReserveError;
56
use crate::fmt;

‎std/src/sys/pal/itron/thread.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Thread implementation backed by μITRON tasks. Assumes `acre_tsk` and
22
//! `exd_tsk` are available.
3+
34
use super::{
45
abi,
56
error::{expect_success, expect_success_aborting, ItronError},

‎std/src/sys/pal/solid/abi/fs.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! `solid_fs.h`
2+
23
use crate::os::raw::{c_char, c_int, c_uchar};
34
pub use libc::{
45
ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,

‎std/src/sys/pal/unix/process/process_unsupported/wait_status.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Emulated wait status for non-Unix #[cfg(unix) platforms
22
//!
33
//! Separate module to facilitate testing against a real Unix implementation.
4+
45
use crate::ffi::c_int;
56
use crate::fmt;
67
use crate::num::NonZero;

‎std/src/sys/pal/unix/thread.rs

+1
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ mod cgroups {
475475
//! * cgroup v2 in non-standard mountpoints
476476
//! * paths containing control characters or spaces, since those would be escaped in procfs
477477
//! output and we don't unescape
478+
478479
use crate::borrow::Cow;
479480
use crate::ffi::OsString;
480481
use crate::fs::{try_exists, File};

‎std/src/sys/sync/condvar/itron.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! POSIX conditional variable implementation based on user-space wait queues.
2+
23
use crate::sys::pal::itron::{
34
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
45
};

‎std/src/sys/sync/mutex/itron.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Mutex implementation backed by μITRON mutexes. Assumes `acre_mtx` and
22
//! `TA_INHERIT` are available.
3+
34
use crate::sys::pal::itron::{
45
abi,
56
error::{expect_success, expect_success_aborting, fail, ItronError},

‎std/src/sys/sync/rwlock/solid.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! A readers-writer lock implementation backed by the SOLID kernel extension.
2+
23
use crate::sys::pal::{
34
abi,
45
itron::{

‎std/tests/create_dir_all_bare.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
//! Note that this test changes the current directory so
44
//! should not be in the same process as other tests.
5+
56
use std::env;
67
use std::fs;
78
use std::path::{Path, PathBuf};

‎test/src/bench.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Benchmarking module.
2+
23
use super::{
34
event::CompletedTest,
45
options::BenchMode,

‎test/src/helpers/concurrency.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Helper module which helps to determine amount of threads to be used
22
//! during tests execution.
3+
34
use std::{env, num::NonZero, thread};
45

56
pub fn get_concurrency() -> usize {

‎test/src/helpers/metrics.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Benchmark metrics.
2+
23
use std::collections::BTreeMap;
34

45
#[derive(Clone, PartialEq, Debug, Copy)]

0 commit comments

Comments
 (0)
Failed to load comments.