News for hackers. Stuff that matters.
Re:Cloudflare outage on November 18, 2025 post mortem by kibwen on Tuesday November 18, 2025 @10:33PM (#45975569)
The `unsafe` keyword means something specific in Rust, and panicking isn't unsafe by Rust's definition. Sometimes avoiding partial functions just isn't feasible, and an unwrap (or whatever you want to call the method) is a way of providing a (runtime-checked) proof to the compiler that the function is actually total.
Re:Cloudflare outage on November 18, 2025 post mortem by echelon on Tuesday November 18, 2025 @10:38PM (#45975598)
Panics should be explicit, not implicit.

unwrap() should effectively work as a Result<> where the user must manually invoke a panic in the failure branch. Make special syntax if a match and panic is too much boilerplate.

This is like an implicit null pointer exception that cannot be statically guarded against.

I want a way to statically block any crates doing this from my dependency chain.

Re:Cloudflare outage on November 18, 2025 post mortem by bigstrat2003 on Tuesday November 18, 2025 @11:04PM (#45975732)
unwrap is explicit.
Re:Cloudflare outage on November 18, 2025 post mortem by speedgoose on Wednesday November 19, 2025 @02:35AM (#45976831)
Not explicit enough, apparently.
Re:Cloudflare outage on November 18, 2025 post mortem by echelon on Wednesday November 19, 2025 @06:55AM (#45978489)
What happens if a dependency of mine unwrap()s or expect()s something that is an error or isn't there? What should I do?

How was I informed as a user? It's not in the type signature.

Sounds like I get to indeterminately crash at runtime and have a fun time debugging.

Re:Cloudflare outage on November 18, 2025 post mortem by the8472 on Wednesday November 19, 2025 @10:02AM (#45980418)
That would require an effects system[0] like Koka's[1]. Then one could not only express the absence of panics but also allocations, infinite loops and various other undesirable effects within some call-trees. This is a desirable feature, but an enormous undertaking.

Absent that there are hacks like no_panic[2]

[0] https://blog.yoshuawuyts.com/extending-rusts-effect-system/ [1] https://koka-lang.github.io/koka/doc/book.html#why-effects [2] https://crates.io/crates/no-panic

Re:Cloudflare outage on November 18, 2025 post mortem by wrs on Wednesday November 19, 2025 @12:12PM (#45982049)
Same thing that would happen if it did a match statement and panicked. The problem is the panic, not the unwrap.

I don’t think you can ever completely eliminate panics, because there are always going to be some assumptions in code that will be surprisingly violated, because bugs exist. What if the heap allocator discovers the heap is corrupted? What if you reference memory that’s paged out and the disk is offline? (That one’s probably not turned into a panic, but it’s the same principle.)

Re:Cloudflare outage on November 18, 2025 post mortem by wrs on Tuesday November 18, 2025 @11:11PM (#45975777)
Not sure what you're saying with the "work as a Result<>" part...unwrap is a method on Result. I think you're just saying the unwrap/expect methods should be eliminated?