@@ -66,7 +66,7 @@ use itertools::Itertools;
6666use nameres:: diagnostics:: DefDiagnosticKind ;
6767use once_cell:: unsync:: Lazy ;
6868use rustc_hash:: FxHashSet ;
69- use stdx:: { format_to, impl_from} ;
69+ use stdx:: { format_to, impl_from, never } ;
7070use syntax:: {
7171 ast:: { self , HasAttrs as _, HasName } ,
7272 AstNode , AstPtr , SmolStr , SyntaxKind , SyntaxNodePtr ,
@@ -2232,7 +2232,13 @@ impl ConstParam {
22322232
22332233 pub fn name ( self , db : & dyn HirDatabase ) -> Name {
22342234 let params = db. generic_params ( self . id . parent ) ;
2235- params. types [ self . id . local_id ] . name ( ) . unwrap ( ) . clone ( )
2235+ match params. types [ self . id . local_id ] . name ( ) {
2236+ Some ( x) => x. clone ( ) ,
2237+ None => {
2238+ never ! ( ) ;
2239+ Name :: missing ( )
2240+ }
2241+ }
22362242 }
22372243
22382244 pub fn module ( self , db : & dyn HirDatabase ) -> Module {
@@ -2285,15 +2291,10 @@ impl TypeOrConstParam {
22852291 }
22862292
22872293 pub fn ty ( self , db : & dyn HirDatabase ) -> Type {
2288- let def = self . id . parent ;
2289- let krate = def. module ( db. upcast ( ) ) . krate ( ) ;
2290- if let Some ( ty) = db. const_param_ty ( self . id ) {
2291- return Type :: new ( db, krate, def, ty) ;
2294+ match self . split ( db) {
2295+ Either :: Left ( x) => x. ty ( db) ,
2296+ Either :: Right ( x) => x. ty ( db) ,
22922297 }
2293- let resolver = self . id . parent . resolver ( db. upcast ( ) ) ;
2294- let krate = self . id . parent . module ( db. upcast ( ) ) . krate ( ) ;
2295- let ty = TyKind :: Placeholder ( hir_ty:: to_placeholder_idx ( db, self . id ) ) . intern ( Interner ) ;
2296- Type :: new_with_resolver_inner ( db, krate, & resolver, ty)
22972298 }
22982299}
22992300
0 commit comments