diff options
| author | Josh Triplett <josh@joshtriplett.org> | 2025-09-25 07:43:25 -0700 |
|---|---|---|
| committer | Josh Triplett <josh@joshtriplett.org> | 2025-09-25 07:54:28 -0700 |
| commit | 9e3f7487e9e572aee95381688bda52525d79b005 (patch) | |
| tree | be3404610097b89eed76a5e8c75b515c5271a7f6 | |
| parent | 7cfd7d328b14b936c7ffede92cacebe8557c6388 (diff) | |
| download | rust-9e3f7487e9e572aee95381688bda52525d79b005.tar.gz rust-9e3f7487e9e572aee95381688bda52525d79b005.zip | |
mbe: Simplify check_redundant_vis_repetition
Eliminate a use of `map_or` in favor of a match. Inline some variable definitions that don't add clarity, and that prevent short-circuiting.
| -rw-r--r-- | compiler/rustc_expand/src/mbe/macro_rules.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 1d147a0385c..74b7de7e12b 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -894,12 +894,12 @@ fn check_redundant_vis_repetition( seq: &SequenceRepetition, span: &DelimSpan, ) { - let is_zero_or_one: bool = seq.kleene.op == KleeneOp::ZeroOrOne; - let is_vis = seq.tts.first().map_or(false, |tt| { - matches!(tt, mbe::TokenTree::MetaVarDecl { kind: NonterminalKind::Vis, .. }) - }); - - if is_vis && is_zero_or_one { + if seq.kleene.op == KleeneOp::ZeroOrOne + && matches!( + seq.tts.first(), + Some(mbe::TokenTree::MetaVarDecl { kind: NonterminalKind::Vis, .. }) + ) + { err.note("a `vis` fragment can already be empty"); err.multipart_suggestion( "remove the `$(` and `)?`", |
