about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJake <jh@discordapp.com>2021-11-17 09:53:24 -0800
committerGitHub <noreply@github.com>2021-11-17 09:53:24 -0800
commitd5de7c21b27e7ad2ba92c6ce8f386d226bcc6adc (patch)
tree8c88b173fa2f70d93a391975570152a34d3369a0
parent312eafe91677441f2efdccd27db44b4e0bf8710c (diff)
downloadrust-d5de7c21b27e7ad2ba92c6ce8f386d226bcc6adc.tar.gz
rust-d5de7c21b27e7ad2ba92c6ce8f386d226bcc6adc.zip
Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
-rw-r--r--crates/hir/src/lib.rs9
1 files changed, 1 insertions, 8 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index ee7270f2959..a528b2bc2d1 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1458,14 +1458,7 @@ impl Const {
     }
 
     pub fn value(self, db: &dyn HirDatabase) -> Option<ast::Expr> {
-        let loc = self.id.lookup(db.upcast());
-        let item_tree = loc.id.item_tree(db.upcast());
-        let ast_id = item_tree[loc.id.value].ast_id;
-        let ast_id_map = db.ast_id_map(loc.id.file_id());
-        let ast_ptr = ast_id_map.get(ast_id);
-        let syntax_node = db.parse_or_expand(loc.id.file_id())?;
-        let ast_node = ast_ptr.to_node(&syntax_node);
-        ast_node.body()
+        self.source(db)?.value.body()
     }
 
     pub fn ty(self, db: &dyn HirDatabase) -> Type {