Repository: rust-lang/rust
File: library/panic_unwind/src/lib.rs (Rust)

Code before:
//! Implementation of panics via stack unwinding
//!
//! This crate is an implementation of panics in Rust using "most native" stack
//! unwinding mechanism of the platform this is being compiled for. This
//! essentially gets categorized into three buckets currently:
//!
//! 1. MSVC targets use SEH in the `seh.rs` file.
//! 2. Emscripten uses C++ exceptions in the `emcc.rs` file.
//! 3. All other targets use libunwind/libgcc in the `gcc.rs` file.
//!
//! More documentation about each implementation can be found in the respective
//! module.

#![no_std]
#![unstable(feature = "panic_unwind", issue = "32837")]
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![feature(cfg_emscripten_wasm_eh)]
#![feature(cfg_select)]
#![feature(core_intrinsics)]
#![feature(lang_items)]
#![feature(panic_unwind)]
#![feature(staged_api)]
#![feature(std_internals)]
#![feature(rustc_attrs)]
#![panic_runtime]
#![feature(panic_runtime)]
#![allow(internal_features)]
#![warn(unreachable_pub)]
#![deny(unsafe_op_in_unsafe_fn)]

use alloc::boxed::Box;
use core::any::Any;
use core::panic::PanicPayload;

cfg_select! {
    all(target_os = "emscripten", not(emscripten_wasm_eh)) => {
        #[path = "emcc.rs"]
        mod imp;
    }
    target_os = "hermit" => {
        #[path = "hermit.rs"]
        mod imp;
    }
    target_os = "l4re" => {
        // L4Re is unix family but does not yet support unwinding.

Review comment (bug):
Emscripten needs this feature.
https://github.com/rust-lang/rust/blob/1ed488274bec5bf5cfe6bf7a1cc089abcc4ebd68/library/panic_unwind/src/emcc.rs#L40
```console
error[E0658]: lang items are subject to change
  --> /rustc/1ed488274bec5bf5cfe6bf7a1cc089abcc4ebd68/library/panic_unwind/src/emcc.rs:40:1
   |
40 | #[lang = "eh_catch_typeinfo"]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: add `#![feature(lang_items)]` to the crate attributes to enable
   = note: this compiler was built on 2026-02-25; consider upgrading it if it is out of date

For more information about this error, try `rustc --explain E0658`.
error: could not compile `panic_unwind` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
```


Code after:
//! Implementation of panics via stack unwinding
//!
//! This crate is an implementation of panics in Rust using "most native" stack
//! unwinding mechanism of the platform this is being compiled for. This
//! essentially gets categorized into three buckets currently:
//!
//! 1. MSVC targets use SEH in the `seh.rs` file.
//! 2. Emscripten uses C++ exceptions in the `emcc.rs` file.
//! 3. All other targets use libunwind/libgcc in the `gcc.rs` file.
//!
//! More documentation about each implementation can be found in the respective
//! module.

#![no_std]
#![unstable(feature = "panic_unwind", issue = "32837")]
#![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![feature(cfg_emscripten_wasm_eh)]
#![feature(cfg_select)]
#![feature(core_intrinsics)]
#![feature(panic_unwind)]
#![feature(staged_api)]
#![feature(std_internals)]
#![feature(rustc_attrs)]
#![panic_runtime]
#![feature(panic_runtime)]
#![allow(internal_features)]
#![allow(unused_features)]
#![warn(unreachable_pub)]
#![deny(unsafe_op_in_unsafe_fn)]

use alloc::boxed::Box;
use core::any::Any;
use core::panic::PanicPayload;

cfg_select! {
    all(target_os = "emscripten", not(emscripten_wasm_eh)) => {
        #[path = "emcc.rs"]
        mod imp;
    }
    target_os = "hermit" => {
        #[path = "hermit.rs"]
        mod imp;
    }
    target_os = "l4re" => {
        // L4Re is unix family but does not yet support unwinding.