diff options
Diffstat (limited to 'crates/ra_hir_expand/src/builtin_macro.rs')
-rw-r--r-- | crates/ra_hir_expand/src/builtin_macro.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs new file mode 100644 index 000000000..dca2f17ef --- /dev/null +++ b/crates/ra_hir_expand/src/builtin_macro.rs | |||
@@ -0,0 +1,26 @@ | |||
1 | //! Builtin macro | ||
2 | use crate::{ast, name, AstId, BuiltinMacro, CrateId, MacroDefId}; | ||
3 | |||
4 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
5 | pub enum BuiltinExpander { | ||
6 | Line | ||
7 | } | ||
8 | |||
9 | impl BuiltinExpander { | ||
10 | pub fn expand(&self, _tt: &tt::Subtree) -> Result<tt::Subtree, mbe::ExpandError> { | ||
11 | Err(mbe::ExpandError::UnexpectedToken) | ||
12 | } | ||
13 | } | ||
14 | |||
15 | pub fn find_builtin_macro( | ||
16 | ident: &name::Name, | ||
17 | krate: CrateId, | ||
18 | ast_id: AstId<ast::MacroCall>, | ||
19 | ) -> Option<MacroDefId> { | ||
20 | // FIXME: Better registering method | ||
21 | if ident == &name::LINE { | ||
22 | Some(MacroDefId::BuiltinMacro(BuiltinMacro { expander: BuiltinExpander::Line, krate, ast_id })) | ||
23 | } else { | ||
24 | None | ||
25 | } | ||
26 | } | ||