aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_expand
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_expand')
-rw-r--r--crates/hir_expand/src/builtin_macro.rs25
-rw-r--r--crates/hir_expand/src/name.rs3
2 files changed, 28 insertions, 0 deletions
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index 477192a09..b1b432ded 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -88,12 +88,15 @@ register_builtin! {
88 (column, Column) => column_expand, 88 (column, Column) => column_expand,
89 (file, File) => file_expand, 89 (file, File) => file_expand,
90 (line, Line) => line_expand, 90 (line, Line) => line_expand,
91 (module_path, ModulePath) => module_path_expand,
91 (assert, Assert) => assert_expand, 92 (assert, Assert) => assert_expand,
92 (stringify, Stringify) => stringify_expand, 93 (stringify, Stringify) => stringify_expand,
93 (format_args, FormatArgs) => format_args_expand, 94 (format_args, FormatArgs) => format_args_expand,
94 // format_args_nl only differs in that it adds a newline in the end, 95 // format_args_nl only differs in that it adds a newline in the end,
95 // so we use the same stub expansion for now 96 // so we use the same stub expansion for now
96 (format_args_nl, FormatArgsNl) => format_args_expand, 97 (format_args_nl, FormatArgsNl) => format_args_expand,
98 (llvm_asm, LlvmAsm) => asm_expand,
99 (asm, Asm) => asm_expand,
97 100
98 EAGER: 101 EAGER:
99 (compile_error, CompileError) => compile_error_expand, 102 (compile_error, CompileError) => compile_error_expand,
@@ -105,6 +108,15 @@ register_builtin! {
105 (option_env, OptionEnv) => option_env_expand 108 (option_env, OptionEnv) => option_env_expand
106} 109}
107 110
111fn module_path_expand(
112 _db: &dyn AstDatabase,
113 _id: LazyMacroId,
114 _tt: &tt::Subtree,
115) -> ExpandResult<tt::Subtree> {
116 // Just return a dummy result.
117 ExpandResult::ok(quote! { "module::path" })
118}
119
108fn line_expand( 120fn line_expand(
109 _db: &dyn AstDatabase, 121 _db: &dyn AstDatabase,
110 _id: LazyMacroId, 122 _id: LazyMacroId,
@@ -261,6 +273,19 @@ fn format_args_expand(
261 ExpandResult::ok(expanded) 273 ExpandResult::ok(expanded)
262} 274}
263 275
276fn asm_expand(
277 _db: &dyn AstDatabase,
278 _id: LazyMacroId,
279 _tt: &tt::Subtree,
280) -> ExpandResult<tt::Subtree> {
281 // both asm and llvm_asm don't return anything, so we can expand them to nothing,
282 // for now
283 let expanded = quote! {
284 ()
285 };
286 ExpandResult::ok(expanded)
287}
288
264fn unquote_str(lit: &tt::Literal) -> Option<String> { 289fn unquote_str(lit: &tt::Literal) -> Option<String> {
265 let lit = ast::make::tokens::literal(&lit.to_string()); 290 let lit = ast::make::tokens::literal(&lit.to_string());
266 let token = ast::String::cast(lit)?; 291 let token = ast::String::cast(lit)?;
diff --git a/crates/hir_expand/src/name.rs b/crates/hir_expand/src/name.rs
index 583ed6142..69d8e6803 100644
--- a/crates/hir_expand/src/name.rs
+++ b/crates/hir_expand/src/name.rs
@@ -188,6 +188,7 @@ pub mod known {
188 column, 188 column,
189 compile_error, 189 compile_error,
190 line, 190 line,
191 module_path,
191 assert, 192 assert,
192 stringify, 193 stringify,
193 concat, 194 concat,
@@ -198,6 +199,8 @@ pub mod known {
198 format_args_nl, 199 format_args_nl,
199 env, 200 env,
200 option_env, 201 option_env,
202 llvm_asm,
203 asm,
201 // Builtin derives 204 // Builtin derives
202 Copy, 205 Copy,
203 Clone, 206 Clone,