Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ fn raw_cargo() -> Command {
}

fn cargo(project: &Project) -> Command {
cargo_with_rustflags(project, &[])
}

fn cargo_with_rustflags(project: &Project, extra_rustflags: &[&'static str]) -> Command {
let mut cmd = raw_cargo();
cmd.current_dir(&project.dir);
cmd.envs(cargo_target_dir(project));
cmd.env_remove("RUSTFLAGS");
cmd.env("CARGO_INCREMENTAL", "0");
cmd.arg("--offline");

let rustflags = rustflags::toml();
let rustflags = rustflags::toml(extra_rustflags);
cmd.arg(format!("--config=build.rustflags={rustflags}"));
cmd.arg(format!("--config=target.{TARGET}.rustflags={rustflags}"));

Expand Down Expand Up @@ -122,7 +126,7 @@ pub(crate) fn build_test(project: &Project, name: &Name) -> Result<Output> {
.stderr(Stdio::null())
.status();

cargo(project)
cargo_with_rustflags(project, &["--diagnostic-width=140"])
.arg(if project.has_pass { "build" } else { "check" })
.args(target())
.arg("--bin")
Expand All @@ -145,7 +149,7 @@ pub(crate) fn build_all_tests(project: &Project) -> Result<Output> {
.stderr(Stdio::null())
.status();

cargo(project)
cargo_with_rustflags(project, &["--diagnostic-width=140"])
.arg(if project.has_pass { "build" } else { "check" })
.args(target())
.arg("--bins")
Expand Down
4 changes: 3 additions & 1 deletion src/rustflags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::env;

const IGNORED_LINTS: &[&str] = &["dead_code"];

pub(crate) fn toml() -> toml::Value {
pub(crate) fn toml(extra_rustflags: &[&'static str]) -> toml::Value {
let mut rustflags = vec!["--cfg", "trybuild", "--verbose"];

for &lint in IGNORED_LINTS {
Expand All @@ -18,5 +18,7 @@ pub(crate) fn toml() -> toml::Value {
}
}

rustflags.extend(extra_rustflags);

toml::Value::try_from(rustflags).unwrap()
}