Skip to content

Commit 72bc4ae

Browse files
thomccpietroalbini
authored andcommitted
Add a compile_fail doctest to check that io::Error: !UnwindSafe
1 parent c763f06 commit 72bc4ae

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

library/std/src/io/error/repr_bitpacked.rs

+9
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ const TAG_CUSTOM: usize = 0b01;
115115
const TAG_OS: usize = 0b10;
116116
const TAG_SIMPLE: usize = 0b11;
117117

118+
/// The internal representation.
119+
///
120+
/// See the module docs for more, this is just a way to hack in a check that we
121+
/// indeed are not unwind-safe.
122+
///
123+
/// ```compile_fail
124+
/// fn is_unwind_safe<T: core::panic::UnwindSafe>() {}
125+
/// is_unwind_safe::<std::io::Error>();
126+
/// ```
118127
#[repr(transparent)]
119128
pub(super) struct Repr(NonNull<()>, PhantomData<ErrorData<Box<Custom>>>);
120129

0 commit comments

Comments
 (0)