aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_expand/src/builtin_macro.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index 80b60d59f..2806842cd 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -327,17 +327,12 @@ fn concat_expand(
327 // concat works with string and char literals, so remove any quotes. 327 // concat works with string and char literals, so remove any quotes.
328 // It also works with integer, float and boolean literals, so just use the rest 328 // It also works with integer, float and boolean literals, so just use the rest
329 // as-is. 329 // as-is.
330 330 let component = unquote_str(&it).unwrap_or_else(|| it.text.to_string());
331 text += it 331 text.push_str(&component);
332 .text 332 }
333 .trim_start_matches(|c| match c { 333 // handle boolean literals
334 'r' | '#' | '\'' | '"' => true, 334 tt::TokenTree::Leaf(tt::Leaf::Ident(id)) if i % 2 == 0 => {
335 _ => false, 335 text.push_str(id.text.as_str());
336 })
337 .trim_end_matches(|c| match c {
338 '#' | '\'' | '"' => true,
339 _ => false,
340 });
341 } 336 }
342 tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if i % 2 == 1 && punct.char == ',' => (), 337 tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) if i % 2 == 1 && punct.char == ',' => (),
343 _ => { 338 _ => {
@@ -345,7 +340,6 @@ fn concat_expand(
345 } 340 }
346 } 341 }
347 } 342 }
348
349 ExpandResult { value: Some((quote!(#text), FragmentKind::Expr)), err } 343 ExpandResult { value: Some((quote!(#text), FragmentKind::Expr)), err }
350} 344}
351 345
@@ -745,12 +739,10 @@ mod tests {
745 r##" 739 r##"
746 #[rustc_builtin_macro] 740 #[rustc_builtin_macro]
747 macro_rules! concat {} 741 macro_rules! concat {}
748 concat!("foo", 0, r#"bar"#); 742 concat!("foo", r, 0, r#"bar"#, false);
749 "##, 743 "##,
750 ); 744 );
751 745
752 assert_eq!(expanded, r#""foo0bar""#); 746 assert_eq!(expanded, r#""foor0barfalse""#);
753
754 // FIXME: `true`/`false` literals don't work.
755 } 747 }
756} 748}