From 2a265aeb9dd3d1a06cb6543d356a06611f147402 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Fri, 30 Jan 2026 12:56:17 +0000 Subject: [PATCH] use `--diagnostic-width` rustflag to fix ui test output width --- src/cargo.rs | 10 +++++++--- src/rustflags.rs | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cargo.rs b/src/cargo.rs index d473fcf..1a38655 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -37,6 +37,10 @@ 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)); @@ -44,7 +48,7 @@ fn cargo(project: &Project) -> Command { 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}")); @@ -122,7 +126,7 @@ pub(crate) fn build_test(project: &Project, name: &Name) -> Result { .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") @@ -145,7 +149,7 @@ pub(crate) fn build_all_tests(project: &Project) -> Result { .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") diff --git a/src/rustflags.rs b/src/rustflags.rs index 4bfd26c..0913b94 100644 --- a/src/rustflags.rs +++ b/src/rustflags.rs @@ -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 { @@ -18,5 +18,7 @@ pub(crate) fn toml() -> toml::Value { } } + rustflags.extend(extra_rustflags); + toml::Value::try_from(rustflags).unwrap() }