diff --git a/Cargo.lock b/Cargo.lock index 5d01c34d64f0..14e79442141c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,12 +93,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - [[package]] name = "autocfg" version = "1.1.0" @@ -252,6 +246,7 @@ dependencies = [ name = "cargo" version = "0.75.0" dependencies = [ + "anstream", "anstyle", "anstyle-termcolor", "anyhow", @@ -310,7 +305,6 @@ dependencies = [ "sha1", "shell-escape", "snapbox", - "strip-ansi-escapes", "syn 2.0.29", "tar", "tempfile", @@ -3117,15 +3111,6 @@ dependencies = [ "der", ] -[[package]] -name = "strip-ansi-escapes" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "011cbb39cf7c1f62871aea3cc46e5817b0937b49e9447370c93cacbe93a766d8" -dependencies = [ - "vte", -] - [[package]] name = "strsim" version = "0.10.0" @@ -3583,27 +3568,6 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" -[[package]] -name = "vte" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983" -dependencies = [ - "arrayvec", - "utf8parse", - "vte_generate_state_changes", -] - -[[package]] -name = "vte_generate_state_changes" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" -dependencies = [ - "proc-macro2", - "quote", -] - [[package]] name = "wait-timeout" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 3e243c2d531b..dc603dd1fefc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ edition = "2021" license = "MIT OR Apache-2.0" [workspace.dependencies] +anstream = { version = "0.6.0", default-features = false } anstyle = "1.0.3" anstyle-termcolor = "1.1.0" anyhow = "1.0.75" @@ -87,7 +88,6 @@ sha1 = "0.10.5" sha2 = "0.10.7" shell-escape = "0.1.5" snapbox = { version = "0.4.13", features = ["diff", "path"] } -strip-ansi-escapes = "0.1.1" syn = { version = "2.0.29", features = ["extra-traits", "full"] } tar = { version = "0.4.40", default-features = false } tempfile = "3.8.0" @@ -123,8 +123,9 @@ name = "cargo" path = "src/cargo/lib.rs" [dependencies] -anstyle.workspace = true +anstream.workspace = true anstyle-termcolor.workspace = true +anstyle.workspace = true anyhow.workspace = true base64.workspace = true bytesize.workspace = true @@ -175,7 +176,6 @@ serde_ignored.workspace = true serde_json = { workspace = true, features = ["raw_value"] } sha1.workspace = true shell-escape.workspace = true -strip-ansi-escapes.workspace = true syn.workspace = true tar.workspace = true tempfile.workspace = true diff --git a/src/cargo/core/compiler/future_incompat.rs b/src/cargo/core/compiler/future_incompat.rs index cfc028cf00ac..e94e42c390c4 100644 --- a/src/cargo/core/compiler/future_incompat.rs +++ b/src/cargo/core/compiler/future_incompat.rs @@ -272,9 +272,7 @@ impl OnDiskReports { let to_display = if shell.err_supports_color() && shell.out_supports_color() { to_display } else { - strip_ansi_escapes::strip(&to_display) - .map(|v| String::from_utf8(v).expect("utf8")) - .expect("strip should never fail") + anstream::adapter::strip_str(&to_display).to_string() }; Ok(to_display) } diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 5da3a908ed88..0cfb61ddcba7 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1591,9 +1591,7 @@ fn on_stderr_line_inner( } else { // Strip only fails if the Writer fails, which is Cursor // on a Vec, which should never fail. - strip_ansi_escapes::strip(&msg.rendered) - .map(|v| String::from_utf8(v).expect("utf8")) - .expect("strip should never fail") + anstream::adapter::strip_str(&msg.rendered).to_string() }; if options.show_diagnostics { let machine_applicable: bool = msg @@ -1625,9 +1623,7 @@ fn on_stderr_line_inner( other: std::collections::BTreeMap, } if let Ok(mut error) = serde_json::from_str::(compiler_message.get()) { - error.rendered = strip_ansi_escapes::strip(&error.rendered) - .map(|v| String::from_utf8(v).expect("utf8")) - .unwrap_or(error.rendered); + error.rendered = anstream::adapter::strip_str(&error.rendered).to_string(); let new_line = serde_json::to_string(&error)?; let new_msg: Box = serde_json::from_str(&new_line)?; compiler_message = new_msg;