aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/item_tree
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-03-24 16:00:29 +0000
committerLukas Wirth <[email protected]>2021-03-29 16:11:28 +0100
commitbb6e1bf811bce09fdab115a4257e47cc0d5ddc82 (patch)
tree7fa2802e317177ef9da00a442fddb75528d9b56b /crates/hir_def/src/item_tree
parentbb1d925dab36372c6bd1fb5671bb68ce938ff009 (diff)
Lower traits to TraitRef instead of TypeRef
Diffstat (limited to 'crates/hir_def/src/item_tree')
-rw-r--r--crates/hir_def/src/item_tree/lower.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index 3f558edd8..34af5c8d4 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -11,7 +11,7 @@ use syntax::{
11 11
12use crate::{ 12use crate::{
13 generics::{GenericParams, TypeParamData, TypeParamProvenance}, 13 generics::{GenericParams, TypeParamData, TypeParamProvenance},
14 type_ref::LifetimeRef, 14 type_ref::{LifetimeRef, TraitRef},
15}; 15};
16 16
17use super::*; 17use super::*;
@@ -536,7 +536,7 @@ impl Ctx {
536 fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> { 536 fn lower_impl(&mut self, impl_def: &ast::Impl) -> Option<FileItemTreeId<Impl>> {
537 let generic_params = 537 let generic_params =
538 self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def); 538 self.lower_generic_params_and_inner_items(GenericsOwner::Impl, impl_def);
539 let target_trait = impl_def.trait_().map(|tr| self.lower_type_ref(&tr)); 539 let target_trait = impl_def.trait_().map(|tr| self.lower_trait_ref(&tr));
540 let target_type = self.lower_type_ref(&impl_def.self_ty()?); 540 let target_type = self.lower_type_ref(&impl_def.self_ty()?);
541 let is_negative = impl_def.excl_token().is_some(); 541 let is_negative = impl_def.excl_token().is_some();
542 542
@@ -740,10 +740,16 @@ impl Ctx {
740 self.data().vis.alloc(vis) 740 self.data().vis.alloc(vis)
741 } 741 }
742 742
743 fn lower_trait_ref(&mut self, trait_ref: &ast::Type) -> Idx<TraitRef> {
744 let trait_ref = TraitRef::from_ast(&self.body_ctx, trait_ref.clone());
745 self.data().trait_refs.intern(trait_ref)
746 }
747
743 fn lower_type_ref(&mut self, type_ref: &ast::Type) -> Idx<TypeRef> { 748 fn lower_type_ref(&mut self, type_ref: &ast::Type) -> Idx<TypeRef> {
744 let tyref = TypeRef::from_ast(&self.body_ctx, type_ref.clone()); 749 let tyref = TypeRef::from_ast(&self.body_ctx, type_ref.clone());
745 self.data().type_refs.intern(tyref) 750 self.data().type_refs.intern(tyref)
746 } 751 }
752
747 fn lower_type_ref_opt(&mut self, type_ref: Option<ast::Type>) -> Idx<TypeRef> { 753 fn lower_type_ref_opt(&mut self, type_ref: Option<ast::Type>) -> Idx<TypeRef> {
748 match type_ref.map(|ty| self.lower_type_ref(&ty)) { 754 match type_ref.map(|ty| self.lower_type_ref(&ty)) {
749 Some(it) => it, 755 Some(it) => it,