72
72
#![ doc( cfg_hide(
73
73
not( test) ,
74
74
any( not( feature = "miri-test-libstd" ) , test, doctest) ,
75
+ all( feature = "miri-test" , not( any( test, doctest) ) ) ,
76
+ not( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ,
75
77
no_fp_fmt_parse,
76
78
target_pointer_width = "16" ,
77
79
target_pointer_width = "32" ,
282
284
#![ feature( wasm_target_feature) ]
283
285
// tidy-alphabetical-end
284
286
287
+ // We want to be able to `cargo miri test` this crate, but that's tricky:
288
+ // This will build the crate itself again, so now we have two `core` crates, one in the sysroot and
289
+ // one built as dependency of the test crate. That leads to duplicate lang item errors. `./x.py test
290
+ // library` avoids this by making the sysroot exactly the crates that `cargo build` produces, but
291
+ // Miri builds the sysroot itself so that does not work.
292
+ // Instead, we use the `miri-test` feature to indicate that we're running `cargo miri test`, and
293
+ // with that feature we turn this crate into a re-export of the sysroot crate. We only do this when
294
+ // building the crate that will become a dependency, not when doing the actual (doc)test build.
295
+ #[ cfg( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ]
296
+ extern crate core as realcore;
297
+ #[ cfg( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ]
298
+ #[ stable( feature = "miri_test" , since = "1.0.0" ) ]
299
+ pub use realcore:: * ;
300
+
301
+ // Otherwise, we build the crate as usual. Everything that follows should have
302
+ // `#[cfg(not(all(feature = "miri-test", not(any(test, doctest)))))]`. To avoid having to repeat the
303
+ // same `cfg` so many times, we `include!("lib_.rs")` with the main crate contents, and `cfg` the
304
+ // `include!`. However, some macro-related things can't be behind the `include!` so we have to
305
+ // repeat the `cfg` for them.
306
+
285
307
// allow using `core::` in intra-doc links
308
+ #[ cfg( not( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ) ]
286
309
#[ allow( unused_extern_crates) ]
287
310
extern crate self as core;
288
311
312
+ #[ cfg( not( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ) ]
289
313
#[ prelude_import]
290
314
#[ allow( unused) ]
291
315
use prelude:: rust_2021:: * ;
292
316
293
317
#[ cfg( not( test) ) ] // See #65860
318
+ #[ cfg( not( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ) ]
294
319
#[ macro_use]
295
320
mod macros;
296
321
297
- // We don't export this through #[macro_export] for now, to avoid breakage.
298
- // See https://github.com/rust-lang/rust/issues/82913
299
- #[ cfg( not( test) ) ]
300
- #[ unstable( feature = "assert_matches" , issue = "82775" ) ]
301
- /// Unstable module containing the unstable `assert_matches` macro.
302
- pub mod assert_matches {
303
- #[ unstable( feature = "assert_matches" , issue = "82775" ) ]
304
- pub use crate :: macros:: { assert_matches, debug_assert_matches} ;
305
- }
306
-
307
- #[ unstable( feature = "cfg_match" , issue = "115585" ) ]
308
- pub use crate :: macros:: cfg_match;
309
-
310
- #[ macro_use]
311
- mod internal_macros;
312
-
313
- #[ path = "num/shells/int_macros.rs" ]
314
- #[ macro_use]
315
- mod int_macros;
316
-
317
- #[ rustc_diagnostic_item = "i128_legacy_mod" ]
318
- #[ path = "num/shells/i128.rs" ]
319
- pub mod i128;
320
- #[ rustc_diagnostic_item = "i16_legacy_mod" ]
321
- #[ path = "num/shells/i16.rs" ]
322
- pub mod i16;
323
- #[ rustc_diagnostic_item = "i32_legacy_mod" ]
324
- #[ path = "num/shells/i32.rs" ]
325
- pub mod i32;
326
- #[ rustc_diagnostic_item = "i64_legacy_mod" ]
327
- #[ path = "num/shells/i64.rs" ]
328
- pub mod i64;
329
- #[ rustc_diagnostic_item = "i8_legacy_mod" ]
330
- #[ path = "num/shells/i8.rs" ]
331
- pub mod i8;
332
- #[ rustc_diagnostic_item = "isize_legacy_mod" ]
333
- #[ path = "num/shells/isize.rs" ]
334
- pub mod isize;
335
-
336
- #[ rustc_diagnostic_item = "u128_legacy_mod" ]
337
- #[ path = "num/shells/u128.rs" ]
338
- pub mod u128;
339
- #[ rustc_diagnostic_item = "u16_legacy_mod" ]
340
- #[ path = "num/shells/u16.rs" ]
341
- pub mod u16;
342
- #[ rustc_diagnostic_item = "u32_legacy_mod" ]
343
- #[ path = "num/shells/u32.rs" ]
344
- pub mod u32;
345
- #[ rustc_diagnostic_item = "u64_legacy_mod" ]
346
- #[ path = "num/shells/u64.rs" ]
347
- pub mod u64;
348
- #[ rustc_diagnostic_item = "u8_legacy_mod" ]
349
- #[ path = "num/shells/u8.rs" ]
350
- pub mod u8;
351
- #[ rustc_diagnostic_item = "usize_legacy_mod" ]
352
- #[ path = "num/shells/usize.rs" ]
353
- pub mod usize;
354
-
355
- #[ path = "num/f32.rs" ]
356
- pub mod f32;
357
- #[ path = "num/f64.rs" ]
358
- pub mod f64;
359
-
360
- #[ macro_use]
361
- pub mod num;
362
-
363
322
/* The core prelude, not as all-encompassing as the std prelude */
364
-
323
+ # [ cfg ( not ( all ( feature = "miri-test" , not ( any ( test , doctest ) ) ) ) ) ]
365
324
pub mod prelude;
366
325
367
- /* Core modules for ownership management */
368
-
369
- pub mod hint;
370
- pub mod intrinsics;
371
- pub mod mem;
372
- pub mod ptr;
373
- mod ub_checks;
374
-
375
- /* Core language traits */
376
-
377
- pub mod borrow;
378
- pub mod clone;
379
- pub mod cmp;
380
- pub mod convert;
381
- pub mod default;
382
- pub mod error;
383
- pub mod marker;
384
- pub mod ops;
385
-
386
- /* Core types and methods on primitives */
387
-
388
- pub mod any;
389
- pub mod array;
390
- pub mod ascii;
391
- pub mod asserting;
392
- #[ unstable( feature = "async_iterator" , issue = "79024" ) ]
393
- pub mod async_iter;
394
- pub mod cell;
395
- pub mod char;
396
- pub mod ffi;
397
- #[ unstable( feature = "core_io_borrowed_buf" , issue = "117693" ) ]
398
- pub mod io;
399
- pub mod iter;
400
- pub mod net;
401
- pub mod option;
402
- pub mod panic;
403
- pub mod panicking;
404
- pub mod pin;
405
- pub mod result;
406
- pub mod sync;
407
-
408
- pub mod fmt;
409
- pub mod hash;
410
- pub mod slice;
411
- pub mod str;
412
- pub mod time;
413
-
414
- pub mod unicode;
415
-
416
- /* Async */
417
- pub mod future;
418
- pub mod task;
419
-
420
- /* Heap memory allocator trait */
421
- #[ allow( missing_docs) ]
422
- pub mod alloc;
423
-
424
- // note: does not need to be public
425
- mod bool;
426
- mod escape;
427
- mod tuple;
428
- mod unit;
429
-
430
- #[ stable( feature = "core_primitive" , since = "1.43.0" ) ]
431
- pub mod primitive;
432
-
433
326
// Pull in the `core_arch` crate directly into core. The contents of
434
327
// `core_arch` are in a different repository: rust-lang/stdarch.
435
328
//
436
329
// `core_arch` depends on core, but the contents of this module are
437
330
// set up in such a way that directly pulling it here works such that the
438
331
// crate uses the this crate as its core.
332
+ #[ cfg( not( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ) ]
439
333
#[ path = "../../stdarch/crates/core_arch/src/mod.rs" ]
440
334
#[ allow(
441
335
missing_docs,
@@ -449,27 +343,5 @@ pub mod primitive;
449
343
#[ allow( rustdoc:: bare_urls) ]
450
344
mod core_arch;
451
345
452
- #[ stable( feature = "simd_arch" , since = "1.27.0" ) ]
453
- pub mod arch;
454
-
455
- // Pull in the `core_simd` crate directly into core. The contents of
456
- // `core_simd` are in a different repository: rust-lang/portable-simd.
457
- //
458
- // `core_simd` depends on core, but the contents of this module are
459
- // set up in such a way that directly pulling it here works such that the
460
- // crate uses this crate as its core.
461
- #[ path = "../../portable-simd/crates/core_simd/src/mod.rs" ]
462
- #[ allow( missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn) ]
463
- #[ allow( rustdoc:: bare_urls) ]
464
- #[ unstable( feature = "portable_simd" , issue = "86656" ) ]
465
- mod core_simd;
466
-
467
- #[ unstable( feature = "portable_simd" , issue = "86656" ) ]
468
- pub mod simd {
469
- #![ doc = include_str ! ( "../../portable-simd/crates/core_simd/src/core_simd_docs.md" ) ]
470
-
471
- #[ unstable( feature = "portable_simd" , issue = "86656" ) ]
472
- pub use crate :: core_simd:: simd:: * ;
473
- }
474
-
475
- include ! ( "primitive_docs.rs" ) ;
346
+ #[ cfg( not( all( feature = "miri-test" , not( any( test, doctest) ) ) ) ) ]
347
+ include ! ( "lib_.rs" ) ;
0 commit comments