Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 978c960

Browse files
authored
Rollup merge of rust-lang#147031 - joshtriplett:mbe-opt-collect, r=lcnr
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.
2 parents 67d88f9 + 9e3f748 commit 978c960

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -894,12 +894,12 @@ fn check_redundant_vis_repetition(
894894
seq: &SequenceRepetition,
895895
span: &DelimSpan,
896896
) {
897-
let is_zero_or_one: bool = seq.kleene.op == KleeneOp::ZeroOrOne;
898-
let is_vis = seq.tts.first().map_or(false, |tt| {
899-
matches!(tt, mbe::TokenTree::MetaVarDecl { kind: NonterminalKind::Vis, .. })
900-
});
901-
902-
if is_vis && is_zero_or_one {
897+
if seq.kleene.op == KleeneOp::ZeroOrOne
898+
&& matches!(
899+
seq.tts.first(),
900+
Some(mbe::TokenTree::MetaVarDecl { kind: NonterminalKind::Vis, .. })
901+
)
902+
{
903903
err.note("a `vis` fragment can already be empty");
904904
err.multipart_suggestion(
905905
"remove the `$(` and `)?`",

0 commit comments

Comments
 (0)