From 0a0e22235b7ad222be1aaa7765b580f4096c9aeb Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Sat, 20 Mar 2021 12:18:57 -0600 Subject: Make bare underscore token an Ident rather than Punct in proc-macro --- crates/proc_macro_srv/src/rustc_server.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'crates/proc_macro_srv/src') diff --git a/crates/proc_macro_srv/src/rustc_server.rs b/crates/proc_macro_srv/src/rustc_server.rs index ceefd187d..c147484c0 100644 --- a/crates/proc_macro_srv/src/rustc_server.rs +++ b/crates/proc_macro_srv/src/rustc_server.rs @@ -805,5 +805,14 @@ mod tests { let t2 = TokenStream::from_str("(a);").unwrap(); assert_eq!(t2.token_trees.len(), 2); assert_eq!(t2.token_trees[0], subtree_paren_a); + + let underscore = TokenStream::from_str("_").unwrap(); + assert_eq!( + underscore.token_trees[0], + tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident { + text: "_".into(), + id: tt::TokenId::unspecified(), + })) + ); } } -- cgit v1.2.3