Use IsTerminal in rustc_errors
This commit is contained in:
parent
8be3ce9056
commit
c5ad97da25
4 changed files with 4 additions and 5 deletions
|
@ -3452,7 +3452,6 @@ name = "rustc_errors"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"annotate-snippets",
|
||||
"atty",
|
||||
"rustc_ast",
|
||||
"rustc_ast_pretty",
|
||||
"rustc_data_structures",
|
||||
|
|
|
@ -18,7 +18,6 @@ rustc_target = { path = "../rustc_target" }
|
|||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_lint_defs = { path = "../rustc_lint_defs" }
|
||||
unicode-width = "0.1.4"
|
||||
atty = "0.2"
|
||||
termcolor = "1.0"
|
||||
annotate-snippets = "0.9"
|
||||
termize = "0.1.1"
|
||||
|
|
|
@ -28,8 +28,8 @@ use rustc_error_messages::FluentArgs;
|
|||
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||
use std::borrow::Cow;
|
||||
use std::cmp::{max, min, Reverse};
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::io::{self, IsTerminal};
|
||||
use std::iter;
|
||||
use std::path::Path;
|
||||
use termcolor::{Ansi, BufferWriter, ColorChoice, ColorSpec, StandardStream};
|
||||
|
@ -619,14 +619,14 @@ impl ColorConfig {
|
|||
fn to_color_choice(self) -> ColorChoice {
|
||||
match self {
|
||||
ColorConfig::Always => {
|
||||
if atty::is(atty::Stream::Stderr) {
|
||||
if io::stderr().is_terminal() {
|
||||
ColorChoice::Always
|
||||
} else {
|
||||
ColorChoice::AlwaysAnsi
|
||||
}
|
||||
}
|
||||
ColorConfig::Never => ColorChoice::Never,
|
||||
ColorConfig::Auto if atty::is(atty::Stream::Stderr) => ColorChoice::Auto,
|
||||
ColorConfig::Auto if io::stderr().is_terminal() => ColorChoice::Auto,
|
||||
ColorConfig::Auto => ColorChoice::Never,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(is_terminal)]
|
||||
#![feature(adt_const_params)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(never_type)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue