Skip to content

Commit 3fc8f89

Browse files
committed
Clarify parse a little.
- Name the colon span as `colon_span` to distinguish it from the other `span` local variable. - Just use basic pattern matching, which is easier to read than `map_or`.
1 parent c8844df commit 3fc8f89

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

compiler/rustc_expand/src/mbe/quoted.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ pub(super) fn parse(
6262
match tree {
6363
TokenTree::MetaVar(start_sp, ident) if parsing_patterns => {
6464
let span = match trees.next() {
65-
Some(&tokenstream::TokenTree::Token(Token { kind: token::Colon, span }, _)) => {
65+
Some(&tokenstream::TokenTree::Token(
66+
Token { kind: token::Colon, span: colon_span },
67+
_,
68+
)) => {
6669
match trees.next() {
6770
Some(tokenstream::TokenTree::Token(token, _)) => match token.ident() {
6871
Some((fragment, _)) => {
@@ -126,10 +129,12 @@ pub(super) fn parse(
126129
}
127130
_ => token.span,
128131
},
129-
tree => tree.map_or(span, tokenstream::TokenTree::span),
132+
Some(tree) => tree.span(),
133+
None => colon_span,
130134
}
131135
}
132-
tree => tree.map_or(start_sp, tokenstream::TokenTree::span),
136+
Some(tree) => tree.span(),
137+
None => start_sp,
133138
};
134139

135140
result.push(TokenTree::MetaVarDecl(span, ident, None));

0 commit comments

Comments
 (0)