Skip to content

Commit

Permalink
Auto merge of rust-lang#126736 - matthiaskrgr:rollup-rb20oe3, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

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
  • Loading branch information
bors committed Jun 20, 2024
2 parents e057232 + 0829ab8 commit b4e2e4a
Show file tree
Hide file tree
Showing 27 changed files with 56 additions and 22 deletions.
7 changes: 4 additions & 3 deletions alloc/src/boxed/thin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Based on
// https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs
// by matthieu-m
//! Based on
//! <https://github.com/matthieu-m/rfc2580/blob/b58d1d3cba0d4b5e859d3617ea2d0943aaa31329/examples/thin.rs>
//! by matthieu-m

use crate::alloc::{self, Layout, LayoutError};
use core::error::Error;
use core::fmt::{self, Debug, Display, Formatter};
Expand Down
1 change: 1 addition & 0 deletions alloc/src/vec/in_place_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
//! }
//! vec.truncate(write_idx);
//! ```

use crate::alloc::{handle_alloc_error, Global};
use core::alloc::Allocator;
use core::alloc::Layout;
Expand Down
10 changes: 6 additions & 4 deletions core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ impl<T> Option<T> {
#[inline]
#[must_use]
#[stable(feature = "option_as_slice", since = "1.75.0")]
pub fn as_slice(&self) -> &[T] {
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
pub const fn as_slice(&self) -> &[T] {
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
// to the payload, with a length of 1, so this is equivalent to
// `slice::from_ref`, and thus is safe.
Expand All @@ -811,7 +812,7 @@ impl<T> Option<T> {
unsafe {
slice::from_raw_parts(
(self as *const Self).byte_add(core::mem::offset_of!(Self, Some.0)).cast(),
usize::from(self.is_some()),
self.is_some() as usize,
)
}
}
Expand Down Expand Up @@ -851,7 +852,8 @@ impl<T> Option<T> {
#[inline]
#[must_use]
#[stable(feature = "option_as_slice", since = "1.75.0")]
pub fn as_mut_slice(&mut self) -> &mut [T] {
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
pub const fn as_mut_slice(&mut self) -> &mut [T] {
// SAFETY: When the `Option` is `Some`, we're using the actual pointer
// to the payload, with a length of 1, so this is equivalent to
// `slice::from_mut`, and thus is safe.
Expand All @@ -867,7 +869,7 @@ impl<T> Option<T> {
unsafe {
slice::from_raw_parts_mut(
(self as *mut Self).byte_add(core::mem::offset_of!(Self, Some.0)).cast(),
usize::from(self.is_some()),
self.is_some() as usize,
)
}
}
Expand Down
1 change: 1 addition & 0 deletions core/src/str/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Note: Because the term "leading byte" can sometimes be ambiguous (for
//! example, it could also refer to the first byte of a slice), we'll often use
//! the term "non-continuation byte" to refer to these bytes in the code.

use core::intrinsics::unlikely;

const USIZE_SIZE: usize = core::mem::size_of::<usize>();
Expand Down
1 change: 1 addition & 0 deletions core/tests/iter/adapters/map_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
#[cfg(not(panic = "abort"))]
mod drop_checks {
//! These tests mainly make sure the elements are correctly dropped.

use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering::SeqCst};

#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions core/tests/net/parser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// FIXME: These tests are all excellent candidates for AFL fuzz testing

use core::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use core::str::FromStr;

Expand Down
1 change: 1 addition & 0 deletions core/tests/num/ieee754.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
//! standard. That is why they accept wildly diverse inputs or may seem to duplicate other tests.
//! Please consider this carefully when adding, removing, or reorganizing these tests. They are
//! here so that it is clear what tests are required by the standard and what can be changed.

use ::core::str::FromStr;

// IEEE 754 for many tests is applied to specific bit patterns.
Expand Down
9 changes: 9 additions & 0 deletions core/tests/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,4 +574,13 @@ fn as_slice() {
assert_eq!(Some(43).as_mut_slice(), &[43]);
assert_eq!(None::<i32>.as_slice(), &[]);
assert_eq!(None::<i32>.as_mut_slice(), &[]);

const A: &[u32] = Some(44).as_slice();
const B: &[u32] = None.as_slice();
const _: () = {
let [45] = Some(45).as_mut_slice() else { panic!() };
let []: &[u32] = None.as_mut_slice() else { panic!() };
};
assert_eq!(A, &[44]);
assert_eq!(B, &[]);
}
1 change: 1 addition & 0 deletions core/tests/pin_macro.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// edition:2021

use core::{
marker::PhantomPinned,
mem::{drop as stuff, transmute},
Expand Down
1 change: 1 addition & 0 deletions panic_unwind/src/miri.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Unwinding panics for Miri.

use alloc::boxed::Box;
use core::any::Any;

Expand Down
5 changes: 2 additions & 3 deletions portable-simd/crates/core_simd/examples/dot_product.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Code taken from the `packed_simd` crate
// Run this code with `cargo test --example dot_product`
//use std::iter::zip;
//! Code taken from the `packed_simd` crate.
//! Run this code with `cargo test --example dot_product`.

#![feature(array_chunks)]
#![feature(slice_as_chunks)]
Expand Down
1 change: 1 addition & 0 deletions portable-simd/crates/core_simd/src/ops/assign.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Assignment operators

use super::*;
use core::ops::{AddAssign, MulAssign}; // commutative binary op-assignment
use core::ops::{BitAndAssign, BitOrAssign, BitXorAssign}; // commutative bit binary op-assignment
Expand Down
1 change: 1 addition & 0 deletions portable-simd/crates/core_simd/src/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//! Ideally, Rust would take care of this itself,
//! and method calls usually handle the LHS implicitly.
//! But this is not the case with arithmetic ops.

use super::*;

macro_rules! deref_lhs {
Expand Down
1 change: 1 addition & 0 deletions std/src/hash/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! outside this crate.
//!
//! [`collections`]: crate::collections

#[allow(deprecated)]
use super::{BuildHasher, Hasher, SipHasher13};
use crate::cell::Cell;
Expand Down
21 changes: 11 additions & 10 deletions std/src/io/buffered/bufreader/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
///! An encapsulation of `BufReader`'s buffer management logic.
///
/// This module factors out the basic functionality of `BufReader` in order to protect two core
/// invariants:
/// * `filled` bytes of `buf` are always initialized
/// * `pos` is always <= `filled`
/// Since this module encapsulates the buffer management logic, we can ensure that the range
/// `pos..filled` is always a valid index into the initialized region of the buffer. This means
/// that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so
/// without encountering any runtime bounds checks.
//! An encapsulation of `BufReader`'s buffer management logic.
//!
//! This module factors out the basic functionality of `BufReader` in order to protect two core
//! invariants:
//! * `filled` bytes of `buf` are always initialized
//! * `pos` is always <= `filled`
//! Since this module encapsulates the buffer management logic, we can ensure that the range
//! `pos..filled` is always a valid index into the initialized region of the buffer. This means
//! that user code which wants to do reads from a `BufReader` via `buffer` + `consume` can do so
//! without encountering any runtime bounds checks.

use crate::cmp;
use crate::io::{self, BorrowedBuf, Read};
use crate::mem::MaybeUninit;
Expand Down
5 changes: 3 additions & 2 deletions std/src/sys/os_str/wtf8.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// The underlying OsString/OsStr implementation on Windows is a
/// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
//! The underlying OsString/OsStr implementation on Windows is a
//! wrapper around the "WTF-8" encoding; see the `wtf8` module for more.

use crate::borrow::Cow;
use crate::collections::TryReserveError;
use crate::fmt;
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/pal/itron/thread.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Thread implementation backed by μITRON tasks. Assumes `acre_tsk` and
//! `exd_tsk` are available.

use super::{
abi,
error::{expect_success, expect_success_aborting, ItronError},
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/pal/solid/abi/fs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! `solid_fs.h`

use crate::os::raw::{c_char, c_int, c_uchar};
pub use libc::{
ino_t, off_t, stat, time_t, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Emulated wait status for non-Unix #[cfg(unix) platforms
//!
//! Separate module to facilitate testing against a real Unix implementation.

use crate::ffi::c_int;
use crate::fmt;
use crate::num::NonZero;
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ mod cgroups {
//! * cgroup v2 in non-standard mountpoints
//! * paths containing control characters or spaces, since those would be escaped in procfs
//! output and we don't unescape

use crate::borrow::Cow;
use crate::ffi::OsString;
use crate::fs::{try_exists, File};
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/sync/condvar/itron.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! POSIX conditional variable implementation based on user-space wait queues.

use crate::sys::pal::itron::{
abi, error::expect_success_aborting, spin::SpinMutex, task, time::with_tmos_strong,
};
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/sync/mutex/itron.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Mutex implementation backed by μITRON mutexes. Assumes `acre_mtx` and
//! `TA_INHERIT` are available.

use crate::sys::pal::itron::{
abi,
error::{expect_success, expect_success_aborting, fail, ItronError},
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/sync/rwlock/solid.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! A readers-writer lock implementation backed by the SOLID kernel extension.

use crate::sys::pal::{
abi,
itron::{
Expand Down
1 change: 1 addition & 0 deletions std/tests/create_dir_all_bare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//! Note that this test changes the current directory so
//! should not be in the same process as other tests.

use std::env;
use std::fs;
use std::path::{Path, PathBuf};
Expand Down
1 change: 1 addition & 0 deletions test/src/bench.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Benchmarking module.

use super::{
event::CompletedTest,
options::BenchMode,
Expand Down
1 change: 1 addition & 0 deletions test/src/helpers/concurrency.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Helper module which helps to determine amount of threads to be used
//! during tests execution.

use std::{env, num::NonZero, thread};

pub fn get_concurrency() -> usize {
Expand Down
1 change: 1 addition & 0 deletions test/src/helpers/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Benchmark metrics.

use std::collections::BTreeMap;

#[derive(Clone, PartialEq, Debug, Copy)]
Expand Down

0 comments on commit b4e2e4a

Please sign in to comment.