@@ -1410,34 +1410,30 @@ impl Type {
14101410
14111411impl Type {
14121412 fn inner_def_id ( & self , cache : Option < & Cache > ) -> Option < DefId > {
1413- fn inner < T : GetDefId > ( t : & T , cache : Option < & Cache > ) -> Option < DefId > {
1414- match cache {
1415- Some ( c) => t. def_id_full ( c) ,
1416- None => t. def_id ( ) ,
1417- }
1418- }
1419-
1420- match * self {
1421- ResolvedPath { did, .. } => Some ( did) ,
1422- Primitive ( p) => cache. and_then ( |c| c. primitive_locations . get ( & p) . cloned ( ) ) ,
1423- BorrowedRef { type_ : box Generic ( ..) , .. } => {
1424- inner ( & Primitive ( PrimitiveType :: Reference ) , cache)
1425- }
1426- BorrowedRef { ref type_, .. } => inner ( & * * type_, cache) ,
1413+ let t: & dyn GetDefId = match * self {
1414+ ResolvedPath { did, .. } => return Some ( did) ,
1415+ Primitive ( p) => return cache. and_then ( |c| c. primitive_locations . get ( & p) . cloned ( ) ) ,
1416+ BorrowedRef { type_ : box Generic ( ..) , .. } => & Primitive ( PrimitiveType :: Reference ) ,
1417+ BorrowedRef { ref type_, .. } => return type_. inner_def_id ( cache) ,
14271418 Tuple ( ref tys) => {
14281419 if tys. is_empty ( ) {
1429- inner ( & Primitive ( PrimitiveType :: Unit ) , cache )
1420+ & Primitive ( PrimitiveType :: Unit )
14301421 } else {
1431- inner ( & Primitive ( PrimitiveType :: Tuple ) , cache )
1422+ & Primitive ( PrimitiveType :: Tuple )
14321423 }
14331424 }
1434- BareFunction ( ..) => inner ( & Primitive ( PrimitiveType :: Fn ) , cache) ,
1435- Never => inner ( & Primitive ( PrimitiveType :: Never ) , cache) ,
1436- Slice ( ..) => inner ( & Primitive ( PrimitiveType :: Slice ) , cache) ,
1437- Array ( ..) => inner ( & Primitive ( PrimitiveType :: Array ) , cache) ,
1438- RawPointer ( ..) => inner ( & Primitive ( PrimitiveType :: RawPointer ) , cache) ,
1439- QPath { ref self_type, .. } => inner ( & * * self_type, cache) ,
1440- _ => None ,
1425+ BareFunction ( ..) => & Primitive ( PrimitiveType :: Fn ) ,
1426+ Never => & Primitive ( PrimitiveType :: Never ) ,
1427+ Slice ( ..) => & Primitive ( PrimitiveType :: Slice ) ,
1428+ Array ( ..) => & Primitive ( PrimitiveType :: Array ) ,
1429+ RawPointer ( ..) => & Primitive ( PrimitiveType :: RawPointer ) ,
1430+ QPath { ref self_type, .. } => return self_type. inner_def_id ( cache) ,
1431+ // FIXME: remove this wildcard
1432+ _ => return None ,
1433+ } ;
1434+ match cache {
1435+ Some ( c) => t. def_id_full ( c) ,
1436+ None => t. def_id ( ) ,
14411437 }
14421438 }
14431439}
0 commit comments