Skip to content

Commit b4e2e4a

Browse files
committed
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 6 additions & 4 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 9 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy