diff options
Diffstat (limited to 'crates/hir_expand')
-rw-r--r-- | crates/hir_expand/src/builtin_macro.rs | 26 | ||||
-rw-r--r-- | crates/hir_expand/src/name.rs | 3 |
2 files changed, 13 insertions, 16 deletions
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs index 80b60d59f..57bc6fbd7 100644 --- a/crates/hir_expand/src/builtin_macro.rs +++ b/crates/hir_expand/src/builtin_macro.rs | |||
@@ -327,17 +327,14 @@ 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)) |
335 | _ => false, | 335 | if i % 2 == 0 && (id.text == "true" || id.text == "false") => |
336 | }) | 336 | { |
337 | .trim_end_matches(|c| match c { | 337 | text.push_str(id.text.as_str()); |
338 | '#' | '\'' | '"' => true, | ||
339 | _ => false, | ||
340 | }); | ||
341 | } | 338 | } |
342 | 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 == ',' => (), |
343 | _ => { | 340 | _ => { |
@@ -345,7 +342,6 @@ fn concat_expand( | |||
345 | } | 342 | } |
346 | } | 343 | } |
347 | } | 344 | } |
348 | |||
349 | ExpandResult { value: Some((quote!(#text), FragmentKind::Expr)), err } | 345 | ExpandResult { value: Some((quote!(#text), FragmentKind::Expr)), err } |
350 | } | 346 | } |
351 | 347 | ||
@@ -745,12 +741,10 @@ mod tests { | |||
745 | r##" | 741 | r##" |
746 | #[rustc_builtin_macro] | 742 | #[rustc_builtin_macro] |
747 | macro_rules! concat {} | 743 | macro_rules! concat {} |
748 | concat!("foo", 0, r#"bar"#); | 744 | concat!("foo", "r", 0, r#"bar"#, false); |
749 | "##, | 745 | "##, |
750 | ); | 746 | ); |
751 | 747 | ||
752 | assert_eq!(expanded, r#""foo0bar""#); | 748 | assert_eq!(expanded, r#""foor0barfalse""#); |
753 | |||
754 | // FIXME: `true`/`false` literals don't work. | ||
755 | } | 749 | } |
756 | } | 750 | } |
diff --git a/crates/hir_expand/src/name.rs b/crates/hir_expand/src/name.rs index d692cec14..c7609e90d 100644 --- a/crates/hir_expand/src/name.rs +++ b/crates/hir_expand/src/name.rs | |||
@@ -186,6 +186,9 @@ pub mod known { | |||
186 | Neg, | 186 | Neg, |
187 | Not, | 187 | Not, |
188 | Index, | 188 | Index, |
189 | // Components of known path (function name) | ||
190 | filter_map, | ||
191 | next, | ||
189 | // Builtin macros | 192 | // Builtin macros |
190 | file, | 193 | file, |
191 | column, | 194 | column, |