Skip to content

Commit 1d53075

Browse files
Merge #7050
7050: Ignore third punct when matching for 2-composite punct in mbe r=jonas-schievink a=edwin0cheng Fixes #6692 Co-authored-by: Edwin Cheng <[email protected]>
2 parents 8f26221 + 26e1f76 commit 1d53075

File tree

2 files changed

+36
-20
lines changed

2 files changed

+36
-20
lines changed

crates/mbe/src/mbe_expander/matcher.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,26 +240,26 @@ impl<'a> TtIter<'a> {
240240
let tt3 = self.next().unwrap().clone();
241241
Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into())
242242
}
243-
('-', '=', None)
244-
| ('-', '>', None)
245-
| (':', ':', None)
246-
| ('!', '=', None)
247-
| ('.', '.', None)
248-
| ('*', '=', None)
249-
| ('/', '=', None)
250-
| ('&', '&', None)
251-
| ('&', '=', None)
252-
| ('%', '=', None)
253-
| ('^', '=', None)
254-
| ('+', '=', None)
255-
| ('<', '<', None)
256-
| ('<', '=', None)
257-
| ('=', '=', None)
258-
| ('=', '>', None)
259-
| ('>', '=', None)
260-
| ('>', '>', None)
261-
| ('|', '=', None)
262-
| ('|', '|', None) => {
243+
('-', '=', _)
244+
| ('-', '>', _)
245+
| (':', ':', _)
246+
| ('!', '=', _)
247+
| ('.', '.', _)
248+
| ('*', '=', _)
249+
| ('/', '=', _)
250+
| ('&', '&', _)
251+
| ('&', '=', _)
252+
| ('%', '=', _)
253+
| ('^', '=', _)
254+
| ('+', '=', _)
255+
| ('<', '<', _)
256+
| ('<', '=', _)
257+
| ('=', '=', _)
258+
| ('=', '>', _)
259+
| ('>', '=', _)
260+
| ('>', '>', _)
261+
| ('|', '=', _)
262+
| ('|', '|', _) => {
263263
let tt2 = self.next().unwrap().clone();
264264
Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into())
265265
}

crates/mbe/src/tests.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,22 @@ fn test_tt_composite2() {
991991
);
992992
}
993993

994+
#[test]
995+
fn test_tt_with_composite_without_space() {
996+
parse_macro(
997+
r#"
998+
macro_rules! foo {
999+
($ op:tt, $j:path) => (
1000+
0
1001+
)
1002+
}
1003+
"#,
1004+
)
1005+
// Test macro input without any spaces
1006+
// See https://github.com/rust-analyzer/rust-analyzer/issues/6692
1007+
.assert_expand_items("foo!(==,Foo::Bool)", "0");
1008+
}
1009+
9941010
#[test]
9951011
fn test_underscore() {
9961012
parse_macro(

0 commit comments

Comments
 (0)