# How to Panic in Rust

**URL:** <https://internals.rust-lang.org/t/how-to-panic-in-rust/11368>\
**Category:** Uncategorized\
**Created:** [November 25, 2019, 11:29am UTC](https://internals.rust-lang.org/t/how-to-panic-in-rust/11368 "2019-11-25T11:29:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RalfJung](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ralfjung/32/2415_2.png) [@RalfJung](https://internals.rust-lang.org/u/RalfJung)\
**Post date:** [November 25, 2019, 11:29am UTC](https://internals.rust-lang.org/t/how-to-panic-in-rust/11368/1 "2019-11-25T11:29:10Z")

</div>

What exactly happens when you `panic!()` ? I recently spent a lot of time looking at the parts of the standard library concerned with this, and it turns out the answer is quite complicated! I have not been able to find docs explaining the high-level picture of panicking in Rust, so this feels worth writing down.

[https://www.ralfj.de/blog/2019/11/25/how-to-panic-in-rust.html](https://www.ralfj.de/blog/2019/11/25/how-to-panic-in-rust.html)

I'd love to put this overview somewhere more permanently than a blog post, any suggestions for what would be a good place? I first through of the rustc guide but that is concerned with rustc, not libstd.

---

<div class="post-metadata">

**Author:** ![Aaron1011](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/aaron1011/32/2246_2.png) [@Aaron1011](https://internals.rust-lang.org/u/Aaron1011)\
**Post date:** [November 25, 2019, 3:20pm UTC](https://internals.rust-lang.org/t/how-to-panic-in-rust/11368/2 "2019-11-25T15:20:33Z")

</div>

@RalfJung: Looks like we raced to write this explanation 😄 :[https://github.com/rust-lang/rustc-guide/pull/521](https://github.com/rust-lang/rustc-guide/pull/521)

---

<div class="post-metadata">

**Author:** ![RalfJung](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ralfjung/32/2415_2.png) [@RalfJung](https://internals.rust-lang.org/u/RalfJung)\
**Post date:** [November 25, 2019, 9:30pm UTC](https://internals.rust-lang.org/t/how-to-panic-in-rust/11368/3 "2019-11-25T21:30:01Z")

</div>

Oh lol, sorry for that.^^ I felt the urge yesterday to write down this stuff, seems like it would have been a more productive use of my time to review your PR instead. 😕

---

<div class="post-metadata">

**Author:** ![Tom-Phinney](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/tom-phinney/32/3299_2.png) [@Tom-Phinney](https://internals.rust-lang.org/u/Tom-Phinney)\
**Post date:** [November 25, 2019, 11:21pm UTC](https://internals.rust-lang.org/t/how-to-panic-in-rust/11368/4 "2019-11-25T23:21:43Z")

</div>

Personally, I think your two contributions are complementary, so thank you both.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [February 23, 2020, 11:21pm UTC](https://internals.rust-lang.org/t/how-to-panic-in-rust/11368/5 "2020-02-23T23:21:48Z")

</div>

Closed on February 23, 2020, 11:21pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
