Rollup merge of #156492 - RalfJung:cfg-miri, r=SimonSapin

remove/update various cfg(miri)

I went over all `cfg(miri)` in `library/`. Most of the things I noticed have become separate PRs; these here are the few remaining scattered little fixes in various places.
This commit is contained in:
Jonathan Brouwer
2026-05-18 03:19:44 +02:00
committed by GitHub
9 changed files with 9 additions and 13 deletions
+1
View File
@@ -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 };
-2
View File
@@ -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();
}
+1 -1
View File
@@ -1090,7 +1090,7 @@ pub fn metadata(&self) -> io::Result<FileAttr> {
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)
+1 -3
View File
@@ -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>,
+1 -1
View File
@@ -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| {
+1 -3
View File
@@ -78,7 +78,7 @@ unsafe fn sanitize_standard_fds() {
// 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",
@@ -125,8 +125,6 @@ unsafe fn sanitize_standard_fds() {
// 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",
+2 -2
View File
@@ -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)
@@ -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"),
}
+1
View File
@@ -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};
+1 -1
View File
@@ -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