External Publication
Visit Post

Pre-RFC improved ergonomics for `!`

Rust Internals [Unofficial] May 23, 2026
Source

MusicalNinjaDad:

so the user is used to adding unreachable!() or similar to avoid a compiler error.

The best way to avoid this error when using Infallible is match _b {} – you can match against all 0 variants of Infallible to avoid the error (which compiles because all 0 match arms produce a value of the correct type). It's possible that this technique isn't sufficiently widely-known, so maybe we'd benefit from Clippy or the like explaining it (but maybe that wouldn't be worth it, given that Infallible is due to be replaced by !).

I'm not sure what happens if you write the equivalent using !. In any case, it would make sense to not lint on a 0-variant match in unreachable code (because the construct in question explicitly serves as a proof that the code is unreachable / marks it as unreachable, so is unlikely to have been a mistake).

Discussion in the ATmosphere

Loading comments...