it might make more sense to start with a review and see what the team thinks first rather than rushing stabilization PR, but (!) this is finish line to be stablizied
I went through the full set of tests and also studied #132833, which stabilized let_chains and includes a some of discussion and evidence that if let guards behave correctly
My conclusion is that the feature appears sound and well-tested, and I believe it’s ready for stabilization (for 2024 edition for now). If I missed anything, please let me know
I'm wondering if we should enable if let guards only for edition 2024 and later. I tried removing the edition checks and applying the IfLetRescope behavior in edition 2021, but it led to MIR issues (e.g., ICE related to drop scopes). Given that let_chains were also stabilized only for edition 2024 to avoid similar backward compatibility pitfalls, maybe it makes sense to take the same approach here?
We could open an issue later if compatibility between editions becomes essential, but for now, it seems reasonable to restrict this feature to edition 2024. After all, it is stable (at least in 2024 edition), and thanks to if let rescope, it is now highly predictable and stable, especially for things like move and drop semantics
Since development seems to have stalled, and the test suite already covers a wide range of interactions (including drop order, temporaries, mutability, macros and a LOT more), I believe this would be a productive and low-risk step toward stabilization
If this direction looks good to everyone, I’d be happy to try opening a proper stabilization PR — not sure how tricky it’ll be, but I’d love to gain the experience :D
Reference adding documentaion for if let rust-lang/reference#1823
Here my my write-up explaining this feature and how it works in details
kivooeo.github.io/if-let-guard-feature/
Current stabilization checklist (feel free to ask add/fix something here)
- Tests cover drop order, move, async, const, bindings, temporaries, mutability, macros, and a lot more (see tests for
if letguard) - est31:
irrefutable_let_patternslint works as expected - Verify other lints (
unused_variables,unreachable_patterns, etc.) - Documentation updated in
src/doc/if-let-guard-review.mdand rust-lang/reference#1823 (Theif-let-guard-review.mddocument is a comprehensive write-up summarizing the state of theif letguards feature, including tests, drop semantics, and stabilization considerations. Since it’s more of a review and discussion document rather than final documentation, I don’t think it belongs insrc/doc) - Check and confirm rustfmt support for
if letguards -
Confirm 2024-only stabilization with team - Make this work on all editions
- Open stabilization PR after team approval