Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/expand_macro.rs')
-rw-r--r--crates/ide/src/expand_macro.rs30
1 files changed, 27 insertions, 3 deletions
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs
index 1ead045788..4b54c057bf 100644
--- a/crates/ide/src/expand_macro.rs
+++ b/crates/ide/src/expand_macro.rs
@@ -111,9 +111,10 @@ fn expand_macro_recur(
macro_call: &ast::Item,
) -> Option<SyntaxNode> {
let expanded = match macro_call {
- item @ ast::Item::MacroCall(macro_call) => {
- sema.expand_attr_macro(item).or_else(|| sema.expand(macro_call))?.clone_for_update()
- }
+ item @ ast::Item::MacroCall(macro_call) => sema
+ .expand_attr_macro(item)
+ .or_else(|| sema.expand_allowed_builtins(macro_call))?
+ .clone_for_update(),
item => sema.expand_attr_macro(item)?.clone_for_update(),
};
expand(sema, expanded)
@@ -229,6 +230,29 @@ mod tests {
}
#[test]
+ fn expand_allowed_builtin_macro() {
+ check(
+ r#"
+//- minicore: concat
+$0concat!("test", 10, 'b', true);"#,
+ expect![[r#"
+ concat!
+ "test10btrue""#]],
+ );
+ }
+
+ #[test]
+ fn do_not_expand_disallowed_macro() {
+ let (analysis, pos) = fixture::position(
+ r#"
+//- minicore: asm
+$0asm!("0x300, x0");"#,
+ );
+ let expansion = analysis.expand_macro(pos).unwrap();
+ assert!(expansion.is_none());
+ }
+
+ #[test]
fn macro_expand_as_keyword() {
check(
r#"