diff options
Diffstat (limited to 'crates/mbe/src/syntax_bridge.rs')
-rw-r--r-- | crates/mbe/src/syntax_bridge.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index 85163c4b3..9d433b3b0 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs | |||
@@ -350,7 +350,7 @@ trait TokenConvertor { | |||
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | 352 | ||
353 | result.push(if k.is_punct() { | 353 | result.push(if k.is_punct() && k != UNDERSCORE { |
354 | assert_eq!(range.len(), TextSize::of('.')); | 354 | assert_eq!(range.len(), TextSize::of('.')); |
355 | let delim = match k { | 355 | let delim = match k { |
356 | T!['('] => Some((tt::DelimiterKind::Parenthesis, T![')'])), | 356 | T!['('] => Some((tt::DelimiterKind::Parenthesis, T![')'])), |
@@ -362,7 +362,7 @@ trait TokenConvertor { | |||
362 | if let Some((kind, closed)) = delim { | 362 | if let Some((kind, closed)) = delim { |
363 | let mut subtree = tt::Subtree::default(); | 363 | let mut subtree = tt::Subtree::default(); |
364 | let (id, idx) = self.id_alloc().open_delim(range); | 364 | let (id, idx) = self.id_alloc().open_delim(range); |
365 | subtree.delimiter = Some(tt::Delimiter { kind, id }); | 365 | subtree.delimiter = Some(tt::Delimiter { id, kind }); |
366 | 366 | ||
367 | while self.peek().map(|it| it.kind() != closed).unwrap_or(false) { | 367 | while self.peek().map(|it| it.kind() != closed).unwrap_or(false) { |
368 | self.collect_leaf(&mut subtree.token_trees); | 368 | self.collect_leaf(&mut subtree.token_trees); |
@@ -395,7 +395,9 @@ trait TokenConvertor { | |||
395 | { | 395 | { |
396 | tt::Spacing::Alone | 396 | tt::Spacing::Alone |
397 | } | 397 | } |
398 | Some(next) if next.kind().is_punct() => tt::Spacing::Joint, | 398 | Some(next) if next.kind().is_punct() && next.kind() != UNDERSCORE => { |
399 | tt::Spacing::Joint | ||
400 | } | ||
399 | _ => tt::Spacing::Alone, | 401 | _ => tt::Spacing::Alone, |
400 | }; | 402 | }; |
401 | let char = match token.to_char() { | 403 | let char = match token.to_char() { |
@@ -415,6 +417,7 @@ trait TokenConvertor { | |||
415 | let leaf: tt::Leaf = match k { | 417 | let leaf: tt::Leaf = match k { |
416 | T![true] | T![false] => make_leaf!(Ident), | 418 | T![true] | T![false] => make_leaf!(Ident), |
417 | IDENT => make_leaf!(Ident), | 419 | IDENT => make_leaf!(Ident), |
420 | UNDERSCORE => make_leaf!(Ident), | ||
418 | k if k.is_keyword() => make_leaf!(Ident), | 421 | k if k.is_keyword() => make_leaf!(Ident), |
419 | k if k.is_literal() => make_leaf!(Literal), | 422 | k if k.is_literal() => make_leaf!(Literal), |
420 | LIFETIME_IDENT => { | 423 | LIFETIME_IDENT => { |