Skip to content

Commit 6d740aa

Browse files
committed
Make -Z terminal-width opt-in.
This commit modifies the parsing of `-Z terminal-width` so that it can optionally take a value and only uses `accurate_err_width` when the user does not provide a value - therefore making the emission of `-Z terminal-width` opt-in. Signed-off-by: David Wood <[email protected]>
1 parent c46b9a7 commit 6d740aa

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,11 +720,18 @@ fn add_error_format_and_color(
720720
cmd.arg(json);
721721

722722
if nightly_features_allowed() {
723-
if let (Some(width), _) | (_, Some(width)) = (
724-
cx.bcx.config.cli_unstable().terminal_width,
725-
cx.bcx.config.shell().accurate_err_width(),
726-
) {
727-
cmd.arg(format!("-Zterminal-width={}", width));
723+
let config = cx.bcx.config;
724+
match (config.cli_unstable().terminal_width, config.shell().accurate_err_width()) {
725+
// Terminal width explicitly provided - only useful for testing.
726+
(Some(Some(width)), _) => {
727+
cmd.arg(format!("-Zterminal-width={}", width));
728+
}
729+
// Terminal width was not explicitly provided but flag was provided - common case.
730+
(Some(None), Some(width)) => {
731+
cmd.arg(format!("-Zterminal-width={}", width));
732+
}
733+
// User didn't opt-in.
734+
_ => (),
728735
}
729736
}
730737

src/cargo/core/features.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ pub struct CliUnstable {
357357
pub separate_nightlies: bool,
358358
pub multitarget: bool,
359359
pub rustdoc_map: bool,
360-
pub terminal_width: Option<usize>,
360+
pub terminal_width: Option<Option<usize>>,
361361
}
362362

363363
impl CliUnstable {
@@ -448,7 +448,7 @@ impl CliUnstable {
448448
"separate-nightlies" => self.separate_nightlies = parse_empty(k, v)?,
449449
"multitarget" => self.multitarget = parse_empty(k, v)?,
450450
"rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?,
451-
"terminal-width" => self.terminal_width = parse_usize_opt(v)?,
451+
"terminal-width" => self.terminal_width = Some(parse_usize_opt(v)?),
452452
_ => bail!("unknown `-Z` flag specified: {}", k),
453453
}
454454

0 commit comments

Comments
 (0)