Support if-let guards in matches macros by using :guard matcher#156025
Support if-let guards in matches macros by using :guard matcher#156025SpriteOvO wants to merge 2 commits into
matches macros by using :guard matcher#156025Conversation
Alternatively, to be more safe, we only provide the |
|
Hi - could you provide us some examples of where this might be a breaking change? We discussed this in the libs-api meeting but it wasn't quite clear what this might affect |
|
rust/compiler/rustc_expand/src/mbe/macro_rules.rs Lines 1716 to 1725 in 9128490 @nia-e My main concern was in
I took some time to rethink it, given that the original intent of this matcher was just to simplify matching match-guards, rather than to allow users to extend the syntax with custom rules. And strictly according to The requested Crater run was also based on the potential impacts mentioned above, plus, it’s instantly stable. If we decide to remove |
|
We discussed this in today's @rust-lang/libs-api meeting - we're fine with this so long as lang is okay committing to these semantics. Thanks! |
|
The one concern I have here is that if stabilizing But I really want the macro to use the (Said on the assumption that there's nothing particularly tricky involved in the |
|
Similar to what @scottmcm said, it'd seem best to me for us to commit to the semantics of the |
|
Please also keep in mind rust-lang/rfcs#3637. What's the story on forward compatibility with guard patterns if we do this? |
|
@rustbot author |
Tracking issue #153104.
This PR replaces the original
if $guard:exprwith new matcher$guard:guardin macrosmatches!andassert_matches!to support the use of if-let guards syntax in these macros. This syntax is already stable in #141295 formatcharms.Please note that this PR directly applies
:guardto macros that are already stable, so the support for if-let guards in these macros is instantly stable.When using these macros that accept
:guard, users will not be required to use nightly and enable#![feature(macro_guard_matcher)]. However, when defining macros with:guard, nightly and#![feature(macro_guard_matcher)]are still required. Therefore, I think a Crater run is needed.cc @programmerjake
r? libs