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