diff --git a/src/rustfmt_diff.rs b/src/rustfmt_diff.rs index 3e9fd913d7c6..3fb228653851 100644 --- a/src/rustfmt_diff.rs +++ b/src/rustfmt_diff.rs @@ -12,6 +12,7 @@ use diff; use std::collections::VecDeque; use std::io; use term; +use utils::isatty; #[derive(Debug, PartialEq)] pub enum DiffLine { @@ -105,25 +106,6 @@ where } _ => print_diff_basic(diff, get_section_title), } - - // isatty shamelessly adapted from cargo. - #[cfg(unix)] - fn isatty() -> bool { - extern crate libc; - - unsafe { libc::isatty(libc::STDOUT_FILENO) != 0 } - } - #[cfg(windows)] - fn isatty() -> bool { - extern crate kernel32; - extern crate winapi; - - unsafe { - let handle = kernel32::GetStdHandle(winapi::winbase::STD_OUTPUT_HANDLE); - let mut out = 0; - kernel32::GetConsoleMode(handle, &mut out) != 0 - } - } } fn print_diff_fancy( diff --git a/src/utils.rs b/src/utils.rs index 9a31289e8eb2..bd46ef1bc6ad 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -516,3 +516,22 @@ pub fn left_most_sub_expr(e: &ast::Expr) -> &ast::Expr { _ => e, } } + +// isatty shamelessly adapted from cargo. +#[cfg(unix)] +pub fn isatty() -> bool { + extern crate libc; + + unsafe { libc::isatty(libc::STDOUT_FILENO) != 0 } +} +#[cfg(windows)] +pub fn isatty() -> bool { + extern crate kernel32; + extern crate winapi; + + unsafe { + let handle = kernel32::GetStdHandle(winapi::winbase::STD_OUTPUT_HANDLE); + let mut out = 0; + kernel32::GetConsoleMode(handle, &mut out) != 0 + } +}