Debian Codegraph @

debian/rust-vendor/rstest_macros/build.rs

raw
1 use rustc_version::{version, version_meta, Channel};
2
3 fn allow_features() -> Option<Vec<String>> {
4 std::env::var("CARGO_ENCODED_RUSTFLAGS").ok().map(|args| {
5 args.split('\u{001f}')
6 .filter(|arg| arg.starts_with("-Zallow-features="))
7 .map(|arg| arg.split('=').nth(1).unwrap())
8 .flat_map(|features| features.split(','))
9 .map(|f| f.to_owned())
10 .collect()
11 })
12 }
13
14 fn can_enable_proc_macro_diagnostic() -> bool {
15 allow_features()
16 .map(|f| f.iter().any(|f| f == "proc_macro_diagnostic"))
17 .unwrap_or(true)
18 }
19
20 fn main() {
21 let ver = version().unwrap();
22 assert!(ver.major >= 1);
23
24 match version_meta().unwrap().channel {
25 Channel::Nightly | Channel::Dev if can_enable_proc_macro_diagnostic() => {
26 println!("cargo:rustc-cfg=use_proc_macro_diagnostic");
27 }
28 _ => {}
29 }
30 }