4 compile_error!("`miri` cfg should not be set in build script");
6 fn not_in_miri() -> i32 {
7 // Inline assembly definitely does not work in Miri.
10 std::arch::asm!("/* {} */", in(reg) &mut dummy);
17 // Cargo calls `miri --print=cfg` to populate the `CARGO_CFG_*` env vars.
18 // Make sure that the "miri" flag is set.
19 assert!(env::var_os("CARGO_CFG_MIRI").is_some(), "cargo failed to tell us about `--cfg miri`");
20 println!("cargo:rerun-if-changed=build.rs");
21 println!("cargo:rerun-if-env-changed=MIRITESTVAR");
22 println!("cargo:rustc-env=MIRITESTVAR=testval");
24 // Test that autocfg works. This invokes RUSTC.
25 let a = autocfg::new();
26 assert!(a.probe_sysroot_crate("std"));
27 assert!(!a.probe_sysroot_crate("doesnotexist"));
28 assert!(a.probe_rustc_version(1, 0));
29 assert!(!a.probe_rustc_version(2, 0));
30 assert!(a.probe_type("i128"));
31 assert!(!a.probe_type("doesnotexist"));
32 assert!(a.probe_trait("Send"));
33 assert!(!a.probe_trait("doesnotexist"));
34 assert!(a.probe_path("std::num"));
35 assert!(!a.probe_path("doesnotexist"));
36 assert!(a.probe_constant("i32::MAX"));
37 assert!(!a.probe_constant("doesnotexist"));
38 assert!(a.probe_expression("Box::new(0)"));
39 assert!(!a.probe_expression("doesnotexist"));