diff options
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 5081466a2..4e8dc0c54 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -4,10 +4,8 @@ use std::sync::Arc; | |||
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
5 | 5 | ||
6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; |
7 | use ra_db::{LocalSyntaxPtr, Cancelable}; | 7 | use ra_db::LocalSyntaxPtr; |
8 | use ra_syntax::{ | 8 | use ra_syntax::ast::{self, AstNode, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor}; |
9 | ast::{self, AstNode, LoopBodyOwner, ArgListOwner, NameOwner, LiteralFlavor} | ||
10 | }; | ||
11 | 9 | ||
12 | use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName}; | 10 | use crate::{Path, type_ref::{Mutability, TypeRef}, Name, HirDatabase, DefId, Def, name::AsName}; |
13 | use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}; | 11 | use crate::ty::primitive::{UintTy, UncertainIntTy, UncertainFloatTy}; |
@@ -358,8 +356,8 @@ impl Pat { | |||
358 | 356 | ||
359 | // Queries | 357 | // Queries |
360 | 358 | ||
361 | pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<Body>> { | 359 | pub(crate) fn body_hir(db: &impl HirDatabase, def_id: DefId) -> Arc<Body> { |
362 | Ok(Arc::clone(&body_syntax_mapping(db, def_id)?.body)) | 360 | Arc::clone(&body_syntax_mapping(db, def_id).body) |
363 | } | 361 | } |
364 | 362 | ||
365 | struct ExprCollector { | 363 | struct ExprCollector { |
@@ -828,17 +826,14 @@ pub(crate) fn collect_fn_body_syntax(node: &ast::FnDef) -> BodySyntaxMapping { | |||
828 | collector.into_body_syntax_mapping(params, body) | 826 | collector.into_body_syntax_mapping(params, body) |
829 | } | 827 | } |
830 | 828 | ||
831 | pub(crate) fn body_syntax_mapping( | 829 | pub(crate) fn body_syntax_mapping(db: &impl HirDatabase, def_id: DefId) -> Arc<BodySyntaxMapping> { |
832 | db: &impl HirDatabase, | 830 | let def = def_id.resolve(db); |
833 | def_id: DefId, | ||
834 | ) -> Cancelable<Arc<BodySyntaxMapping>> { | ||
835 | let def = def_id.resolve(db)?; | ||
836 | 831 | ||
837 | let body_syntax_mapping = match def { | 832 | let body_syntax_mapping = match def { |
838 | Def::Function(f) => collect_fn_body_syntax(&f.source(db)?.1), | 833 | Def::Function(f) => collect_fn_body_syntax(&f.source(db).1), |
839 | // TODO: consts, etc. | 834 | // TODO: consts, etc. |
840 | _ => panic!("Trying to get body for item type without body"), | 835 | _ => panic!("Trying to get body for item type without body"), |
841 | }; | 836 | }; |
842 | 837 | ||
843 | Ok(Arc::new(body_syntax_mapping)) | 838 | Arc::new(body_syntax_mapping) |
844 | } | 839 | } |