Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
670fe10
doc(core::cmp::Eq): fix definition of consistency
numero-744 Apr 14, 2026
3be45b3
Fix cross-compiling macos-deployment-target-warning test
madsmtm Apr 27, 2026
8714345
Include vendored sources in the rust-src component
bjorn3 May 5, 2026
d8502aa
implement into_array for Vec<T>
bend-n May 6, 2026
d6cd152
Update iterator.rs
justinyaodu May 12, 2026
4625f8c
remove/update various cfg(miri)
RalfJung May 12, 2026
57a1291
Fix paths in generated .cargo/config.toml for vendoring
bjorn3 May 11, 2026
181845e
std: replace "safe" with "sound" in safety documentation
xtqqczze May 14, 2026
871a2ae
c ffi document fixes for c_short.md
lygstate Sep 21, 2025
88eb204
Fix compilation for espidf target by conditionally disabling process …
FelixLttks May 16, 2026
2677965
Change division to multiplication in floating-point midpoint
oscargus May 16, 2026
43436c9
Fix typo in `format_into` docs: signed -> unsigned
joshtriplett May 17, 2026
7442ae7
add red test
qaijuang May 17, 2026
7aa831f
preserve spans when hiding do_not_recommend impls
qaijuang May 17, 2026
76955f4
change `other uses of const` to `raw pointers`
Cheese-Space May 17, 2026
c30d903
Rollup merge of #156196 - bjorn3:vendor_stdlib, r=Mark-Simulacrum
JonathanBrouwer May 18, 2026
1f9aa27
Rollup merge of #155870 - madsmtm:fix-test-arm64e, r=chenyukang
JonathanBrouwer May 18, 2026
05e9620
Rollup merge of #156492 - RalfJung:cfg-miri, r=SimonSapin
JonathanBrouwer May 18, 2026
04d8b94
Rollup merge of #156676 - qaijuang:diagnostics-do-not-recommend-span,…
JonathanBrouwer May 18, 2026
5908149
Rollup merge of #155313 - numero-744:patch-1, r=SimonSapin
JonathanBrouwer May 18, 2026
acd0707
Rollup merge of #156234 - bend-n:into_array_for_vec_t_via_boxed_array…
JonathanBrouwer May 18, 2026
8ebe7e8
Rollup merge of #156488 - justinyaodu:patch-2, r=SimonSapin
JonathanBrouwer May 18, 2026
a99602d
Rollup merge of #156572 - xtqqczze:sound-env, r=SimonSapin
JonathanBrouwer May 18, 2026
a62fb3b
Rollup merge of #156624 - lygstate:c_ffi_docs_fixes, r=SimonSapin
JonathanBrouwer May 18, 2026
0104cf0
Rollup merge of #156638 - FelixLttks:fix-espidf-sigkill, r=SimonSapin
JonathanBrouwer May 18, 2026
868afcb
Rollup merge of #156647 - oscargus:fasterfloatmidpoint, r=SimonSapin
JonathanBrouwer May 18, 2026
b295a02
Rollup merge of #156668 - joshtriplett:format-into-typo, r=SimonSapin
JonathanBrouwer May 18, 2026
3810819
Rollup merge of #156677 - Cheese-Space:main, r=SimonSapin
JonathanBrouwer May 18, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -816,13 +816,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
pub(super) fn apply_do_not_recommend(
&self,
obligation: &mut PredicateObligation<'tcx>,
root_obligation: &PredicateObligation<'tcx>,
) -> bool {
let mut base_cause = obligation.cause.code().clone();
let mut applied_do_not_recommend = false;
loop {
if let ObligationCauseCode::ImplDerived(ref c) = base_cause {
if self.tcx.do_not_recommend_impl(c.impl_or_alias_def_id) {
let code = (*c.derived.parent_code).clone();
// Keep more precise spans that still point within the parent obligation,
// but do not let hidden impl details move the span outside of it.
if code == *root_obligation.cause.code()
&& !root_obligation.cause.span.contains(obligation.cause.span)
{
obligation.cause.span = root_obligation.cause.span;
}
obligation.cause.map_code(|_| code);
obligation.predicate = c.derived.parent_trait_pred.upcast(self.tcx);
applied_do_not_recommend = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
error.code,
FulfillmentErrorCode::Select(crate::traits::SelectionError::Unimplemented)
| FulfillmentErrorCode::Project(_)
) && self.apply_do_not_recommend(&mut error.obligation)
) && self.apply_do_not_recommend(&mut error.obligation, &error.root_obligation)
{
error.code = FulfillmentErrorCode::Select(SelectionError::Unimplemented);
}
Expand Down
21 changes: 21 additions & 0 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,27 @@ impl<T, A: Allocator> Vec<T, A> {
}
}

/// Converts the Vec into a boxed array. This conversion will discard any spare capacity, if there is any, see [`Vec::shrink_to_fit`].
/// If you merely wish for a reference to an array, use [`as_array`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_array).
///
/// If `N` is not exactly equal to [`Vec::len`], then this method returns `None`.
///
/// # Examples
///
/// ```
/// #![feature(alloc_slice_into_array)]
/// let vec: Vec<i32> = vec![1, 2, 3];
/// let box_array: Box<[i32; 3]> = vec.clone().into_array().unwrap();
/// let not_enough_elements: Result<Box<[i32; 4]>, Vec<i32>> = vec.into_array::<4>();
/// assert_eq!(not_enough_elements, Err(vec![1, 2, 3]));
/// ```
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "alloc_slice_into_array", issue = "148082")]
#[must_use]
pub fn into_array<const N: usize>(self) -> Result<Box<[T; N], A>, Self> {
if self.len() == N { Ok(self.into_boxed_slice().into_array().unwrap()) } else { Err(self) }
}

/// Shortens the vector, keeping the first `len` elements and dropping
/// the rest.
///
Expand Down
1 change: 1 addition & 0 deletions library/alloctests/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,7 @@ fn utf8_char_counts() {
.flat_map(|n| n - spread..=n + spread)
.collect::<Vec<usize>>();
if cfg!(not(miri)) {
// Miri is too slow
reps.extend([1024, 1 << 16].iter().copied().flat_map(|n| n - spread..=n + spread));
}
let counts = if cfg!(miri) { 0..1 } else { 0..8 };
Expand Down
2 changes: 0 additions & 2 deletions library/alloctests/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,6 @@ fn test_weak_count_locked() {
while !a2.load(SeqCst) {
let n = Arc::weak_count(&a2);
assert!(n < 2, "bad weak count: {}", n);
#[cfg(miri)] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
std::hint::spin_loop();
}
t.join().unwrap();
}
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ pub macro PartialEq($item:item) {
/// The primary difference to [`PartialEq`] is the additional requirement for reflexivity. A type
/// that implements [`PartialEq`] guarantees that for all `a`, `b` and `c`:
///
/// - symmetric: `a == b` implies `b == a` and `a != b` implies `!(a == b)`
/// - symmetric: `a == b` implies `b == a`
/// - transitive: `a == b` and `b == c` implies `a == c`
/// - consistent: `a != b` if and only if `!(a == b)`
///
/// `Eq`, which builds on top of [`PartialEq`] also implies:
///
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/ffi/c_short.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Equivalent to C's `signed short` (`short`) type.

This type will almost always be [`i16`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer with at least 16 bits; some systems may define it as `i32`, for example.

[`char`]: c_char
6 changes: 3 additions & 3 deletions library/core/src/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ macro_rules! impl_Display {
}

impl $Unsigned {
/// Allows users to write an integer (in signed decimal format) into a variable `buf` of
/// type [`NumBuffer`] that is passed by the caller by mutable reference.
/// Allows users to write an integer (in unsigned decimal format) into a variable `buf`
/// of type [`NumBuffer`] that is passed by the caller by mutable reference.
///
/// # Examples
///
Expand Down Expand Up @@ -738,7 +738,7 @@ impl u128 {
offset
}

/// Allows users to write an integer (in signed decimal format) into a variable `buf` of
/// Allows users to write an integer (in unsigned decimal format) into a variable `buf` of
/// type [`NumBuffer`] that is passed by the caller by mutable reference.
///
/// # Examples
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3674,7 +3674,7 @@ pub const trait Iterator {
Sum::sum(self)
}

/// Iterates over the entire iterator, multiplying all the elements
/// Iterates over the entire iterator, multiplying all the elements.
///
/// An empty iterator returns the one value of the type.
///
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,17 +977,17 @@ impl f128 {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
pub const fn midpoint(self, other: f128) -> f128 {
const HI: f128 = f128::MAX / 2.;
const HI: f128 = f128::MAX * 0.5;

let (a, b) = (self, other);
let abs_a = a.abs();
let abs_b = b.abs();

if abs_a <= HI && abs_b <= HI {
// Overflow is impossible
(a + b) / 2.
(a + b) * 0.5
} else {
(a / 2.) + (b / 2.)
(a * 0.5) + (b * 0.5)
}
}

Expand Down
6 changes: 3 additions & 3 deletions library/core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -973,17 +973,17 @@ impl f16 {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
pub const fn midpoint(self, other: f16) -> f16 {
const HI: f16 = f16::MAX / 2.;
const HI: f16 = f16::MAX * 0.5;

let (a, b) = (self, other);
let abs_a = a.abs();
let abs_b = b.abs();

if abs_a <= HI && abs_b <= HI {
// Overflow is impossible
(a + b) / 2.
(a + b) * 0.5
} else {
(a / 2.) + (b / 2.)
(a * 0.5) + (b * 0.5)
}
}

Expand Down
8 changes: 4 additions & 4 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,20 +1164,20 @@ impl f32 {
target_arch = "wasm32",
target_arch = "wasm64",
) => {
((self as f64 + other as f64) / 2.0) as f32
((self as f64 + other as f64) * 0.5) as f32
}
_ => {
const HI: f32 = f32::MAX / 2.;
const HI: f32 = f32::MAX * 0.5;

let (a, b) = (self, other);
let abs_a = a.abs();
let abs_b = b.abs();

if abs_a <= HI && abs_b <= HI {
// Overflow is impossible
(a + b) / 2.
(a + b) * 0.5
} else {
(a / 2.) + (b / 2.)
(a * 0.5) + (b * 0.5)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,17 +1150,17 @@ impl f64 {
#[must_use = "this returns the result of the operation, \
without modifying the original"]
pub const fn midpoint(self, other: f64) -> f64 {
const HI: f64 = f64::MAX / 2.;
const HI: f64 = f64::MAX * 0.5;

let (a, b) = (self, other);
let abs_a = a.abs();
let abs_b = b.abs();

if abs_a <= HI && abs_b <= HI {
// Overflow is impossible
(a + b) / 2.
(a + b) * 0.5
} else {
(a / 2.) + (b / 2.)
(a * 0.5) + (b * 0.5)
}
}

Expand Down
16 changes: 8 additions & 8 deletions library/std/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ impl Error for VarError {}
///
/// # Safety
///
/// This function is safe to call in a single-threaded program.
/// This function is sound to call in a single-threaded program.
///
/// This function is also always safe to call on Windows, in single-threaded
/// This function is also always sound to call on Windows, in single-threaded
/// and multi-threaded programs.
///
/// In multi-threaded programs on other operating systems, the only safe option is
/// In multi-threaded programs on other operating systems, the only sound option is
/// to not use `set_var` or `remove_var` at all.
///
/// The exact requirement is: you
Expand All @@ -322,7 +322,7 @@ impl Error for VarError {}
/// lookups from [`std::net::ToSocketAddrs`]. No stable guarantee is made about
/// which functions may read from the environment in future versions of a
/// library. All this makes it not practically possible for you to guarantee
/// that no other thread will read the environment, so the only safe option is
/// that no other thread will read the environment, so the only sound option is
/// to not use `set_var` or `remove_var` in multi-threaded programs at all.
///
/// Discussion of this unsafety on Unix may be found in:
Expand Down Expand Up @@ -366,12 +366,12 @@ pub unsafe fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
///
/// # Safety
///
/// This function is safe to call in a single-threaded program.
/// This function is sound to call in a single-threaded program.
///
/// This function is also always safe to call on Windows, in single-threaded
/// This function is also always sound to call on Windows, in single-threaded
/// and multi-threaded programs.
///
/// In multi-threaded programs on other operating systems, the only safe option is
/// In multi-threaded programs on other operating systems, the only sound option is
/// to not use `set_var` or `remove_var` at all.
///
/// The exact requirement is: you
Expand All @@ -385,7 +385,7 @@ pub unsafe fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
/// lookups from [`std::net::ToSocketAddrs`]. No stable guarantee is made about
/// which functions may read from the environment in future versions of a
/// library. All this makes it not practically possible for you to guarantee
/// that no other thread will read the environment, so the only safe option is
/// that no other thread will read the environment, so the only sound option is
/// to not use `set_var` or `remove_var` in multi-threaded programs at all.
///
/// Discussion of this unsafety on Unix may be found in:
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ mod break_keyword {}
///
/// Turning a `fn` into a `const fn` has no effect on run-time uses of that function.
///
/// ## Other uses of `const`
/// ## raw pointers
///
/// The `const` keyword is also used in raw pointers in combination with `mut`, as seen in `*const
/// T` and `*mut T`. More about `const` as used in raw pointers can be read at the Rust docs for the [pointer primitive].
Expand Down
9 changes: 9 additions & 0 deletions library/std/src/os/unix/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,18 @@ impl ChildExt for process::Child {
self.handle.send_process_group_signal(signal)
}

#[cfg(not(target_os = "espidf"))]
fn kill_process_group(&mut self) -> io::Result<()> {
self.handle.send_process_group_signal(libc::SIGKILL)
}

#[cfg(target_os = "espidf")]
fn kill_process_group(&mut self) -> io::Result<()> {
Err(io::Error::new(
io::ErrorKind::Unsupported,
"process groups are not supported on espidf",
))
}
}

#[stable(feature = "process_extensions", since = "1.2.0")]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/fs/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ impl DirEntry {
target_os = "illumos",
target_vendor = "apple",
)),
miri
miri // no dirfd on Miri
))]
pub fn metadata(&self) -> io::Result<FileAttr> {
run_path_with_cstr(&self.path(), &lstat)
Expand Down
4 changes: 1 addition & 3 deletions library/std/src/sys/pal/unix/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ pub fn page_size() -> usize {
///
/// [posix_confstr]:
/// https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html
//
// FIXME: Support `confstr` in Miri.
#[cfg(all(target_vendor = "apple", not(miri)))]
#[cfg(target_vendor = "apple")]
pub fn confstr(
key: crate::ffi::c_int,
size_hint: Option<usize>,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/unix/conf/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn test_parse_glibc_version() {
// Smoke check `confstr`, do it for several hint values, to ensure our resizing
// logic is correct.
#[test]
#[cfg(all(target_vendor = "apple", not(miri)))]
#[cfg(target_vendor = "apple")]
fn test_confstr() {
for key in [libc::_CS_DARWIN_USER_TEMP_DIR, libc::_CS_PATH] {
let value_nohint = super::confstr(key, None).unwrap_or_else(|e| {
Expand Down
4 changes: 1 addition & 3 deletions library/std/src/sys/pal/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {

// fast path with a single syscall for systems with poll()
#[cfg(not(any(
miri,
miri, // no `poll`
target_os = "emscripten",
target_os = "fuchsia",
target_os = "vxworks",
Expand Down Expand Up @@ -125,8 +125,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {

// fallback in case poll isn't available or limited by RLIMIT_NOFILE
#[cfg(not(any(
// The standard fds are always available in Miri.
miri,
target_os = "emscripten",
target_os = "fuchsia",
target_os = "vxworks",
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/paths/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
if !path.is_absolute() { getcwd().map(|cwd| cwd.join(path)) } else { Ok(path) }
}

#[cfg(all(target_vendor = "apple", not(miri)))]
#[cfg(target_vendor = "apple")]
fn darwin_temp_dir() -> PathBuf {
crate::sys::pal::conf::confstr(libc::_CS_DARWIN_USER_TEMP_DIR, Some(64))
.map(PathBuf::from)
Expand All @@ -407,7 +407,7 @@ fn darwin_temp_dir() -> PathBuf {
pub fn temp_dir() -> PathBuf {
crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
cfg_select! {
all(target_vendor = "apple", not(miri)) => darwin_temp_dir(),
target_vendor = "apple" => darwin_temp_dir(),
target_os = "android" => PathBuf::from("/data/local/tmp"),
_ => PathBuf::from("/tmp"),
}
Expand Down
1 change: 1 addition & 0 deletions library/std/tests/pipe_subprocess.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fn main() {
// No `Command` on Miri and emscripten
#[cfg(all(not(miri), any(unix, windows), not(target_os = "emscripten")))]
{
use std::io::{Read, pipe};
Expand Down
2 changes: 1 addition & 1 deletion library/std/tests/windows_unix_socket.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg(windows)]
#![cfg(not(miri))] // no socket support in Miri
#![cfg(not(miri))] // no Windows socket support in Miri
#![feature(windows_unix_domain_sockets)]
// Now only test windows_unix_domain_sockets feature
// in the future, will test both unix and windows uds
Expand Down
Loading
Loading