@@ -56,7 +56,6 @@ extern crate log;
56
56
extern crate syntax;
57
57
extern crate syntax_ext;
58
58
extern crate syntax_pos;
59
- extern crate isatty;
60
59
61
60
use driver:: CompileController ;
62
61
use pretty:: { PpMode , UserIdentifiedItem } ;
@@ -101,8 +100,6 @@ use syntax::feature_gate::{GatedCfg, UnstableFeatures};
101
100
use syntax:: parse:: { self , PResult } ;
102
101
use syntax_pos:: { DUMMY_SP , MultiSpan } ;
103
102
104
- use isatty:: stdout_isatty;
105
-
106
103
#[ cfg( test) ]
107
104
pub mod test;
108
105
@@ -347,6 +344,35 @@ pub trait CompilerCalls<'a> {
347
344
#[ derive( Copy , Clone ) ]
348
345
pub struct RustcDefaultCalls ;
349
346
347
+ /**
348
+ * TODO remove these and use winapi 0.3 instead
349
+ *
350
+ * These are duplicated in
351
+ * - bootstrap/compile.rs#L478
352
+ * - librustc_errors/emitter.rs#L1253
353
+ */
354
+ #[ cfg( unix) ]
355
+ fn stdout_isatty ( ) -> bool {
356
+ unsafe { libc:: isatty ( libc:: STDOUT_FILENO ) != 0 }
357
+ }
358
+ #[ cfg( windows) ]
359
+ fn stdout_isatty ( ) -> bool {
360
+ type DWORD = u32 ;
361
+ type BOOL = i32 ;
362
+ type HANDLE = * mut u8 ;
363
+ type LPDWORD = * mut u32 ;
364
+ const STD_OUTPUT_HANDLE : DWORD = -11i32 as DWORD ;
365
+ extern "system" {
366
+ fn GetStdHandle ( which : DWORD ) -> HANDLE ;
367
+ fn GetConsoleMode ( hConsoleHandle : HANDLE , lpMode : LPDWORD ) -> BOOL ;
368
+ }
369
+ unsafe {
370
+ let handle = GetStdHandle ( STD_OUTPUT_HANDLE ) ;
371
+ let mut out = 0 ;
372
+ GetConsoleMode ( handle, & mut out) != 0
373
+ }
374
+ }
375
+
350
376
fn handle_explain ( code : & str ,
351
377
descriptions : & errors:: registry:: Registry ,
352
378
output : ErrorOutputType ) {
0 commit comments