Skip to content

Commit fd574d7

Browse files
committed
refactor(compile): Remove redundant color stripping
These messages will eventually be forwarded to `Shell` which will strip as needed, making it so we don't need to strip here anymore.
1 parent 10230d4 commit fd574d7

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ fn compile<'cfg>(
202202
&unit.target,
203203
cx.files().message_cache_path(unit),
204204
cx.bcx.build_config.message_format,
205-
cx.bcx.config.shell().err_supports_color(),
206205
unit.show_warnings(bcx.config),
207206
);
208207
// Need to link targets on both the dirty and fresh.
@@ -1416,8 +1415,6 @@ fn envify(s: &str) -> String {
14161415
struct OutputOptions {
14171416
/// What format we're emitting from Cargo itself.
14181417
format: MessageFormat,
1419-
/// Whether or not to display messages in color.
1420-
color: bool,
14211418
/// Where to write the JSON messages to support playback later if the unit
14221419
/// is fresh. The file is created lazily so that in the normal case, lots
14231420
/// of empty files are not created. If this is None, the output will not
@@ -1439,14 +1436,12 @@ struct OutputOptions {
14391436

14401437
impl OutputOptions {
14411438
fn new(cx: &Context<'_, '_>, unit: &Unit) -> OutputOptions {
1442-
let color = cx.bcx.config.shell().err_supports_color();
14431439
let path = cx.files().message_cache_path(unit);
14441440
// Remove old cache, ignore ENOENT, which is the common case.
14451441
drop(fs::remove_file(&path));
14461442
let cache_cell = Some((path, LazyCell::new()));
14471443
OutputOptions {
14481444
format: cx.bcx.build_config.message_format,
1449-
color,
14501445
cache_cell,
14511446
show_diagnostics: true,
14521447
warnings_seen: 0,
@@ -1586,13 +1581,7 @@ fn on_stderr_line_inner(
15861581
if msg.rendered.ends_with('\n') {
15871582
msg.rendered.pop();
15881583
}
1589-
let rendered = if options.color {
1590-
msg.rendered
1591-
} else {
1592-
// Strip only fails if the Writer fails, which is Cursor
1593-
// on a Vec, which should never fail.
1594-
anstream::adapter::strip_str(&msg.rendered).to_string()
1595-
};
1584+
let rendered = msg.rendered;
15961585
if options.show_diagnostics {
15971586
let machine_applicable: bool = msg
15981587
.children
@@ -1695,13 +1684,11 @@ fn replay_output_cache(
16951684
target: &Target,
16961685
path: PathBuf,
16971686
format: MessageFormat,
1698-
color: bool,
16991687
show_diagnostics: bool,
17001688
) -> Work {
17011689
let target = target.clone();
17021690
let mut options = OutputOptions {
17031691
format,
1704-
color,
17051692
cache_cell: None,
17061693
show_diagnostics,
17071694
warnings_seen: 0,

0 commit comments

Comments
 (0)