diff options
author | Edwin Cheng <[email protected]> | 2020-12-27 15:51:00 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-12-27 15:51:00 +0000 |
commit | 26e1f7696ae3903f868e50409fb7ee70ee37d6db (patch) | |
tree | 09c722506b0f5bd254e0fe0a2684bed861874d4d /crates/mbe/src | |
parent | 0fd75c98ac81c9f6581712ec8802940e547315e3 (diff) |
Ignore third punct in 2-composite punct
Diffstat (limited to 'crates/mbe/src')
-rw-r--r-- | crates/mbe/src/mbe_expander/matcher.rs | 40 | ||||
-rw-r--r-- | crates/mbe/src/tests.rs | 16 |
2 files changed, 36 insertions, 20 deletions
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> { | |||
240 | let tt3 = self.next().unwrap().clone(); | 240 | let tt3 = self.next().unwrap().clone(); |
241 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into()) | 241 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2, tt3] }.into()) |
242 | } | 242 | } |
243 | ('-', '=', None) | 243 | ('-', '=', _) |
244 | | ('-', '>', None) | 244 | | ('-', '>', _) |
245 | | (':', ':', None) | 245 | | (':', ':', _) |
246 | | ('!', '=', None) | 246 | | ('!', '=', _) |
247 | | ('.', '.', None) | 247 | | ('.', '.', _) |
248 | | ('*', '=', None) | 248 | | ('*', '=', _) |
249 | | ('/', '=', None) | 249 | | ('/', '=', _) |
250 | | ('&', '&', None) | 250 | | ('&', '&', _) |
251 | | ('&', '=', None) | 251 | | ('&', '=', _) |
252 | | ('%', '=', None) | 252 | | ('%', '=', _) |
253 | | ('^', '=', None) | 253 | | ('^', '=', _) |
254 | | ('+', '=', None) | 254 | | ('+', '=', _) |
255 | | ('<', '<', None) | 255 | | ('<', '<', _) |
256 | | ('<', '=', None) | 256 | | ('<', '=', _) |
257 | | ('=', '=', None) | 257 | | ('=', '=', _) |
258 | | ('=', '>', None) | 258 | | ('=', '>', _) |
259 | | ('>', '=', None) | 259 | | ('>', '=', _) |
260 | | ('>', '>', None) | 260 | | ('>', '>', _) |
261 | | ('|', '=', None) | 261 | | ('|', '=', _) |
262 | | ('|', '|', None) => { | 262 | | ('|', '|', _) => { |
263 | let tt2 = self.next().unwrap().clone(); | 263 | let tt2 = self.next().unwrap().clone(); |
264 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into()) | 264 | Ok(tt::Subtree { delimiter: None, token_trees: vec![tt, tt2] }.into()) |
265 | } | 265 | } |
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 | |||
@@ -992,6 +992,22 @@ fn test_tt_composite2() { | |||
992 | } | 992 | } |
993 | 993 | ||
994 | #[test] | 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 | |||
1010 | #[test] | ||
995 | fn test_underscore() { | 1011 | fn test_underscore() { |
996 | parse_macro( | 1012 | parse_macro( |
997 | r#" | 1013 | r#" |