Skip to content

Commit

Permalink
Merge #7050
Browse files Browse the repository at this point in the history
7050: Ignore third punct when matching for 2-composite punct in mbe r=jonas-schievink a=edwin0cheng

Fixes #6692



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
  • Loading branch information
bors[bot] and edwin0cheng committed Dec 27, 2020
2 parents 8f26221 + 26e1f76 commit 1d53075
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
40 changes: 20 additions & 20 deletions crates/mbe/src/mbe_expander/matcher.rs
Expand Up @@ -240,26 +240,26 @@ impl<'a> TtIter<'a> {
let tt3 = self.next().unwrap().clone();
Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into())
}
('-', '=', None)
| ('-', '>', None)
| (':', ':', None)
| ('!', '=', None)
| ('.', '.', None)
| ('*', '=', None)
| ('/', '=', None)
| ('&', '&', None)
| ('&', '=', None)
| ('%', '=', None)
| ('^', '=', None)
| ('+', '=', None)
| ('<', '<', None)
| ('<', '=', None)
| ('=', '=', None)
| ('=', '>', None)
| ('>', '=', None)
| ('>', '>', None)
| ('|', '=', None)
| ('|', '|', None) => {
('-', '=', _)
| ('-', '>', _)
| (':', ':', _)
| ('!', '=', _)
| ('.', '.', _)
| ('*', '=', _)
| ('/', '=', _)
| ('&', '&', _)
| ('&', '=', _)
| ('%', '=', _)
| ('^', '=', _)
| ('+', '=', _)
| ('<', '<', _)
| ('<', '=', _)
| ('=', '=', _)
| ('=', '>', _)
| ('>', '=', _)
| ('>', '>', _)
| ('|', '=', _)
| ('|', '|', _) => {
let tt2 = self.next().unwrap().clone();
Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into())
}
Expand Down
16 changes: 16 additions & 0 deletions crates/mbe/src/tests.rs
Expand Up @@ -991,6 +991,22 @@ fn test_tt_composite2() {
);
}

#[test]
fn test_tt_with_composite_without_space() {
parse_macro(
r#"
macro_rules! foo {
($ op:tt, $j:path) => (
0
)
}
"#,
)
// Test macro input without any spaces
// See https://github.com/rust-analyzer/rust-analyzer/issues/6692
.assert_expand_items("foo!(==,Foo::Bool)", "0");
}

#[test]
fn test_underscore() {
parse_macro(
Expand Down

0 comments on commit 1d53075

Please sign in to comment.