aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_expand/src/lib.rs7
-rw-r--r--crates/ide/src/annotations.rs15
2 files changed, 8 insertions, 14 deletions
diff --git a/crates/hir_expand/src/lib.rs b/crates/hir_expand/src/lib.rs
index d7391ebad..b8045fda9 100644
--- a/crates/hir_expand/src/lib.rs
+++ b/crates/hir_expand/src/lib.rs
@@ -207,13 +207,6 @@ impl HirFileId {
207 } 207 }
208 false 208 false
209 } 209 }
210
211 pub fn is_macro_file(&self) -> bool {
212 match self.0 {
213 HirFileIdRepr::MacroFile(_) => true,
214 HirFileIdRepr::FileId(_) => false,
215 }
216 }
217} 210}
218 211
219#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 212#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs
index 9e78ed6a0..64bc926f1 100644
--- a/crates/ide/src/annotations.rs
+++ b/crates/ide/src/annotations.rs
@@ -80,19 +80,19 @@ pub(crate) fn annotations(
80 Either::Left(def) => { 80 Either::Left(def) => {
81 let node = match def { 81 let node = match def {
82 hir::ModuleDef::Const(konst) => { 82 hir::ModuleDef::Const(konst) => {
83 konst.source(db).and_then(|node| range_and_position_of(&node)) 83 konst.source(db).and_then(|node| range_and_position_of(&node, file_id))
84 } 84 }
85 hir::ModuleDef::Trait(trait_) => { 85 hir::ModuleDef::Trait(trait_) => {
86 trait_.source(db).and_then(|node| range_and_position_of(&node)) 86 trait_.source(db).and_then(|node| range_and_position_of(&node, file_id))
87 } 87 }
88 hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { 88 hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => {
89 strukt.source(db).and_then(|node| range_and_position_of(&node)) 89 strukt.source(db).and_then(|node| range_and_position_of(&node, file_id))
90 } 90 }
91 hir::ModuleDef::Adt(hir::Adt::Enum(enum_)) => { 91 hir::ModuleDef::Adt(hir::Adt::Enum(enum_)) => {
92 enum_.source(db).and_then(|node| range_and_position_of(&node)) 92 enum_.source(db).and_then(|node| range_and_position_of(&node, file_id))
93 } 93 }
94 hir::ModuleDef::Adt(hir::Adt::Union(union)) => { 94 hir::ModuleDef::Adt(hir::Adt::Union(union)) => {
95 union.source(db).and_then(|node| range_and_position_of(&node)) 95 union.source(db).and_then(|node| range_and_position_of(&node, file_id))
96 } 96 }
97 _ => None, 97 _ => None,
98 }; 98 };
@@ -122,9 +122,10 @@ pub(crate) fn annotations(
122 122
123 fn range_and_position_of<T: NameOwner>( 123 fn range_and_position_of<T: NameOwner>(
124 node: &InFile<T>, 124 node: &InFile<T>,
125 file_id: FileId,
125 ) -> Option<(TextSize, TextRange)> { 126 ) -> Option<(TextSize, TextRange)> {
126 if node.file_id.is_macro_file() { 127 if node.file_id != file_id.into() {
127 // Macro generated files should not contain annotations. 128 // Node is outside the file we are adding annotations to (e.g. macros).
128 None 129 None
129 } else { 130 } else {
130 Some(( 131 Some((