diff --git a/Cargo.lock b/Cargo.lock index c0a7cc9b9d3..9dd43effcb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" [[package]] name = "anstyle-parse" diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 3ad396896eb..6807985278e 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -54,10 +54,9 @@ pub fn main(config: &mut LazyConfig) -> CliResult { .map(String::as_str) == Some("help") { - let header = style::HEADER.render(); - let literal = style::LITERAL.render(); - let placeholder = style::PLACEHOLDER.render(); - let reset = anstyle::Reset.render(); + let header = style::HEADER; + let literal = style::LITERAL; + let placeholder = style::PLACEHOLDER; let options = CliUnstable::help(); let max_length = options @@ -72,17 +71,17 @@ pub fn main(config: &mut LazyConfig) -> CliResult { .map(|(opt, help)| { let opt = opt.replace("_", "-"); let help = help.unwrap(); - format!(" {literal}-Z {opt: { assert!( @@ -146,21 +144,25 @@ Run with `{literal}cargo -Z{reset} {placeholder}[FLAG] [COMMAND]{reset}`", ); let summary = about.unwrap_or_default(); let summary = summary.lines().next().unwrap_or(&summary); // display only the first line - drop_println!(config, " {literal}{name:<20}{reset} {summary}"); + drop_println!(config, " {literal}{name:<20}{literal:#} {summary}"); } CommandInfo::External { path } => { if let Some(desc) = known_external_desc { - drop_println!(config, " {literal}{name:<20}{reset} {desc}"); + drop_println!(config, " {literal}{name:<20}{literal:#} {desc}"); } else if is_verbose { - drop_println!(config, " {literal}{name:<20}{reset} {}", path.display()); + drop_println!( + config, + " {literal}{name:<20}{literal:#} {}", + path.display() + ); } else { - drop_println!(config, " {literal}{name}{reset}"); + drop_println!(config, " {literal}{name}{literal:#}"); } } CommandInfo::Alias { target } => { drop_println!( config, - " {literal}{name:<20}{reset} alias: {}", + " {literal}{name:<20}{literal:#} alias: {}", target.iter().join(" ") ); } diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 3d446664f3d..5c47b1b1c8f 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -455,15 +455,13 @@ impl ShellOut { style: &Style, justified: bool, ) -> CargoResult<()> { - let style = style.render(); - let bold = (anstyle::Style::new() | anstyle::Effects::BOLD).render(); - let reset = anstyle::Reset.render(); + let bold = anstyle::Style::new() | anstyle::Effects::BOLD; let mut buffer = Vec::new(); if justified { - write!(&mut buffer, "{style}{status:>12}{reset}")?; + write!(&mut buffer, "{style}{status:>12}{style:#}")?; } else { - write!(&mut buffer, "{style}{status}{reset}{bold}:{reset}")?; + write!(&mut buffer, "{style}{status}{style:#}{bold}:{bold:#}")?; } match message { Some(message) => writeln!(buffer, " {message}")?, diff --git a/src/cargo/ops/cargo_add/mod.rs b/src/cargo/ops/cargo_add/mod.rs index 51ad938f371..be230e96a48 100644 --- a/src/cargo/ops/cargo_add/mod.rs +++ b/src/cargo/ops/cargo_add/mod.rs @@ -1009,9 +1009,8 @@ fn print_dep_table_msg(shell: &mut Shell, dep: &DependencyUI) -> CargoResult<()> } let stderr = shell.err(); - let good = style::GOOD.render(); - let error = style::ERROR.render(); - let reset = anstyle::Reset.render(); + let good = style::GOOD; + let error = style::ERROR; let (activated, deactivated) = dep.features(); if !activated.is_empty() || !deactivated.is_empty() { @@ -1026,7 +1025,7 @@ fn print_dep_table_msg(shell: &mut Shell, dep: &DependencyUI) -> CargoResult<()> if total_activated <= MAX_FEATURE_PRINTS { for feat in activated { - writeln!(stderr, "{prefix}{good}+{reset} {feat}")?; + writeln!(stderr, "{prefix}{good}+{good:#} {feat}")?; } } else { writeln!(stderr, "{prefix}{total_activated} activated features")?; @@ -1034,7 +1033,7 @@ fn print_dep_table_msg(shell: &mut Shell, dep: &DependencyUI) -> CargoResult<()> if total_activated + total_deactivated <= MAX_FEATURE_PRINTS { for feat in deactivated { - writeln!(stderr, "{prefix}{error}-{reset} {feat}")?; + writeln!(stderr, "{prefix}{error}-{error:#} {feat}")?; } } else { writeln!(stderr, "{prefix}{total_deactivated} deactivated features")?; diff --git a/src/cargo/ops/registry/search.rs b/src/cargo/ops/registry/search.rs index 0f464975406..6d26ba22f04 100644 --- a/src/cargo/ops/registry/search.rs +++ b/src/cargo/ops/registry/search.rs @@ -47,8 +47,7 @@ pub fn search( let mut shell = config.shell(); let stdout = shell.out(); - let good = style::GOOD.render(); - let reset = anstyle::Reset.render(); + let good = style::GOOD; for (name, description) in names.into_iter().zip(descriptions) { let line = match description { @@ -59,7 +58,7 @@ pub fn search( while let Some(fragment) = fragments.next() { let _ = write!(stdout, "{fragment}"); if fragments.peek().is_some() { - let _ = write!(stdout, "{good}{query}{reset}"); + let _ = write!(stdout, "{good}{query}{good:#}"); } } let _ = writeln!(stdout);