Why does `panic!()` (and other macros that make panics) return `()` instead of `!`?

⚓ Rust    📅 2026-06-08    👤 surdeus    👁️ 1      

surdeus

In type theory, the return type of a function that never returns is the bottom type. In Rust, a panic call never returns, and the bottom type is !.
However, Rust analyzer annotates the return type of panic!() as (). Is this an mistake?
screenshot

4 posts - 3 participants

Read full topic

🏷️ Rust_feed