-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
30 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 13 additions & 16 deletions
29
tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
// Test that println! to a closed stdout does not panic. | ||
// On Windows, close via SetStdHandle to 0. | ||
//@ run-pass | ||
#![allow(dead_code)] | ||
|
||
#![feature(rustc_private)] | ||
|
||
extern crate libc; | ||
|
||
type DWORD = u32; | ||
type HANDLE = *mut u8; | ||
type BOOL = i32; | ||
|
||
#[cfg(windows)] | ||
extern "system" { | ||
fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; | ||
} | ||
|
||
#[cfg(windows)] | ||
fn close_stdout() { | ||
type DWORD = u32; | ||
type HANDLE = *mut u8; | ||
type BOOL = i32; | ||
|
||
extern "system" { | ||
fn SetStdHandle(nStdHandle: DWORD, nHandle: HANDLE) -> BOOL; | ||
} | ||
|
||
const STD_OUTPUT_HANDLE: DWORD = -11i32 as DWORD; | ||
unsafe { SetStdHandle(STD_OUTPUT_HANDLE, 0 as HANDLE); } | ||
} | ||
|
||
#[cfg(windows)] | ||
#[cfg(not(windows))] | ||
fn close_stdout() {} | ||
|
||
fn main() { | ||
close_stdout(); | ||
println!("hello"); | ||
println!("world"); | ||
} | ||
|
||
#[cfg(not(windows))] | ||
fn main() {} |
23 changes: 11 additions & 12 deletions
23
tests/ui/rfcs/rfc-1014-stdout-existential-crisis/rfc-1014.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters