diff options
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 010d35e55..cd9e22c42 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs | |||
@@ -156,6 +156,9 @@ pub struct BodySourceMap { | |||
156 | expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, | 156 | expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>, |
157 | } | 157 | } |
158 | 158 | ||
159 | #[derive(Debug)] | ||
160 | pub struct SyntheticSyntax; | ||
161 | |||
159 | impl Body { | 162 | impl Body { |
160 | pub(crate) fn body_with_source_map_query( | 163 | pub(crate) fn body_with_source_map_query( |
161 | db: &impl DefDatabase, | 164 | db: &impl DefDatabase, |
@@ -219,8 +222,8 @@ impl Index<PatId> for Body { | |||
219 | } | 222 | } |
220 | 223 | ||
221 | impl BodySourceMap { | 224 | impl BodySourceMap { |
222 | pub fn expr_syntax(&self, expr: ExprId) -> Option<ExprSource> { | 225 | pub fn expr_syntax(&self, expr: ExprId) -> Result<ExprSource, SyntheticSyntax> { |
223 | self.expr_map_back.get(expr).copied() | 226 | self.expr_map_back.get(expr).copied().ok_or(SyntheticSyntax) |
224 | } | 227 | } |
225 | 228 | ||
226 | pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option<ExprId> { | 229 | pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option<ExprId> { |
@@ -238,8 +241,8 @@ impl BodySourceMap { | |||
238 | self.expr_map.get(&src).cloned() | 241 | self.expr_map.get(&src).cloned() |
239 | } | 242 | } |
240 | 243 | ||
241 | pub fn pat_syntax(&self, pat: PatId) -> Option<PatSource> { | 244 | pub fn pat_syntax(&self, pat: PatId) -> Result<PatSource, SyntheticSyntax> { |
242 | self.pat_map_back.get(pat).copied() | 245 | self.pat_map_back.get(pat).copied().ok_or(SyntheticSyntax) |
243 | } | 246 | } |
244 | 247 | ||
245 | pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> { | 248 | pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> { |