diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index d4976a469cc15..ab6f2b47aae07 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -518,7 +518,7 @@ pub fn panicking() -> bool { } /// Entry point of panics from the libcore crate (`panic_impl` lang item). -#[cfg(not(test))] +#[cfg(not(any(test, doctest)))] #[panic_handler] pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! { struct PanicPayload<'a> { @@ -590,7 +590,7 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! { /// panic!() and assert!(). In particular, this is the only entry point that supports /// arbitrary payloads, not just format strings. #[unstable(feature = "libstd_sys_internals", reason = "used by the panic! macro", issue = "none")] -#[cfg_attr(not(test), lang = "begin_panic")] +#[cfg_attr(not(any(test, doctest)), lang = "begin_panic")] // lang item for CTFE panic support // never inline unless panic_immediate_abort to avoid code // bloat at the call sites as much as possible diff --git a/library/std/src/personality.rs b/library/std/src/personality.rs index 63f0ad4f16e34..99305dfe9f730 100644 --- a/library/std/src/personality.rs +++ b/library/std/src/personality.rs @@ -12,7 +12,7 @@ mod dwarf; -#[cfg(not(test))] +#[cfg(not(any(test, doctest)))] cfg_if::cfg_if! { if #[cfg(target_os = "emscripten")] { mod emcc; diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 400d25beb26f3..a56e5cd29a367 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -2151,7 +2151,7 @@ pub fn id() -> u32 { /// of the `main` function, this trait is likely to be available only on /// standard library's runtime for convenience. Other runtimes are not required /// to provide similar functionality. -#[cfg_attr(not(test), lang = "termination")] +#[cfg_attr(not(any(test, doctest)), lang = "termination")] #[stable(feature = "termination_trait_lib", since = "1.61.0")] #[rustc_on_unimplemented( on( diff --git a/library/std/src/rt.rs b/library/std/src/rt.rs index 9c2f0c1dd3eb6..010a4ca979731 100644 --- a/library/std/src/rt.rs +++ b/library/std/src/rt.rs @@ -154,7 +154,7 @@ fn lang_start_internal( ret_code } -#[cfg(not(test))] +#[cfg(not(any(test, doctest)))] #[lang = "start"] fn lang_start( main: fn() -> T,