aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_expand/src/builtin_macro.rs19
-rw-r--r--crates/ra_hir_expand/src/name.rs2
2 files changed, 20 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs
index 35f99b2bc..e0709704a 100644
--- a/crates/ra_hir_expand/src/builtin_macro.rs
+++ b/crates/ra_hir_expand/src/builtin_macro.rs
@@ -49,7 +49,11 @@ register_builtin! {
49 (COMPILE_ERROR_MACRO, CompileError) => compile_error_expand, 49 (COMPILE_ERROR_MACRO, CompileError) => compile_error_expand,
50 (FILE_MACRO, File) => file_expand, 50 (FILE_MACRO, File) => file_expand,
51 (LINE_MACRO, Line) => line_expand, 51 (LINE_MACRO, Line) => line_expand,
52 (STRINGIFY_MACRO, Stringify) => stringify_expand 52 (STRINGIFY_MACRO, Stringify) => stringify_expand,
53 (FORMAT_ARGS_MACRO, FormatArgs) => format_args_expand,
54 // format_args_nl only differs in that it adds a newline in the end,
55 // so we use the same stub expansion for now
56 (FORMAT_ARGS_NL_MACRO, FormatArgsNl) => format_args_expand
53} 57}
54 58
55fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize { 59fn to_line_number(db: &dyn AstDatabase, file: HirFileId, pos: TextUnit) -> usize {
@@ -200,6 +204,19 @@ fn compile_error_expand(
200 Err(mbe::ExpandError::BindingError("Must be a string".into())) 204 Err(mbe::ExpandError::BindingError("Must be a string".into()))
201} 205}
202 206
207fn format_args_expand(
208 _db: &dyn AstDatabase,
209 _id: MacroCallId,
210 _tt: &tt::Subtree,
211) -> Result<tt::Subtree, mbe::ExpandError> {
212 // FIXME this is just a stub to make format macros type-check without mismatches
213 // We should make this at least insert the arguments, so that go to def etc. work within format macros
214 let expanded = quote! {
215 std::fmt::Arguments::new_v1(&[], &[])
216 };
217 Ok(expanded)
218}
219
203#[cfg(test)] 220#[cfg(test)]
204mod tests { 221mod tests {
205 use super::*; 222 use super::*;
diff --git a/crates/ra_hir_expand/src/name.rs b/crates/ra_hir_expand/src/name.rs
index c5a191160..34edf2003 100644
--- a/crates/ra_hir_expand/src/name.rs
+++ b/crates/ra_hir_expand/src/name.rs
@@ -159,6 +159,8 @@ pub const COLUMN_MACRO: Name = Name::new_inline_ascii(6, b"column");
159pub const COMPILE_ERROR_MACRO: Name = Name::new_inline_ascii(13, b"compile_error"); 159pub const COMPILE_ERROR_MACRO: Name = Name::new_inline_ascii(13, b"compile_error");
160pub const LINE_MACRO: Name = Name::new_inline_ascii(4, b"line"); 160pub const LINE_MACRO: Name = Name::new_inline_ascii(4, b"line");
161pub const STRINGIFY_MACRO: Name = Name::new_inline_ascii(9, b"stringify"); 161pub const STRINGIFY_MACRO: Name = Name::new_inline_ascii(9, b"stringify");
162pub const FORMAT_ARGS_MACRO: Name = Name::new_inline_ascii(11, b"format_args");
163pub const FORMAT_ARGS_NL_MACRO: Name = Name::new_inline_ascii(14, b"format_args_nl");
162 164
163// Builtin derives 165// Builtin derives
164pub const COPY_TRAIT: Name = Name::new_inline_ascii(4, b"Copy"); 166pub const COPY_TRAIT: Name = Name::new_inline_ascii(4, b"Copy");