aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2021-01-25 11:30:55 +0000
committerLaurenČ›iu Nicola <[email protected]>2021-01-25 11:31:03 +0000
commit4e92681aba42aa50a832ec3be547b31a9bbf20e1 (patch)
tree5194767f2edc5c7a92fa7809dcf9f6376860a121 /crates
parent6362b399ad321d8bece357b703e5455de3850e76 (diff)
Disallow non-boolean literals in concat!
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_expand/src/builtin_macro.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index 2806842cd..57bc6fbd7 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -331,7 +331,9 @@ fn concat_expand(
331 text.push_str(&component); 331 text.push_str(&component);
332 } 332 }
333 // handle boolean literals 333 // handle boolean literals
334 tt::TokenTree::Leaf(tt::Leaf::Ident(id)) if i % 2 == 0 => { 334 tt::TokenTree::Leaf(tt::Leaf::Ident(id))
335 if i % 2 == 0 && (id.text == "true" || id.text == "false") =>
336 {
335 text.push_str(id.text.as_str()); 337 text.push_str(id.text.as_str());
336 } 338 }
337 tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if i % 2 == 1 && punct.char == ',' => (), 339 tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if i % 2 == 1 && punct.char == ',' => (),
@@ -739,7 +741,7 @@ mod tests {
739 r##" 741 r##"
740 #[rustc_builtin_macro] 742 #[rustc_builtin_macro]
741 macro_rules! concat {} 743 macro_rules! concat {}
742 concat!("foo", r, 0, r#"bar"#, false); 744 concat!("foo", "r", 0, r#"bar"#, false);
743 "##, 745 "##,
744 ); 746 );
745 747