mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
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 <david@davidtw.co>
This commit is contained in:
parent
c46b9a70bd
commit
6d740aa2e6
@ -720,11 +720,18 @@ fn add_error_format_and_color(
|
||||
cmd.arg(json);
|
||||
|
||||
if nightly_features_allowed() {
|
||||
if let (Some(width), _) | (_, Some(width)) = (
|
||||
cx.bcx.config.cli_unstable().terminal_width,
|
||||
cx.bcx.config.shell().accurate_err_width(),
|
||||
) {
|
||||
cmd.arg(format!("-Zterminal-width={}", width));
|
||||
let config = cx.bcx.config;
|
||||
match (config.cli_unstable().terminal_width, config.shell().accurate_err_width()) {
|
||||
// Terminal width explicitly provided - only useful for testing.
|
||||
(Some(Some(width)), _) => {
|
||||
cmd.arg(format!("-Zterminal-width={}", width));
|
||||
}
|
||||
// Terminal width was not explicitly provided but flag was provided - common case.
|
||||
(Some(None), Some(width)) => {
|
||||
cmd.arg(format!("-Zterminal-width={}", width));
|
||||
}
|
||||
// User didn't opt-in.
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ pub struct CliUnstable {
|
||||
pub separate_nightlies: bool,
|
||||
pub multitarget: bool,
|
||||
pub rustdoc_map: bool,
|
||||
pub terminal_width: Option<usize>,
|
||||
pub terminal_width: Option<Option<usize>>,
|
||||
}
|
||||
|
||||
impl CliUnstable {
|
||||
@ -448,7 +448,7 @@ impl CliUnstable {
|
||||
"separate-nightlies" => self.separate_nightlies = parse_empty(k, v)?,
|
||||
"multitarget" => self.multitarget = parse_empty(k, v)?,
|
||||
"rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?,
|
||||
"terminal-width" => self.terminal_width = parse_usize_opt(v)?,
|
||||
"terminal-width" => self.terminal_width = Some(parse_usize_opt(v)?),
|
||||
_ => bail!("unknown `-Z` flag specified: {}", k),
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user