Skip to content

Update subtree/library to 2025-04-23 #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
a57be39
cargo update
invalid-email-address Apr 13, 2025
fc85ced
Hermit: Unify std::env::args with Unix
thaliaarchi Apr 12, 2025
e45b238
Clarify why SGX code specifies linkage/symbol names for certain statics
Apr 14, 2025
ee40d87
fix missing word in comment
mumbleskates Apr 17, 2025
779deec
Point UNIX_EPOCH to associated constant in SystemTime docs
coolreader18 Apr 17, 2025
ed28bd2
Be more specific about the error in the SystemTime example
coolreader18 Apr 17, 2025
35b0ea7
LocalKey<T>: document that the dtor should not panic
ShE3py Apr 18, 2025
36a886a
rtprintpanic: clarify that the error is aborting the process
ShE3py Apr 18, 2025
9ab89ad
Invert `<CString as Deref>::deref` and `CString::as_c_str`
tamird Apr 18, 2025
4cb999a
Move `<CStr as Debug>` test to coretests
tamird Apr 18, 2025
1585382
Remove errant doc comment lines
tamird Apr 18, 2025
d9af121
docs: fix typo change from inconstants to invariants
c-git Apr 19, 2025
07de1a6
stabilize `naked_functions`
folkertdev Dec 18, 2024
e3fdd2f
simd intrinsics with mask: accept unsigned integer masks
RalfJung Mar 3, 2025
987e8cd
Rollup merge of #137953 - RalfJung:simd-intrinsic-masks, r=WaffleLapkin
ChrisDenton Apr 20, 2025
8427db1
Rollup merge of #140054 - c-git:patch-1, r=joboet
ChrisDenton Apr 20, 2025
19a9fe5
Update `libc` to 0.2.172 for std
Berrysoft Apr 20, 2025
1f234b5
Auto merge of #140079 - ChrisDenton:rollup-2h5cg94, r=ChrisDenton
bors Apr 20, 2025
9178adb
Auto merge of #139727 - rust-lang:cargo_update, r=Mark-Simulacrum
bors Apr 21, 2025
3ecfe0e
cleanup redundant pattern instances
jogru0 Apr 21, 2025
49649b6
Replace colon with parentheses, add missing period
tamird Apr 18, 2025
79729f9
Rollup merge of #139946 - mumbleskates:any-fix-missing-word, r=jhpratt
ChrisDenton Apr 21, 2025
f5c78cd
Rollup merge of #139982 - coolreader18:time-doc-tweak, r=jhpratt
ChrisDenton Apr 21, 2025
e4a3c15
Rollup merge of #140009 - ShE3py:tls-abort, r=thomcc
ChrisDenton Apr 21, 2025
7f7d45c
Rollup merge of #134213 - folkertdev:stabilize-naked-functions, r=tgr…
ChrisDenton Apr 21, 2025
b6fae47
Rollup merge of #139711 - thaliaarchi:hermit-args, r=jhpratt
ChrisDenton Apr 21, 2025
809c35f
Rollup merge of #139795 - jethrogb:jb/sgx-linkage-comments, r=joboet
ChrisDenton Apr 21, 2025
a33105e
Rollup merge of #140111 - jogru0:redundant_pattern, r=compiler-errors
ChrisDenton Apr 21, 2025
9be04dc
Rollup merge of #140118 - tamird:cstr-cleanup, r=joboet
ChrisDenton Apr 21, 2025
98e2a42
Auto merge of #140127 - ChrisDenton:rollup-2kye32h, r=ChrisDenton
bors Apr 21, 2025
54a7b4f
Rollup merge of #140081 - Berrysoft:update-libc-172, r=tgross35
ChrisDenton Apr 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl CString {
#[stable(feature = "as_c_str", since = "1.20.0")]
#[rustc_diagnostic_item = "cstring_as_c_str"]
pub fn as_c_str(&self) -> &CStr {
&*self
unsafe { CStr::from_bytes_with_nul_unchecked(self.as_bytes_with_nul()) }
}

/// Converts this `CString` into a boxed [`CStr`].
Expand Down Expand Up @@ -705,14 +705,14 @@ impl ops::Deref for CString {

#[inline]
fn deref(&self) -> &CStr {
unsafe { CStr::from_bytes_with_nul_unchecked(self.as_bytes_with_nul()) }
self.as_c_str()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for CString {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
fmt::Debug::fmt(self.as_c_str(), f)
}
}

Expand Down
6 changes: 0 additions & 6 deletions alloctests/tests/c_str2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ fn build_with_zero2() {
assert!(CString::new(vec![0]).is_err());
}

#[test]
fn formatted() {
let s = CString::new(&b"abc\x01\x02\n\xE2\x80\xA6\xFF"[..]).unwrap();
assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#);
}

#[test]
fn borrowed() {
unsafe {
Expand Down
4 changes: 2 additions & 2 deletions core/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,8 +772,8 @@ impl hash::Hash for TypeId {
// (especially given the previous point about the lower 64 bits being
// high quality on their own).
// - It is correct to do so -- only hashing a subset of `self` is still
// with an `Eq` implementation that considers the entire value, as
// ours does.
// compatible with an `Eq` implementation that considers the entire
// value, as ours does.
self.t.1.hash(state);
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
///
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
#[unstable(feature = "naked_functions", issue = "90957")]
#[stable(feature = "naked_functions", since = "CURRENT_RUSTC_VERSION")]
#[rustc_builtin_macro]
pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) {
/* compiler built-in */
Expand Down
3 changes: 1 addition & 2 deletions core/src/bstr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ use crate::ops::{Deref, DerefMut, DerefPure};
/// presented as hex escape sequences.
///
/// The `Display` implementation behaves as if the `ByteStr` were first lossily converted to a
/// `str`, with invalid UTF-8 presented as the Unicode replacement character: �
///
/// `str`, with invalid UTF-8 presented as the Unicode replacement character (�).
#[unstable(feature = "bstr", issue = "134915")]
#[repr(transparent)]
#[doc(alias = "BStr")]
Expand Down
1 change: 0 additions & 1 deletion core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ impl Error for FromBytesWithNulError {
/// within the slice.
///
/// This error is created by the [`CStr::from_bytes_until_nul`] method.
///
#[derive(Clone, PartialEq, Eq, Debug)]
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
pub struct FromBytesUntilNulError(());
Expand Down
10 changes: 5 additions & 5 deletions core/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ pub unsafe fn simd_shuffle<T, U, V>(x: T, y: T, idx: U) -> V;
///
/// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`.
///
/// `V` must be a vector of signed integers with the same length as `T` (but any element size).
/// `V` must be a vector of integers with the same length as `T` (but any element size).
///
/// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, read the pointer.
/// Otherwise if the corresponding value in `mask` is `0`, return the corresponding value from
Expand All @@ -325,7 +325,7 @@ pub unsafe fn simd_gather<T, U, V>(val: T, ptr: U, mask: V) -> T;
///
/// `U` must be a vector of pointers to the element type of `T`, with the same length as `T`.
///
/// `V` must be a vector of signed integers with the same length as `T` (but any element size).
/// `V` must be a vector of integers with the same length as `T` (but any element size).
///
/// For each pointer in `ptr`, if the corresponding value in `mask` is `!0`, write the
/// corresponding value in `val` to the pointer.
Expand All @@ -349,7 +349,7 @@ pub unsafe fn simd_scatter<T, U, V>(val: T, ptr: U, mask: V);
///
/// `U` must be a pointer to the element type of `T`
///
/// `V` must be a vector of signed integers with the same length as `T` (but any element size).
/// `V` must be a vector of integers with the same length as `T` (but any element size).
///
/// For each element, if the corresponding value in `mask` is `!0`, read the corresponding
/// pointer offset from `ptr`.
Expand All @@ -372,7 +372,7 @@ pub unsafe fn simd_masked_load<V, U, T>(mask: V, ptr: U, val: T) -> T;
///
/// `U` must be a pointer to the element type of `T`
///
/// `V` must be a vector of signed integers with the same length as `T` (but any element size).
/// `V` must be a vector of integers with the same length as `T` (but any element size).
///
/// For each element, if the corresponding value in `mask` is `!0`, write the corresponding
/// value in `val` to the pointer offset from `ptr`.
Expand Down Expand Up @@ -556,7 +556,7 @@ pub unsafe fn simd_bitmask<T, U>(x: T) -> U;
///
/// `T` must be a vector.
///
/// `M` must be a signed integer vector with the same length as `T` (but any element size).
/// `M` must be an integer vector with the same length as `T` (but any element size).
///
/// For each element, if the corresponding value in `mask` is `!0`, select the element from
/// `if_true`. If the corresponding value in `mask` is `0`, select the element from
Expand Down
2 changes: 1 addition & 1 deletion core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2814,7 +2814,7 @@ impl<T> [T] {
let half = size / 2;
let mid = base + half;

// SAFETY: the call is made safe by the following inconstants:
// SAFETY: the call is made safe by the following invariants:
// - `mid >= 0`: by definition
// - `mid < size`: `mid = size / 2 + size / 4 + size / 8 ...`
let cmp = f(unsafe { self.get_unchecked(mid) });
Expand Down
6 changes: 6 additions & 0 deletions coretests/tests/ffi/cstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ fn compares_as_u8s() {
assert_eq!(Ord::cmp(a, b), Ord::cmp(a_bytes, b_bytes));
assert_eq!(PartialOrd::partial_cmp(a, b), PartialOrd::partial_cmp(a_bytes, b_bytes));
}

#[test]
fn debug() {
let s = c"abc\x01\x02\n\xE2\x80\xA6\xFF";
assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#);
}
2 changes: 1 addition & 1 deletion std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
addr2line = { version = "0.24.0", optional = true, default-features = false }

[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
libc = { version = "0.2.171", default-features = false, features = [
libc = { version = "0.2.172", default-features = false, features = [
'rustc-dep-of-std',
], public = true }

Expand Down
2 changes: 1 addition & 1 deletion std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ impl Hash for Path {
if !verbatim {
component_start += match tail {
[b'.'] => 1,
[b'.', sep @ _, ..] if is_sep_byte(*sep) => 1,
[b'.', sep, ..] if is_sep_byte(*sep) => 1,
_ => 0,
};
}
Expand Down
2 changes: 1 addition & 1 deletion std/src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ macro_rules! rtprintpanic {
macro_rules! rtabort {
($($t:tt)*) => {
{
rtprintpanic!("fatal runtime error: {}\n", format_args!($($t)*));
rtprintpanic!("fatal runtime error: {}, aborting\n", format_args!($($t)*));
crate::sys::abort_internal();
}
}
Expand Down
4 changes: 3 additions & 1 deletion std/src/sys/alloc/sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ use crate::sys::pal::waitqueue::SpinMutex;
// The current allocator here is the `dlmalloc` crate which we've got included
// in the rust-lang/rust repository as a submodule. The crate is a port of
// dlmalloc.c from C to Rust.
//
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys5alloc3sgx8DLMALLOCE")]
static DLMALLOC: SpinMutex<dlmalloc::Dlmalloc<Sgx>> =
SpinMutex::new(dlmalloc::Dlmalloc::new_with_allocator(Sgx {}));

Expand Down
35 changes: 0 additions & 35 deletions std/src/sys/args/hermit.rs

This file was deleted.

8 changes: 4 additions & 4 deletions std/src/sys/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
#![forbid(unsafe_op_in_unsafe_fn)]

cfg_if::cfg_if! {
if #[cfg(all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))))] {
if #[cfg(any(
all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))),
target_os = "hermit",
))] {
mod unix;
pub use unix::*;
} else if #[cfg(target_family = "windows")] {
mod windows;
pub use windows::*;
} else if #[cfg(target_os = "hermit")] {
mod hermit;
pub use hermit::*;
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
mod sgx;
pub use sgx::*;
Expand Down
1 change: 1 addition & 0 deletions std/src/sys/args/sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::sys::pal::abi::usercalls::raw::ByteBuffer;
use crate::sys_common::FromInner;
use crate::{fmt, slice};

// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")]
static ARGS: AtomicUsize = AtomicUsize::new(0);
Expand Down
6 changes: 5 additions & 1 deletion std/src/sys/args/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#![allow(dead_code)] // runtime init functions not used during testing

use crate::ffi::CStr;
#[cfg(target_os = "hermit")]
use crate::os::hermit::ffi::OsStringExt;
#[cfg(not(target_os = "hermit"))]
use crate::os::unix::ffi::OsStringExt;

#[path = "common.rs"]
Expand Down Expand Up @@ -73,6 +76,7 @@ pub fn args() -> Args {
target_os = "illumos",
target_os = "emscripten",
target_os = "haiku",
target_os = "hermit",
target_os = "l4re",
target_os = "fuchsia",
target_os = "redox",
Expand Down Expand Up @@ -100,7 +104,7 @@ mod imp {

unsafe fn really_init(argc: isize, argv: *const *const u8) {
// These don't need to be ordered with each other or other stores,
// because they only hold the unmodified system-provide argv/argc.
// because they only hold the unmodified system-provided argv/argc.
ARGC.store(argc, Ordering::Relaxed);
ARGV.store(argv as *mut _, Ordering::Relaxed);
}
Expand Down
6 changes: 4 additions & 2 deletions std/src/sys/pal/sgx/abi/tls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ const USIZE_BITS: usize = 64;
const TLS_KEYS: usize = 128; // Same as POSIX minimum
const TLS_KEYS_BITSET_SIZE: usize = (TLS_KEYS + (USIZE_BITS - 1)) / USIZE_BITS;

// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_KEY_IN_USEE")]
static TLS_KEY_IN_USE: SyncBitset = SYNC_BITSET_INIT;
macro_rules! dup {
((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* ));
(() $($val:tt)*) => ([$($val),*])
}
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_DESTRUCTORE")]
static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) (AtomicUsize::new(0)));

unsafe extern "C" {
Expand Down
6 changes: 4 additions & 2 deletions std/src/sys/pal/sgx/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ pub fn current_exe() -> io::Result<PathBuf> {
unsupported()
}

// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os3ENVE")]
static ENV: AtomicUsize = AtomicUsize::new(0);
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os8ENV_INITE")]
static ENV_INIT: Once = Once::new();
type EnvStore = Mutex<HashMap<OsString, OsString>>;

Expand Down
3 changes: 2 additions & 1 deletion std/src/sys/pal/sgx/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ mod task_queue {
}
}

// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx6thread10TASK_QUEUEE")]
static TASK_QUEUE: Mutex<Vec<Task>> = Mutex::new(Vec::new());

pub(super) fn lock() -> MutexGuard<'static, Vec<Task>> {
Expand Down
6 changes: 5 additions & 1 deletion std/src/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ use crate::fmt;
///
/// Initialization is dynamically performed on the first call to a setter (e.g.
/// [`with`]) within a thread, and values that implement [`Drop`] get
/// destructed when a thread exits. Some caveats apply, which are explained below.
/// destructed when a thread exits. Some platform-specific caveats apply, which
/// are explained below.
/// Note that, should the destructor panics, the whole process will be [aborted].
///
/// A `LocalKey`'s initializer cannot recursively depend on itself. Using a
/// `LocalKey` in this way may cause panics, aborts or infinite recursion on
/// the first call to `with`.
///
/// [aborted]: crate::process::abort
///
/// # Single-thread Synchronization
///
/// Though there is no potential race with other threads, it is still possible to
Expand Down
5 changes: 3 additions & 2 deletions std/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ pub struct Instant(time::Instant);
/// println!("{}", elapsed.as_secs());
/// }
/// Err(e) => {
/// // an error occurred!
/// println!("Error: {e:?}");
/// // the system clock went backwards!
/// println!("Great Scott! {e:?}");
/// }
/// }
/// }
Expand Down Expand Up @@ -245,6 +245,7 @@ pub struct Instant(time::Instant);
/// > structure cannot represent the new point in time.
///
/// [`add`]: SystemTime::add
/// [`UNIX_EPOCH`]: SystemTime::UNIX_EPOCH
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[stable(feature = "time2", since = "1.8.0")]
pub struct SystemTime(time::SystemTime);
Expand Down