trybuild_internals_api/rustflags.rs
1use std::env;
2
3const IGNORED_LINTS: &[&str] = &["dead_code"];
4
5pub fn toml() -> toml::Value {
6 let mut rustflags = vec!["--cfg", "trybuild", "--verbose"];
7
8 for &lint in IGNORED_LINTS {
9 rustflags.push("-A");
10 rustflags.push(lint);
11 }
12
13 if let Some(flags) = env::var_os("RUSTFLAGS") {
14 // TODO: could parse this properly and allowlist or blocklist certain
15 // flags. This is good enough to at least support cargo-llvm-cov.
16 if flags.to_string_lossy().contains("-C instrument-coverage") {
17 rustflags.extend(["-C", "instrument-coverage"]);
18 }
19 }
20
21 toml::Value::try_from(rustflags).unwrap()
22}