Rust Panic.instructions
---
description: Microsoft Rust guidelines for panic behavior — panics mean immediate program termination, detected programming bugs panic rather than return errors. Enforced on all Rust source files.
applyTo: "**/*.rs"
---
# Rust Panic Guidelines (Microsoft Pragmatic Rust)
## Panic Means 'Stop the Program' (M-PANIC-IS-STOP)
Panics are not exceptions. Instead, they suggest immediate program termination.
Although your code must be
[panic-safe](https://doc.rust-lang.org/nomicon/exception-safety.html) (i.e., a
survived panic may not lead to inconsistent state), invoking a panic means _this
program should stop now_. It is not valid to:
- use panics to communicate (errors) upstream,
- use panics to handle self-inflicted error conditions,
- assume panics will be caught, even by your own code.
For example, if the application calling you is compiled with a `Cargo.toml`
containingwhen to use it
Community prompt sourced from the open-source GitHub repo pngdeity/apm-user-repository (MIT). A "Rust Panic.instructions" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
roleplaycommunitygeneral
source
pngdeity/apm-user-repository · MIT