@@ -9,7 +9,7 @@ use chalk_ir::{
9
9
} ;
10
10
use chalk_rust_ir:: { AssociatedTyDatum , AssociatedTyValue , ImplDatum , StructDatum , TraitDatum } ;
11
11
12
- use hir_def:: { lang_item:: LangItemTarget , ContainerId , GenericDefId , Lookup , TypeAliasId } ;
12
+ use hir_def:: { lang_item:: LangItemTarget , ContainerId , GenericDefId , Lookup , TraitId , TypeAliasId } ;
13
13
use hir_expand:: name;
14
14
15
15
use ra_db:: salsa:: { InternId , InternKey } ;
@@ -459,7 +459,7 @@ where
459
459
[ super :: FnTrait :: FnOnce , super :: FnTrait :: FnMut , super :: FnTrait :: Fn ] . iter ( )
460
460
{
461
461
if let Some ( actual_trait) = get_fn_trait ( self . db , self . krate , fn_trait) {
462
- if trait_ == actual_trait {
462
+ if trait_. id == actual_trait {
463
463
let impl_ = super :: ClosureFnTraitImplData { def, expr, fn_trait } ;
464
464
result. push ( Impl :: ClosureFnTraitImpl ( impl_) . to_chalk ( self . db ) ) ;
465
465
}
@@ -661,6 +661,7 @@ fn impl_block_datum(
661
661
} ;
662
662
663
663
let impl_datum_bound = chalk_rust_ir:: ImplDatumBound { trait_ref, where_clauses } ;
664
+ let trait_data = db. trait_data ( trait_. id ) ;
664
665
let associated_ty_value_ids = impl_block
665
666
. items ( db)
666
667
. into_iter ( )
@@ -670,7 +671,7 @@ fn impl_block_datum(
670
671
} )
671
672
. filter ( |type_alias| {
672
673
// don't include associated types that don't exist in the trait
673
- trait_ . associated_type_by_name ( db , & type_alias. name ( db) ) . is_some ( )
674
+ trait_data . associated_type_by_name ( & type_alias. name ( db) ) . is_some ( )
674
675
} )
675
676
. map ( |type_alias| AssocTyValue :: TypeAlias ( type_alias) . to_chalk ( db) )
676
677
. collect ( ) ;
@@ -713,7 +714,7 @@ fn closure_fn_trait_impl_datum(
713
714
// and don't want to return a valid value only to find out later that FnOnce
714
715
// is broken
715
716
let fn_once_trait = get_fn_trait ( db, krate, super :: FnTrait :: FnOnce ) ?;
716
- fn_once_trait. associated_type_by_name ( db , & name:: OUTPUT_TYPE ) ?;
717
+ let _output = db . trait_data ( fn_once_trait) . associated_type_by_name ( & name:: OUTPUT_TYPE ) ?;
717
718
718
719
let num_args: u16 = match & db. body ( data. def . into ( ) ) [ data. expr ] {
719
720
crate :: expr:: Expr :: Lambda { args, .. } => args. len ( ) as u16 ,
@@ -735,8 +736,8 @@ fn closure_fn_trait_impl_datum(
735
736
let self_ty = Ty :: apply_one ( TypeCtor :: Closure { def : data. def , expr : data. expr } , sig_ty) ;
736
737
737
738
let trait_ref = TraitRef {
738
- trait_,
739
- substs : Substs :: build_for_def ( db, trait_. id ) . push ( self_ty) . push ( arg_ty) . build ( ) ,
739
+ trait_ : trait_ . into ( ) ,
740
+ substs : Substs :: build_for_def ( db, trait_) . push ( self_ty) . push ( arg_ty) . build ( ) ,
740
741
} ;
741
742
742
743
let output_ty_id = AssocTyValue :: ClosureFnTraitImplOutput ( data. clone ( ) ) . to_chalk ( db) ;
@@ -783,10 +784,10 @@ fn type_alias_associated_ty_value(
783
784
. target_trait_ref ( db)
784
785
. expect ( "assoc ty value should not exist" ) // we don't return any assoc ty values if the impl'd trait can't be resolved
785
786
. trait_ ;
786
- let assoc_ty = trait_
787
- . associated_type_by_name ( db , & type_alias . name ( db ) )
788
- . expect ( "assoc ty value should not exist" ) // validated when building the impl data as well
789
- . id ;
787
+ let assoc_ty = db
788
+ . trait_data ( trait_ . id )
789
+ . associated_type_by_name ( & type_alias . name ( db ) )
790
+ . expect ( "assoc ty value should not exist" ) ; // validated when building the impl data as well
790
791
let generic_params = db. generic_params ( impl_block. id . into ( ) ) ;
791
792
let bound_vars = Substs :: bound_vars ( & generic_params) ;
792
793
let ty = db. type_for_def ( type_alias. into ( ) , crate :: ty:: Namespace :: Types ) . subst ( & bound_vars) ;
@@ -819,10 +820,10 @@ fn closure_fn_trait_output_assoc_ty_value(
819
820
let fn_once_trait =
820
821
get_fn_trait ( db, krate, super :: FnTrait :: FnOnce ) . expect ( "assoc ty value should not exist" ) ;
821
822
822
- let output_ty_id = fn_once_trait
823
- . associated_type_by_name ( db , & name :: OUTPUT_TYPE )
824
- . expect ( "assoc ty value should not exist" )
825
- . id ;
823
+ let output_ty_id = db
824
+ . trait_data ( fn_once_trait )
825
+ . associated_type_by_name ( & name :: OUTPUT_TYPE )
826
+ . expect ( "assoc ty value should not exist" ) ;
826
827
827
828
let value_bound = chalk_rust_ir:: AssociatedTyValueBound { ty : output_ty. to_chalk ( db) } ;
828
829
@@ -834,10 +835,10 @@ fn closure_fn_trait_output_assoc_ty_value(
834
835
Arc :: new ( value)
835
836
}
836
837
837
- fn get_fn_trait ( db : & impl HirDatabase , krate : Crate , fn_trait : super :: FnTrait ) -> Option < Trait > {
838
+ fn get_fn_trait ( db : & impl HirDatabase , krate : Crate , fn_trait : super :: FnTrait ) -> Option < TraitId > {
838
839
let target = db. lang_item ( krate. crate_id , fn_trait. lang_item_name ( ) . into ( ) ) ?;
839
840
match target {
840
- LangItemTarget :: TraitId ( t) => Some ( t. into ( ) ) ,
841
+ LangItemTarget :: TraitId ( t) => Some ( t) ,
841
842
_ => None ,
842
843
}
843
844
}
0 commit comments