# Indicating that an example is "should\_panic" in docs

**URL:** <https://internals.rust-lang.org/t/indicating-that-an-example-is-should-panic-in-docs/12544>\
**Category:** documentation\
**Created:** [June 13, 2020, 7:22am UTC](https://internals.rust-lang.org/t/indicating-that-an-example-is-should-panic-in-docs/12544 "2020-06-13T07:22:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JakobDegen](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jakobdegen/32/7158_2.png) [@JakobDegen](https://internals.rust-lang.org/u/JakobDegen)\
**Post date:** [June 13, 2020, 7:22am UTC](https://internals.rust-lang.org/t/indicating-that-an-example-is-should-panic-in-docs/12544/1 "2020-06-13T07:22:39Z")

</div>

At the moment, the `should_panic` and some related attributes can modify how doctests are run and what their intended behavior is. However, in the generated documentation, there is no indication that the code example panics, besides the "this causes a panic" comment that is typically included. What are people's thoughts on the idea of including some visual indicator that a particular code example panics?

If this seems desirable, what should this indicator look like? The Book uses Ferris for this, although I do not think that would be appropriate for general documentation. My tentative idea right now is to add a small red exclamation mark, but I'm not at all sure this is ideal.

---

<div class="post-metadata">

**Author:** ![JakobDegen](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jakobdegen/32/7158_2.png) [@JakobDegen](https://internals.rust-lang.org/u/JakobDegen)\
**Post date:** [June 13, 2020, 9:10am UTC](https://internals.rust-lang.org/t/indicating-that-an-example-is-should-panic-in-docs/12544/3 "2020-06-13T09:10:54Z")

</div>

I'm not quite sure I understand your question. My suggestion is to mark the example in some form based on the existence of the `should_panic` attribute. I do not think the particular cause of the panic should matter for this.

---

<div class="post-metadata">

**Author:** ![ehuss](https://avatars.discourse-cdn.com/v4/letter/e/9de0a6/32.png) [@ehuss](https://internals.rust-lang.org/u/ehuss)\
**Post date:** [June 13, 2020, 1:49pm UTC](https://internals.rust-lang.org/t/indicating-that-an-example-is-should-panic-in-docs/12544/4 "2020-06-13T13:49:19Z")

</div>

The docs already have an icon/tooltip for some situations (see [here](https://github.com/rust-lang/rust/blob/1fb612bd15bb3ef098fd24c20d0727de573b4410/src/librustdoc/html/markdown.rs#L279-L287)). It seems reasonable to me to do that for should\_panic, too.

---

<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:** [September 11, 2020, 1:49pm UTC](https://internals.rust-lang.org/t/indicating-that-an-example-is-should-panic-in-docs/12544/5 "2020-09-11T13:49:28Z")

</div>

Closed on September 11, 2020, 1:49pm UTC

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