aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs45
1 files changed, 1 insertions, 44 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index a3b65cc79..499dcafea 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -50,16 +50,6 @@ impl HirFileId {
50 } 50 }
51 } 51 }
52 52
53 /// XXX: this is a temporary function, which should go away when we implement the
54 /// nameresolution+macro expansion combo. Prefer using `original_file` if
55 /// possible.
56 pub fn as_original_file(self) -> FileId {
57 match self.0 {
58 HirFileIdRepr::File(file_id) => file_id,
59 HirFileIdRepr::Macro(_r) => panic!("macro generated file: {:?}", self),
60 }
61 }
62
63 /// Get the crate which the macro lives in, if it is a macro file. 53 /// Get the crate which the macro lives in, if it is a macro file.
64 pub(crate) fn macro_crate(self, db: &impl AstDatabase) -> Option<Crate> { 54 pub(crate) fn macro_crate(self, db: &impl AstDatabase) -> Option<Crate> {
65 match self.0 { 55 match self.0 {
@@ -95,11 +85,7 @@ impl HirFileId {
95 // Note: 85 // Note:
96 // The final goal we would like to make all parse_macro success, 86 // The final goal we would like to make all parse_macro success,
97 // such that the following log will not call anyway. 87 // such that the following log will not call anyway.
98 log::warn!( 88 log::warn!("fail on macro_parse: (reason: {})", err,);
99 "fail on macro_parse: (reason: {}) {}",
100 err,
101 macro_call_id.debug_dump(db)
102 );
103 }) 89 })
104 .ok()?; 90 .ok()?;
105 match macro_file.macro_file_kind { 91 match macro_file.macro_file_kind {
@@ -377,35 +363,6 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId {
377 } 363 }
378} 364}
379 365
380impl MacroCallId {
381 pub fn debug_dump(self, db: &impl AstDatabase) -> String {
382 let loc = self.loc(db);
383 let node = loc.ast_id.to_node(db);
384 let syntax_str = {
385 let mut res = String::new();
386 node.syntax().text().for_each_chunk(|chunk| {
387 if !res.is_empty() {
388 res.push(' ')
389 }
390 res.push_str(chunk)
391 });
392 res
393 };
394
395 // dump the file name
396 let file_id: HirFileId = self.loc(db).ast_id.file_id();
397 let original = file_id.original_file(db);
398 let macro_rules = db.macro_def(loc.def);
399
400 format!(
401 "macro call [file: {:?}] : {}\nhas rules: {}",
402 db.file_relative_path(original),
403 syntax_str,
404 macro_rules.is_some()
405 )
406 }
407}
408
409/// This exists just for Chalk, because Chalk just has a single `StructId` where 366/// This exists just for Chalk, because Chalk just has a single `StructId` where
410/// we have different kinds of ADTs, primitive types and special type 367/// we have different kinds of ADTs, primitive types and special type
411/// constructors like tuples and function pointers. 368/// constructors like tuples and function pointers.