1
Fork 0

Use IsTerminal in rustc_driver

This commit is contained in:
Josh Triplett 2022-10-16 14:55:18 +01:00
parent c5ad97da25
commit 34f61dd567

View file

@ -5,6 +5,7 @@
//! This API is completely unstable and subject to change. //! This API is completely unstable and subject to change.
#![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(is_terminal)]
#![feature(once_cell)] #![feature(once_cell)]
#![recursion_limit = "256"] #![recursion_limit = "256"]
#![allow(rustc::potential_query_instability)] #![allow(rustc::potential_query_instability)]
@ -26,7 +27,6 @@ use rustc_feature::find_gated_cfg;
use rustc_interface::util::{self, collect_crate_types, get_codegen_backend}; use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
use rustc_interface::{interface, Queries}; use rustc_interface::{interface, Queries};
use rustc_lint::LintStore; use rustc_lint::LintStore;
use rustc_log::stdout_isatty;
use rustc_metadata::locator; use rustc_metadata::locator;
use rustc_save_analysis as save; use rustc_save_analysis as save;
use rustc_save_analysis::DumpHandler; use rustc_save_analysis::DumpHandler;
@ -47,7 +47,7 @@ use std::default::Default;
use std::env; use std::env;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs; use std::fs;
use std::io::{self, Read, Write}; use std::io::{self, IsTerminal, Read, Write};
use std::panic::{self, catch_unwind}; use std::panic::{self, catch_unwind};
use std::path::PathBuf; use std::path::PathBuf;
use std::process::{self, Command, Stdio}; use std::process::{self, Command, Stdio};
@ -538,7 +538,7 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
} }
text.push('\n'); text.push('\n');
} }
if stdout_isatty() { if io::stdout().is_terminal() {
show_content_with_pager(&text); show_content_with_pager(&text);
} else { } else {
print!("{}", text); print!("{}", text);