diff options
Diffstat (limited to 'crates/hir/src/lib.rs')
-rw-r--r-- | crates/hir/src/lib.rs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 01b2de515..d3ef29db4 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -36,8 +36,8 @@ use std::{iter, sync::Arc}; | |||
36 | use arrayvec::ArrayVec; | 36 | use arrayvec::ArrayVec; |
37 | use base_db::{CrateDisplayName, CrateId, Edition, FileId}; | 37 | use base_db::{CrateDisplayName, CrateId, Edition, FileId}; |
38 | use diagnostics::{ | 38 | use diagnostics::{ |
39 | InactiveCode, MacroError, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, | 39 | InactiveCode, MacroError, UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, |
40 | UnresolvedModule, UnresolvedProcMacro, | 40 | UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro, |
41 | }; | 41 | }; |
42 | use either::Either; | 42 | use either::Either; |
43 | use hir_def::{ | 43 | use hir_def::{ |
@@ -565,6 +565,14 @@ impl Module { | |||
565 | }; | 565 | }; |
566 | sink.push(MacroError { file, node: ast, message: message.clone() }); | 566 | sink.push(MacroError { file, node: ast, message: message.clone() }); |
567 | } | 567 | } |
568 | |||
569 | DefDiagnosticKind::UnimplementedBuiltinMacro { ast } => { | ||
570 | let node = ast.to_node(db.upcast()); | ||
571 | // Must have a name, otherwise we wouldn't emit it. | ||
572 | let name = node.name().expect("unimplemented builtin macro with no name"); | ||
573 | let ptr = SyntaxNodePtr::from(AstPtr::new(&name)); | ||
574 | sink.push(UnimplementedBuiltinMacro { file: ast.file_id, node: ptr }); | ||
575 | } | ||
568 | } | 576 | } |
569 | } | 577 | } |
570 | for decl in self.declarations(db) { | 578 | for decl in self.declarations(db) { |
@@ -1282,10 +1290,16 @@ impl BuiltinType { | |||
1282 | 1290 | ||
1283 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 1291 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
1284 | pub enum MacroKind { | 1292 | pub enum MacroKind { |
1293 | /// `macro_rules!` or Macros 2.0 macro. | ||
1285 | Declarative, | 1294 | Declarative, |
1286 | ProcMacro, | 1295 | /// A built-in or custom derive. |
1287 | Derive, | 1296 | Derive, |
1297 | /// A built-in function-like macro. | ||
1288 | BuiltIn, | 1298 | BuiltIn, |
1299 | /// A procedural attribute macro. | ||
1300 | Attr, | ||
1301 | /// A function-like procedural macro. | ||
1302 | ProcMacro, | ||
1289 | } | 1303 | } |
1290 | 1304 | ||
1291 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 1305 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
@@ -1315,11 +1329,13 @@ impl MacroDef { | |||
1315 | pub fn kind(&self) -> MacroKind { | 1329 | pub fn kind(&self) -> MacroKind { |
1316 | match self.id.kind { | 1330 | match self.id.kind { |
1317 | MacroDefKind::Declarative(_) => MacroKind::Declarative, | 1331 | MacroDefKind::Declarative(_) => MacroKind::Declarative, |
1318 | MacroDefKind::BuiltIn(_, _) => MacroKind::BuiltIn, | 1332 | MacroDefKind::BuiltIn(_, _) | MacroDefKind::BuiltInEager(_, _) => MacroKind::BuiltIn, |
1319 | MacroDefKind::BuiltInDerive(_, _) => MacroKind::Derive, | 1333 | MacroDefKind::BuiltInDerive(_, _) => MacroKind::Derive, |
1320 | MacroDefKind::BuiltInEager(_, _) => MacroKind::BuiltIn, | 1334 | MacroDefKind::ProcMacro(_, base_db::ProcMacroKind::CustomDerive, _) => { |
1321 | // FIXME might be a derive | 1335 | MacroKind::Derive |
1322 | MacroDefKind::ProcMacro(_, _) => MacroKind::ProcMacro, | 1336 | } |
1337 | MacroDefKind::ProcMacro(_, base_db::ProcMacroKind::Attr, _) => MacroKind::Attr, | ||
1338 | MacroDefKind::ProcMacro(_, base_db::ProcMacroKind::FuncLike, _) => MacroKind::ProcMacro, | ||
1323 | } | 1339 | } |
1324 | } | 1340 | } |
1325 | } | 1341 | } |