Skip to content

Commit 6778baf

Browse files
committed
Fix up docs
1 parent 57572cf commit 6778baf

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

library/panic_abort/src/lib.rs

+5-12
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen
2727
unreachable!()
2828
}
2929

30-
// "Leak" the payload and shim to the relevant abort on the platform in
31-
// question.
32-
//
33-
// For Unix we just use `abort` from libc as it'll trigger debuggers, core
34-
// dumps, etc, as one might expect. On Windows, however, the best option we have
35-
// is the `__fastfail` intrinsics, but that's unfortunately not defined in LLVM,
36-
// and the `RaiseFailFastException` function isn't available until Windows 7
37-
// which would break compat with XP. For now just use `intrinsics::abort` which
38-
// will kill us with an illegal instruction, which will do a good enough job for
39-
// now hopefully.
30+
// "Leak" the payload and shim to the relevant abort on the platform in question.
4031
#[rustc_std_internal_symbol]
4132
pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
4233
abort();
@@ -57,14 +48,16 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 {
5748
__rust_abort();
5849
}
5950
} else if #[cfg(all(windows, any(target_arch = "x86", target_arch = "x86_64")))] {
60-
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
51+
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
6152
// and later, this will terminate the process immediately without running any
62-
// in-process exception handlers. In earlier versions of Windows, this
53+
// in-process exception handlers. In earlier versions of Windows, this
6354
// sequence of instructions will be treated as an access violation,
6455
// terminating the process but without necessarily bypassing all exception
6556
// handlers.
6657
//
6758
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
59+
//
60+
// Note: this is the same implementation as in libstd's `abort_internal`
6861
unsafe fn abort() -> ! {
6962
llvm_asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
7063
core::intrinsics::unreachable();

library/std/src/sys/windows/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ macro_rules! impl_is_zero {
281281
impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
282282

283283
pub fn cvt<I: IsZero>(i: I) -> crate::io::Result<I> {
284-
if i.is_zero() { Err(crate::io::Error::last_os_error()) } else { Ok(i) }
284+
if i.is_zero() {
285+
Err(crate::io::Error::last_os_error())
286+
} else {
287+
Ok(i)
288+
}
285289
}
286290

287291
pub fn dur2timeout(dur: Duration) -> c::DWORD {
@@ -300,14 +304,10 @@ pub fn dur2timeout(dur: Duration) -> c::DWORD {
300304
.unwrap_or(c::INFINITE)
301305
}
302306

303-
// On Windows, use the processor-specific __fastfail mechanism. In Windows 8
304-
// and later, this will terminate the process immediately without running any
305-
// in-process exception handlers. In earlier versions of Windows, this
306-
// sequence of instructions will be treated as an access violation,
307-
// terminating the process but without necessarily bypassing all exception
308-
// handlers.
309-
//
310-
// https://docs.microsoft.com/en-us/cpp/intrinsics/fastfail
307+
/// Use `__fastfail` to abort the process
308+
///
309+
/// This is the same implementation as in libpanic_abort's `__rust_start_panic`. See
310+
/// that function for more information on `__fastfail`
311311
#[allow(unreachable_code)]
312312
pub fn abort_internal() -> ! {
313313
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]

0 commit comments

Comments
 (0)