@@ -1410,34 +1410,30 @@ impl Type {
1410
1410
1411
1411
impl Type {
1412
1412
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) ,
1427
1418
Tuple ( ref tys) => {
1428
1419
if tys. is_empty ( ) {
1429
- inner ( & Primitive ( PrimitiveType :: Unit ) , cache )
1420
+ & Primitive ( PrimitiveType :: Unit )
1430
1421
} else {
1431
- inner ( & Primitive ( PrimitiveType :: Tuple ) , cache )
1422
+ & Primitive ( PrimitiveType :: Tuple )
1432
1423
}
1433
1424
}
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 ( ) ,
1441
1437
}
1442
1438
}
1443
1439
}
0 commit comments