]> git.lizzy.rs Git - rust.git/blobdiff - crates/hir_expand/src/lib.rs
Merge #11182
[rust.git] / crates / hir_expand / src / lib.rs
index b455fd59172a76e971e1139c4ff697583cd7260b..51899ca2f65b0ab612b3c32bdfec694dfe9afef4 100644 (file)
 pub mod proc_macro;
 pub mod quote;
 pub mod eager;
+pub mod mod_path;
 
 use base_db::ProcMacroKind;
 use either::Either;
 
 pub use mbe::{ExpandError, ExpandResult, Origin};
+use mod_path::ModPath;
 
 use std::{hash::Hash, iter, sync::Arc};
 
@@ -203,7 +205,7 @@ pub fn expansion_info(self, db: &dyn db::AstDatabase) -> Option<ExpansionInfo> {
                             .to_node(db)
                             .doc_comments_and_attrs()
                             .nth(invoc_attr_index as usize)
-                            .and_then(Either::right)?
+                            .and_then(Either::left)?
                             .token_tree()?;
                         Some(InFile::new(ast_id.file_id, tt))
                     }
@@ -380,7 +382,7 @@ pub fn original_call_range(self, db: &dyn db::AstDatabase) -> FileRange {
                     .doc_comments_and_attrs()
                     .nth(derive_attr_index as usize)
                     .expect("missing derive")
-                    .expect_right("derive is a doc comment?")
+                    .expect_left("derive is a doc comment?")
                     .syntax()
                     .text_range()
             }
@@ -389,7 +391,7 @@ pub fn original_call_range(self, db: &dyn db::AstDatabase) -> FileRange {
                 .doc_comments_and_attrs()
                 .nth(invoc_attr_index as usize)
                 .expect("missing attribute")
-                .expect_right("attribute macro is a doc comment?")
+                .expect_left("attribute macro is a doc comment?")
                 .syntax()
                 .text_range(),
         };
@@ -481,7 +483,7 @@ pub fn map_token_down(
                     let attr = item
                         .doc_comments_and_attrs()
                         .nth(*invoc_attr_index as usize)
-                        .and_then(Either::right)?;
+                        .and_then(Either::left)?;
                     match attr.token_tree() {
                         Some(token_tree)
                             if token_tree.syntax().text_range().contains_range(token_range) =>
@@ -835,3 +837,8 @@ pub fn from_call_site(call: &ast::MacroCall) -> ExpandTo {
         }
     }
 }
+
+#[derive(Debug)]
+pub struct UnresolvedMacro {
+    pub path: ModPath,
+}