-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #3464 - RalfJung:windows-err, r=RalfJung
Windows: add basic support for FormatMessageW
- Loading branch information
Showing
5 changed files
with
79 additions
and
19 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,19 @@ | ||
use std::io::IsTerminal; | ||
use std::io::{self, IsTerminal}; | ||
|
||
fn main() { | ||
// We can't really assume that this is truly a terminal, and anyway on Windows Miri will always | ||
// return `false` here, but we can check that the call succeeds. | ||
std::io::stdout().is_terminal(); | ||
io::stdout().is_terminal(); | ||
|
||
// Ensure we can format `io::Error` created from OS errors | ||
// (calls OS-specific error formatting functions). | ||
let raw_os_error = if cfg!(unix) { | ||
22 // EINVAL (on most Unixes, anyway) | ||
} else if cfg!(windows) { | ||
87 // ERROR_INVALID_PARAMETER | ||
} else { | ||
panic!("unsupported OS") | ||
}; | ||
let err = io::Error::from_raw_os_error(raw_os_error); | ||
format!("{err}: {err:?}"); | ||
} |