@@ -115,32 +115,6 @@ index 7ebc41588b3..cb3032719fa 100644
115
115
#[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc
116
116
fn test_try_reserve() {
117
117
let mut empty_bytes: HashMap<u8, u8> = HashMap::new();
118
- diff --git a/library/std/src/io/buffered/tests.rs b/library/std/src/io/buffered/tests.rs
119
- index fe45b132638..1e8cc59a455 100644
120
- --- a/library/std/src/io/buffered/tests.rs
121
- +++ b/library/std/src/io/buffered/tests.rs
122
- @@ -3,7 +3,7 @@
123
- use crate::mem::MaybeUninit;
124
- use crate::panic;
125
- use crate::sync::atomic::{AtomicUsize, Ordering};
126
- - use crate::thread;
127
- + use realstd::thread; // Miri needs the version in real `std`
128
-
129
- /// A dummy reader intended at testing short-reads propagation.
130
- pub struct ShortReader {
131
- diff --git a/library/std/src/io/stdio/tests.rs b/library/std/src/io/stdio/tests.rs
132
- index f89fd27ce6c..10a117c3dfa 100644
133
- --- a/library/std/src/io/stdio/tests.rs
134
- +++ b/library/std/src/io/stdio/tests.rs
135
- @@ -1,7 +1,7 @@
136
- use super::*;
137
- use crate::panic::{RefUnwindSafe, UnwindSafe};
138
- use crate::sync::mpsc::sync_channel;
139
- - use crate::thread;
140
- + use realstd::thread;
141
-
142
- #[test]
143
- fn stdout_unwind_safe() {
144
118
diff --git a/library/std/src/io/tests.rs b/library/std/src/io/tests.rs
145
119
index f357f33ec52..68a19eccc0e 100644
146
120
--- a/library/std/src/io/tests.rs
@@ -225,58 +199,10 @@ index 351cf698810..dd307022c6d 100644
225
199
fn bench_path_hashset_miss(b: &mut test::Bencher) {
226
200
let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/";
227
201
let paths: Vec<_> =
228
- diff --git a/library/std/src/sync/barrier/tests.rs b/library/std/src/sync/barrier/tests.rs
229
- index 834a3e75158..4af0f626de0 100644
230
- --- a/library/std/src/sync/barrier/tests.rs
231
- +++ b/library/std/src/sync/barrier/tests.rs
232
- @@ -1,6 +1,6 @@
233
- use crate::sync::mpsc::{channel, TryRecvError};
234
- use crate::sync::{Arc, Barrier};
235
- - use crate::thread;
236
- + use realstd::thread;
237
-
238
- #[test]
239
- #[cfg_attr(target_os = "emscripten", ignore)]
240
- diff --git a/library/std/src/sync/condvar/tests.rs b/library/std/src/sync/condvar/tests.rs
241
- index 24f467f0b03..f70c4f96240 100644
242
- --- a/library/std/src/sync/condvar/tests.rs
243
- +++ b/library/std/src/sync/condvar/tests.rs
244
- @@ -1,7 +1,7 @@
245
- use crate::sync::atomic::{AtomicBool, Ordering};
246
- use crate::sync::mpsc::channel;
247
- use crate::sync::{Arc, Condvar, Mutex};
248
- - use crate::thread;
249
- + use realstd::thread;
250
- use crate::time::Duration;
251
-
252
- #[test]
253
- diff --git a/library/std/src/sync/lazy_lock/tests.rs b/library/std/src/sync/lazy_lock/tests.rs
254
- index f11b66bfca5..a8c5ed684dd 100644
255
- --- a/library/std/src/sync/lazy_lock/tests.rs
256
- +++ b/library/std/src/sync/lazy_lock/tests.rs
257
- @@ -6,8 +6,8 @@
258
- Mutex,
259
- },
260
- sync::{LazyLock, OnceLock},
261
- - thread,
262
- };
263
- + use realstd::thread;
264
-
265
- fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
266
- thread::spawn(f).join().unwrap()
267
202
diff --git a/library/std/src/sync/mpsc/mpsc_queue/tests.rs b/library/std/src/sync/mpsc/mpsc_queue/tests.rs
268
- index 9f4f31ed051..1095d656c47 100644
203
+ index 9f4f31ed051..34b2a9a98ac 100644
269
204
--- a/library/std/src/sync/mpsc/mpsc_queue/tests.rs
270
205
+++ b/library/std/src/sync/mpsc/mpsc_queue/tests.rs
271
- @@ -1,7 +1,7 @@
272
- use super::{Data, Empty, Inconsistent, Queue};
273
- use crate::sync::mpsc::channel;
274
- use crate::sync::Arc;
275
- - use crate::thread;
276
- + use realstd::thread; // Miri needs the version in real `std`
277
-
278
- #[test]
279
- fn test_full() {
280
206
@@ -13,7 +13,7 @@ fn test_full() {
281
207
#[test]
282
208
fn test() {
@@ -287,18 +213,9 @@ index 9f4f31ed051..1095d656c47 100644
287
213
match q.pop() {
288
214
Empty => {}
289
215
diff --git a/library/std/src/sync/mpsc/spsc_queue/tests.rs b/library/std/src/sync/mpsc/spsc_queue/tests.rs
290
- index 467ef3dbdcb..7d0146b74cb 100644
216
+ index 467ef3dbdcb..eb6d5c2cf66 100644
291
217
--- a/library/std/src/sync/mpsc/spsc_queue/tests.rs
292
218
+++ b/library/std/src/sync/mpsc/spsc_queue/tests.rs
293
- @@ -1,7 +1,7 @@
294
- use super::Queue;
295
- use crate::sync::mpsc::channel;
296
- use crate::sync::Arc;
297
- - use crate::thread;
298
- + use realstd::thread; // Miri needs the version in real `std`
299
-
300
- #[test]
301
- fn smoke() {
302
219
@@ -77,12 +77,13 @@ fn stress() {
303
220
}
304
221
@@ -324,18 +241,9 @@ index 467ef3dbdcb..7d0146b74cb 100644
324
241
}
325
242
rx.recv().unwrap();
326
243
diff --git a/library/std/src/sync/mpsc/sync_tests.rs b/library/std/src/sync/mpsc/sync_tests.rs
327
- index e58649bab6e..49ccb60a5c6 100644
244
+ index e58649bab6e..63c79436974 100644
328
245
--- a/library/std/src/sync/mpsc/sync_tests.rs
329
246
+++ b/library/std/src/sync/mpsc/sync_tests.rs
330
- @@ -1,7 +1,7 @@
331
- use super::*;
332
- use crate::env;
333
- - use crate::thread;
334
- use crate::time::Duration;
335
- + use realstd::thread; // Miri needs the version in real `std`
336
-
337
- pub fn stress_factor() -> usize {
338
- match env::var("RUST_TEST_STRESS") {
339
247
@@ -113,23 +113,25 @@ fn chan_gone_concurrent() {
340
248
341
249
#[test]
@@ -407,18 +315,9 @@ index e58649bab6e..49ccb60a5c6 100644
407
315
}
408
316
}
409
317
diff --git a/library/std/src/sync/mpsc/tests.rs b/library/std/src/sync/mpsc/tests.rs
410
- index 4deb3e59615..699f14512cb 100644
318
+ index 4deb3e59615..f6d0796f604 100644
411
319
--- a/library/std/src/sync/mpsc/tests.rs
412
320
+++ b/library/std/src/sync/mpsc/tests.rs
413
- @@ -1,7 +1,7 @@
414
- use super::*;
415
- use crate::env;
416
- - use crate::thread;
417
- use crate::time::{Duration, Instant};
418
- + use realstd::thread; // Miri needs the version in real `std`
419
-
420
- pub fn stress_factor() -> usize {
421
- match env::var("RUST_TEST_STRESS") {
422
321
@@ -120,13 +120,14 @@ fn chan_gone_concurrent() {
423
322
424
323
#[test]
@@ -461,59 +360,10 @@ index 4deb3e59615..699f14512cb 100644
461
360
rx.recv().unwrap();
462
361
}
463
362
}
464
- diff --git a/library/std/src/sync/mutex/tests.rs b/library/std/src/sync/mutex/tests.rs
465
- index 93900566f11..e5cb77707c5 100644
466
- --- a/library/std/src/sync/mutex/tests.rs
467
- +++ b/library/std/src/sync/mutex/tests.rs
468
- @@ -1,7 +1,7 @@
469
- use crate::sync::atomic::{AtomicUsize, Ordering};
470
- use crate::sync::mpsc::channel;
471
- use crate::sync::{Arc, Condvar, Mutex};
472
- - use crate::thread;
473
- + use realstd::thread;
474
-
475
- struct Packet<T>(Arc<(Mutex<T>, Condvar)>);
476
-
477
- diff --git a/library/std/src/sync/once/tests.rs b/library/std/src/sync/once/tests.rs
478
- index 0c35597e11c..63e20f102f0 100644
479
- --- a/library/std/src/sync/once/tests.rs
480
- +++ b/library/std/src/sync/once/tests.rs
481
- @@ -1,7 +1,7 @@
482
- use super::Once;
483
- use crate::panic;
484
- use crate::sync::mpsc::channel;
485
- - use crate::thread;
486
- + use realstd::thread;
487
-
488
- #[test]
489
- fn smoke_once() {
490
- diff --git a/library/std/src/sync/once_lock/tests.rs b/library/std/src/sync/once_lock/tests.rs
491
- index 46695225b9f..d96ac1f005a 100644
492
- --- a/library/std/src/sync/once_lock/tests.rs
493
- +++ b/library/std/src/sync/once_lock/tests.rs
494
- @@ -5,8 +5,8 @@
495
- atomic::{AtomicUsize, Ordering::SeqCst},
496
- mpsc::channel,
497
- },
498
- - thread,
499
- };
500
- + use realstd::thread;
501
-
502
- fn spawn_and_wait<R: Send + 'static>(f: impl FnOnce() -> R + Send + 'static) -> R {
503
- thread::spawn(f).join().unwrap()
504
363
diff --git a/library/std/src/sync/rwlock/tests.rs b/library/std/src/sync/rwlock/tests.rs
505
- index 08255c985f5..2d855a6027b 100644
364
+ index 08255c985f5..b5b3ad9898e 100644
506
365
--- a/library/std/src/sync/rwlock/tests.rs
507
366
+++ b/library/std/src/sync/rwlock/tests.rs
508
- @@ -1,7 +1,7 @@
509
- use crate::sync::atomic::{AtomicUsize, Ordering};
510
- use crate::sync::mpsc::channel;
511
- use crate::sync::{Arc, RwLock, RwLockReadGuard, TryLockError};
512
- - use crate::thread;
513
- + use realstd::thread;
514
- use rand::{self, Rng};
515
-
516
- #[derive(Eq, PartialEq, Debug)]
517
367
@@ -19,7 +19,7 @@ fn smoke() {
518
368
#[test]
519
369
fn frob() {
@@ -523,78 +373,31 @@ index 08255c985f5..2d855a6027b 100644
523
373
524
374
let r = Arc::new(RwLock::new(()));
525
375
526
- diff --git a/library/std/src/sys_common/remutex/tests.rs b/library/std/src/sys_common/remutex/tests.rs
527
- index 64873b850d3..489bd91fec0 100644
528
- --- a/library/std/src/sys_common/remutex/tests.rs
529
- +++ b/library/std/src/sys_common/remutex/tests.rs
530
- @@ -3,7 +3,7 @@
531
- use crate::pin::Pin;
532
- use crate::sync::Arc;
533
- use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
534
- - use crate::thread;
535
- + use realstd::thread;
536
-
537
- #[test]
538
- fn smoke() {
539
- diff --git a/library/std/src/thread/local/tests.rs b/library/std/src/thread/local/tests.rs
540
- index 1df1ca758c0..51d77514193 100644
541
- --- a/library/std/src/thread/local/tests.rs
542
- +++ b/library/std/src/thread/local/tests.rs
543
- @@ -1,8 +1,9 @@
544
- use crate::cell::{Cell, UnsafeCell};
545
- use crate::sync::atomic::{AtomicU8, Ordering};
546
- use crate::sync::mpsc::{channel, Sender};
547
- - use crate::thread::{self, LocalKey};
548
- + use crate::thread::LocalKey;
549
- use crate::thread_local;
550
- + use realstd::thread; // Miri needs the version in real `std`
551
-
552
- struct Foo(Sender<()>);
553
-
554
- diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs
555
- index 44c8a50fd86..c88760942f0 100644
556
- --- a/library/std/src/thread/mod.rs
557
- +++ b/library/std/src/thread/mod.rs
558
- @@ -204,8 +204,18 @@
559
-
560
- #[unstable(feature = "libstd_thread_internals", issue = "none")]
561
- #[cfg(target_thread_local)]
562
- + #[cfg(not(test))]
563
- #[doc(hidden)]
564
- pub use self::local::fast::Key as __FastLocalKeyInner;
565
- + #[unstable(feature = "libstd_thread_internals", issue = "none")]
566
- + #[cfg(target_thread_local)]
567
- + #[cfg(test)] // when building for tests, use real std's key
568
- + pub use realstd::thread::__FastLocalKeyInner;
569
- + #[unstable(feature = "libstd_thread_internals", issue = "none")]
570
- + #[cfg(target_thread_local)]
571
- + #[cfg(test)]
572
- + pub use self::local::fast::Key as __FastLocalKeyInnerUnused; // we import this anyway to silence 'unused' warnings
573
- +
574
- #[unstable(feature = "libstd_thread_internals", issue = "none")]
575
- #[doc(hidden)]
576
- pub use self::local::os::Key as __OsLocalKeyInner;
376
+ diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs
377
+ index b5cc8038ca4..1261ed0cd89 100644
378
+ --- a/library/std/src/sys/unix/fs.rs
379
+ +++ b/library/std/src/sys/unix/fs.rs
380
+ @@ -825,6 +825,7 @@ fn name_bytes(&self) -> &[u8] {
381
+ target_os = "fuchsia",
382
+ target_os = "redox"
383
+ )))]
384
+ + #[cfg_attr(miri, allow(unused))]
385
+ fn name_cstr(&self) -> &CStr {
386
+ unsafe { CStr::from_ptr(self.entry.d_name.as_ptr()) }
387
+ }
388
+ @@ -836,6 +837,7 @@ fn name_cstr(&self) -> &CStr {
389
+ target_os = "fuchsia",
390
+ target_os = "redox"
391
+ ))]
392
+ + #[cfg_attr(miri, allow(unused))]
393
+ fn name_cstr(&self) -> &CStr {
394
+ &self.name
395
+ }
577
396
diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs
578
- index ec68b529188..c36fdb38e36 100644
397
+ index ec68b529188..130e47c8d44 100644
579
398
--- a/library/std/src/thread/tests.rs
580
399
+++ b/library/std/src/thread/tests.rs
581
- @@ -1,4 +1,3 @@
582
- - use super::Builder;
583
- use crate::any::Any;
584
- use crate::mem;
585
- use crate::panic::panic_any;
586
- @@ -8,9 +7,9 @@
587
- mpsc::{channel, Sender},
588
- Arc, Barrier,
589
- };
590
- - use crate::thread::{self, Scope, ThreadId};
591
- use crate::time::Duration;
592
- use crate::time::Instant;
593
- + use realstd::thread::{self, Builder, Scope, ThreadId}; // Miri needs the version in real `std`
594
-
595
- // !!! These tests are dangerous. If something is buggy, they will hang, !!!
596
- // !!! instead of exiting cleanly. This might wedge the buildbots. !!!
597
- @@ -329,3 +328,22 @@ fn foo(x: &u8) {
400
+ @@ -329,3 +329,22 @@ fn foo(x: &u8) {
598
401
let x = 42_u8;
599
402
foo(&x);
600
403
}
@@ -618,28 +421,16 @@ index ec68b529188..c36fdb38e36 100644
618
421
+ }
619
422
+ }
620
423
diff --git a/library/std/src/time/tests.rs b/library/std/src/time/tests.rs
621
- index d710a574465..aac077d2513 100644
424
+ index d710a574465..6229556c85f 100644
622
425
--- a/library/std/src/time/tests.rs
623
426
+++ b/library/std/src/time/tests.rs
624
- @@ -29,9 +29,10 @@ fn instant_monotonic() {
625
- fn instant_monotonic_concurrent() -> crate::thread::Result<()> {
626
- let threads: Vec<_> = (0..8)
427
+ @@ -31,7 +31,8 @@ fn instant_monotonic_concurrent() -> crate::thread::Result<()> {
627
428
.map(|_| {
628
- - crate::thread::spawn(|| {
629
- + realstd::thread::spawn(|| {
429
+ crate::thread::spawn(|| {
630
430
let mut old = Instant::now();
631
431
- for _ in 0..5_000_000 {
632
432
+ let count = if cfg!(miri) { 1_000 } else { 5_000_000 };
633
433
+ for _ in 0..count {
634
434
let new = Instant::now();
635
435
assert!(new >= old);
636
436
old = new;
637
- @@ -205,7 +206,7 @@ fn $bench_name(b: &mut Bencher) -> crate::thread::Result<()> {
638
- let threads: Vec<_> = (0..$thread_count)
639
- .map(|_| {
640
- let flag = Arc::clone(&running);
641
- - crate::thread::spawn(move || {
642
- + realstd::thread::spawn(move || {
643
- while flag.load(Ordering::Relaxed) {
644
- black_box(Instant::now());
645
- }
0 commit comments