Skip to content

#[no_panic] --> #[no_panic_if(cond)]#1387

Closed
ninehusky wants to merge 16 commits intoflux-rs:mainfrom
ninehusky:ninehusky-add-panic-if
Closed

#[no_panic] --> #[no_panic_if(cond)]#1387
ninehusky wants to merge 16 commits intoflux-rs:mainfrom
ninehusky:ninehusky-add-panic-if

Conversation

@ninehusky
Copy link
Contributor

@ninehusky ninehusky commented Dec 2, 2025

Implements conditional panics, which is the starter step for us to target things like no_panic on traits/closures/etc.

The rough implementation roadmap in my head:

  • Change the no_panic attribute so that it's accompanied with an Expr describing some condition. no_panic without an expr desugars to no_panic_if(true).
  • In the same place where we check preconditions/refinements, if a function is annotated with no_panic_if(cond), then append that as a precondition. e.g., if I have some function which requires len > 0, and a no_panic spec saying idx < len, then the precondition to prove is len > 0 && idx < len.

EDIT: Freezing this for now so that we can work on the more specific solution of marking closures as no_panic. We can come back to this later.

@ninehusky
Copy link
Contributor Author

ninehusky commented Dec 2, 2025

It's still not 100% clear to me why this is on the critical path to checking closures/traits with no_panic.

One thing me and Evan chatted about today was that this could empower users to have a more ergonomic interface for Flux: this allows us to say something like "scream at the user if they care about one specific flavor of checks, otherwise don't care." That seems a bit orthogonal to checking traits, though -- I think I'm forgetting the motivation behind this change!

To be clear: I don't have any specific concerns. I just forget why this is the next step!

Edit: oh, it's because this is no_panic_bikeshed from this discussion.

@ninehusky ninehusky marked this pull request as ready for review February 12, 2026 23:14
@ninehusky
Copy link
Contributor Author

Thanks for the help @nilehmann!! Ready for more comments :)

@nilehmann
Copy link
Member

@ninehusky, I fixed some details and merged your changes in #1492

@nilehmann nilehmann closed this Feb 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants