Debian Codegraph @

debian/rust-vendor/autocfg/tests/no_std.rs

raw
1 extern crate autocfg;
2
3 use std::env;
4
5 mod support;
6
7 /// Tests that we can control the use of `#![no_std]`.
8 #[test]
9 fn no_std() {
10 // Clear the CI `TARGET`, if any, so we're just dealing with the
11 // host target which always has `std` available.
12 env::remove_var("TARGET");
13
14 // Use the same path as this test binary.
15 let out = support::out_dir();
16
17 let mut ac = autocfg::AutoCfg::with_dir(out.as_ref()).unwrap();
18 assert!(!ac.no_std());
19 assert!(ac.probe_path("std::mem"));
20
21 // `#![no_std]` was stabilized in Rust 1.6
22 if ac.probe_rustc_version(1, 6) {
23 ac.set_no_std(true);
24 assert!(ac.no_std());
25 assert!(!ac.probe_path("std::mem"));
26 assert!(ac.probe_path("core::mem"));
27 }
28 }