Convert bool to ident instead of literal in mbe

This commit is contained in:
Edwin Cheng 2020-04-19 03:24:17 +08:00
parent b949500126
commit a1b5cf81eb
5 changed files with 47 additions and 14 deletions

View file

@ -1015,6 +1015,36 @@ fn test_literal() {
.assert_expand_items(r#"foo!(u8 0);"#, r#"const VALUE : u8 = 0 ;"#);
}
#[test]
fn test_boolean_is_ident() {
parse_macro(
r#"
macro_rules! foo {
($lit0:literal, $lit1:literal) => { const VALUE: (bool,bool) = ($lit0,$lit1); };
}
"#,
)
.assert_expand(
r#"foo!(true,false);"#,
r#"
SUBTREE $
IDENT const 14
IDENT VALUE 15
PUNCH : [alone] 16
SUBTREE () 17
IDENT bool 18
PUNCH , [alone] 19
IDENT bool 20
PUNCH = [alone] 21
SUBTREE () 22
IDENT true 29
PUNCH , [joint] 25
IDENT false 31
PUNCH ; [alone] 28
"#,
);
}
#[test]
fn test_vis() {
parse_macro(