From 26e1f7696ae3903f868e50409fb7ee70ee37d6db Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sun, 27 Dec 2020 23:51:00 +0800 Subject: Ignore third punct in 2-composite punct --- crates/mbe/src/mbe_expander/matcher.rs | 40 +++++++++++++++++----------------- crates/mbe/src/tests.rs | 16 ++++++++++++++ 2 files changed, 36 insertions(+), 20 deletions(-) (limited to 'crates') diff --git a/crates/mbe/src/mbe_expander/matcher.rs b/crates/mbe/src/mbe_expander/matcher.rs index 7aeef7be5..44722c0f1 100644 --- a/crates/mbe/src/mbe_expander/matcher.rs +++ b/crates/mbe/src/mbe_expander/matcher.rs @@ -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()) } diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 451fa1456..6cd0ed205 100644 --- a/crates/mbe/src/tests.rs +++ b/crates/mbe/src/tests.rs @@ -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( -- cgit v1.2.3