avatar
least informed nerd @leastinformednerd.bsky.social

I think it's supposed to just be uncreachable! with panic swapped out for abort

aug 27, 2025, 9:54 pm • 1 0

Replies

avatar
Steve Klabnik @steveklabnik.com

All unreachable does is call panic, so that would just be abort

aug 27, 2025, 9:55 pm • 5 0 • view
avatar
barrett ✨ @barretts.club

Dang, I completely thought it did more! Sure enough... 😄

An example program. I ran `cargo expand` on a sample `main.rs` containing only `unreachable!()`. Only a `panic` resulted!
aug 28, 2025, 1:56 pm • 5 0 • view
avatar
barrett ✨ @barretts.club

I suppose we're waiting on `core::hint::cold_path` to be stable? Then it'd be pretty easy to stick in the macro, imv :D doc.rust-lang.org/core/hint/in...

aug 28, 2025, 1:58 pm • 3 0 • view
avatar
least informed nerd @leastinformednerd.bsky.social

The standard library uses so much unstable code anyway it’d be strange for that to be blocker 😄

aug 28, 2025, 7:59 pm • 0 0 • view
avatar
Alyssa the Kate @alyssa.codes

plus the formatted print beforehand

aug 28, 2025, 1:46 pm • 2 0 • view
avatar
least informed nerd @leastinformednerd.bsky.social

huh I don't know why I thought it made a compiler hint, I guess the argument for it is the same as the argument for having unreachable! itself (in that you provide a different name with different semantic implications although the different message part is irrelevant

aug 27, 2025, 9:58 pm • 5 0 • view
avatar
waffle @wffl.ihatereality.space

I mean, nothing stops us from making `unreachble!` also expand to `hint::cold_path()`...

aug 27, 2025, 10:05 pm • 6 0 • view
avatar
Alice ✨ @welltypedwit.ch

arguably, panic! could also expand to that couldn't it?

aug 27, 2025, 10:11 pm • 4 0 • view
avatar
barrett ✨ @barretts.club

wait. this would be kinda perfect

aug 28, 2025, 2:00 pm • 2 0 • view
avatar
waffle @wffl.ihatereality.space

in what way?

aug 28, 2025, 2:41 pm • 2 0 • view
avatar
barrett ✨ @barretts.club

Panics are "unexpected" and, when they occur, we're going to unwind and be slow anyway! In most cases, I think marking it as the "cold path" would be a good default

aug 28, 2025, 2:52 pm • 3 0 • view
avatar
waffle @wffl.ihatereality.space

yea..

aug 28, 2025, 3:23 pm • 2 0 • view
avatar
waffle @wffl.ihatereality.space

yeah, I thought about it after posting my skeet, ur right ^^'

aug 27, 2025, 11:25 pm • 1 0 • view
avatar
least informed nerd @leastinformednerd.bsky.social

maybe? I know some people reuse its unwinding mechanism for more general exceptions, but they could very well be using a lower level mechanism than panic! (and I don't know if there's any stability guarantees that prevent that)

aug 27, 2025, 10:27 pm • 3 0 • view
avatar
least informed nerd @leastinformednerd.bsky.social

yeah, it's strange (and I guess somewhat unintuitive) that it doesn't. The reason appears to be that it was introduced in 2011 and the only change since was just updating for different panic editions github.com/rust-lang/ru...

aug 27, 2025, 10:26 pm • 4 0 • view
avatar
waffle @wffl.ihatereality.space

I wouldn't say it's that strange. `cold_path` is a somewhat new addition and it's not totally clear if it does anything in practice... also, you will be surprised how many things aren't done simply because no one thought about them at all, or didn't care enough to do ^^'

aug 27, 2025, 11:24 pm • 4 0 • view
avatar
least informed nerd @leastinformednerd.bsky.social

ah that makes sense Yeah I'm not surprised, I think it's kind of inevitable

aug 27, 2025, 11:38 pm • 2 0 • view
avatar
Steve Klabnik @steveklabnik.com

Yeah, I’m kinda not a fan of unreachable for this exact reason

aug 27, 2025, 9:59 pm • 4 0 • view