diff options
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/diagnostics.rs | 24 | ||||
-rw-r--r-- | crates/hir/src/display.rs | 4 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 30 |
3 files changed, 47 insertions, 11 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 22ec7c6ac..2cdbd172a 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -227,3 +227,27 @@ impl Diagnostic for MacroError { | |||
227 | true | 227 | true |
228 | } | 228 | } |
229 | } | 229 | } |
230 | |||
231 | #[derive(Debug)] | ||
232 | pub struct UnimplementedBuiltinMacro { | ||
233 | pub file: HirFileId, | ||
234 | pub node: SyntaxNodePtr, | ||
235 | } | ||
236 | |||
237 | impl Diagnostic for UnimplementedBuiltinMacro { | ||
238 | fn code(&self) -> DiagnosticCode { | ||
239 | DiagnosticCode("unimplemented-builtin-macro") | ||
240 | } | ||
241 | |||
242 | fn message(&self) -> String { | ||
243 | "unimplemented built-in macro".to_string() | ||
244 | } | ||
245 | |||
246 | fn display_source(&self) -> InFile<SyntaxNodePtr> { | ||
247 | InFile::new(self.file, self.node.clone()) | ||
248 | } | ||
249 | |||
250 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | ||
251 | self | ||
252 | } | ||
253 | } | ||
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index c5cf803fd..72f0d9b5f 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs | |||
@@ -427,10 +427,6 @@ impl HirDisplay for Trait { | |||
427 | write!(f, "trait {}", data.name)?; | 427 | write!(f, "trait {}", data.name)?; |
428 | let def_id = GenericDefId::TraitId(self.id); | 428 | let def_id = GenericDefId::TraitId(self.id); |
429 | write_generic_params(def_id, f)?; | 429 | write_generic_params(def_id, f)?; |
430 | if !data.bounds.is_empty() { | ||
431 | write!(f, ": ")?; | ||
432 | f.write_joined(&*data.bounds, " + ")?; | ||
433 | } | ||
434 | write_where_clause(def_id, f)?; | 430 | write_where_clause(def_id, f)?; |
435 | Ok(()) | 431 | Ok(()) |
436 | } | 432 | } |
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 | } |