File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -992,8 +992,8 @@ impl TypeParam {
992992
993993 pub fn default ( self , db : & dyn HirDatabase ) -> Option < Ty > {
994994 let params = db. generic_defaults ( self . id . parent ) ;
995- let local_idx: u32 = self . id . local_id . into_raw ( ) . into ( ) ;
996- params. get ( local_idx as usize ) . map ( |d| d. clone ( ) )
995+ let local_idx = hir_ty :: param_idx ( db , self . id ) ? ;
996+ params. get ( local_idx) . map ( |d| d. clone ( ) )
997997 }
998998}
999999
Original file line number Diff line number Diff line change @@ -427,6 +427,11 @@ impl Substs {
427427 }
428428}
429429
430+ /// Return an index of a parameter in the generic type parameter list by it's id.
431+ pub fn param_idx ( db : & dyn HirDatabase , id : TypeParamId ) -> Option < usize > {
432+ generics ( db. upcast ( ) , id. parent ) . param_idx ( id)
433+ }
434+
430435#[ derive( Debug , Clone ) ]
431436pub struct SubstsBuilder {
432437 vec : Vec < Ty > ,
You can’t perform that action at this time.
0 commit comments