Rollup merge of #103117 - joshtriplett:use-is-terminal, r=eholk
Use `IsTerminal` in place of `atty` In any crate that can use nightly features, use `IsTerminal` rather than `atty`: - Use `IsTerminal` in `rustc_errors` - Use `IsTerminal` in `rustc_driver` - Use `IsTerminal` in `rustc_log` - Use `IsTerminal` in `librustdoc`
This commit is contained in:
commit
52cc0d5360
9 changed files with 14 additions and 17 deletions
|
@ -3535,7 +3535,6 @@ name = "rustc_errors"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"annotate-snippets",
|
||||
"atty",
|
||||
"rustc_ast",
|
||||
"rustc_ast_pretty",
|
||||
"rustc_data_structures",
|
||||
|
@ -3834,7 +3833,6 @@ dependencies = [
|
|||
name = "rustc_log"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"rustc_span",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
|
@ -4389,7 +4387,6 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"arrayvec",
|
||||
"askama",
|
||||
"atty",
|
||||
"expect-test",
|
||||
"itertools",
|
||||
"minifier",
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
//! This API is completely unstable and subject to change.
|
||||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
#![feature(is_terminal)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(decl_macro)]
|
||||
#![recursion_limit = "256"]
|
||||
|
@ -27,7 +28,6 @@ use rustc_feature::find_gated_cfg;
|
|||
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
|
||||
use rustc_interface::{interface, Queries};
|
||||
use rustc_lint::LintStore;
|
||||
use rustc_log::stdout_isatty;
|
||||
use rustc_metadata::locator;
|
||||
use rustc_save_analysis as save;
|
||||
use rustc_save_analysis::DumpHandler;
|
||||
|
@ -48,7 +48,7 @@ use std::default::Default;
|
|||
use std::env;
|
||||
use std::ffi::OsString;
|
||||
use std::fs;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::io::{self, IsTerminal, Read, Write};
|
||||
use std::panic::{self, catch_unwind};
|
||||
use std::path::PathBuf;
|
||||
use std::process::{self, Command, Stdio};
|
||||
|
@ -515,7 +515,7 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
|
|||
}
|
||||
text.push('\n');
|
||||
}
|
||||
if stdout_isatty() {
|
||||
if io::stdout().is_terminal() {
|
||||
show_content_with_pager(&text);
|
||||
} else {
|
||||
print!("{}", text);
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -4,7 +4,6 @@ version = "0.0.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
atty = "0.2"
|
||||
tracing = "0.1.28"
|
||||
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
|
||||
tracing-tree = "0.2.0"
|
||||
|
|
|
@ -40,10 +40,11 @@
|
|||
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||
#![feature(is_terminal)]
|
||||
|
||||
use std::env::{self, VarError};
|
||||
use std::fmt::{self, Display};
|
||||
use std::io;
|
||||
use std::io::{self, IsTerminal};
|
||||
use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter};
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
|
||||
|
@ -93,11 +94,11 @@ pub fn init_env_logger(env: &str) -> Result<(), Error> {
|
|||
}
|
||||
|
||||
pub fn stdout_isatty() -> bool {
|
||||
atty::is(atty::Stream::Stdout)
|
||||
io::stdout().is_terminal()
|
||||
}
|
||||
|
||||
pub fn stderr_isatty() -> bool {
|
||||
atty::is(atty::Stream::Stderr)
|
||||
io::stderr().is_terminal()
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -9,7 +9,6 @@ path = "lib.rs"
|
|||
[dependencies]
|
||||
arrayvec = { version = "0.7", default-features = false }
|
||||
askama = { version = "0.11", default-features = false, features = ["config"] }
|
||||
atty = "0.2"
|
||||
itertools = "0.10.1"
|
||||
minifier = "0.2.2"
|
||||
once_cell = "1.10.0"
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#![feature(box_patterns)]
|
||||
#![feature(control_flow_enum)]
|
||||
#![feature(drain_filter)]
|
||||
#![feature(is_terminal)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(test)]
|
||||
#![feature(never_type)]
|
||||
|
@ -69,7 +70,7 @@ extern crate jemalloc_sys;
|
|||
|
||||
use std::default::Default;
|
||||
use std::env::{self, VarError};
|
||||
use std::io;
|
||||
use std::io::{self, IsTerminal};
|
||||
use std::process;
|
||||
|
||||
use rustc_driver::abort_on_err;
|
||||
|
@ -179,7 +180,7 @@ fn init_logging() {
|
|||
let color_logs = match std::env::var("RUSTDOC_LOG_COLOR").as_deref() {
|
||||
Ok("always") => true,
|
||||
Ok("never") => false,
|
||||
Ok("auto") | Err(VarError::NotPresent) => atty::is(atty::Stream::Stdout),
|
||||
Ok("auto") | Err(VarError::NotPresent) => io::stdout().is_terminal(),
|
||||
Ok(value) => early_error(
|
||||
ErrorOutputType::default(),
|
||||
&format!("invalid log color value '{}': expected one of always, never, or auto", value),
|
||||
|
|
Loading…
Add table
Reference in a new issue