@@ -1307,18 +1307,15 @@ crate enum TypeKind {
1307
1307
crate trait GetDefId {
1308
1308
/// Use this method to get the [`DefId`] of a [`clean`] AST node.
1309
1309
/// This will return [`None`] when called on a primitive [`clean::Type`].
1310
- /// Use [`Self::def_id_full`] if you are calling it on a primitive [`clean::Type`] .
1310
+ /// Use [`Self::def_id_full`] if you want to include primitives .
1311
1311
///
1312
1312
/// [`clean`]: crate::clean
1313
- /// [`clean::Type`]: Type
1313
+ // FIXME: get rid of this function and always use `def_id_full`
1314
1314
fn def_id ( & self ) -> Option < DefId > ;
1315
1315
1316
- /// Use this method to get the [`DefId`] of a [`clean`] AST node that may be
1317
- /// a primitive [`clean::Type`].
1316
+ /// Use this method to get the [DefId] of a [clean] AST node, including [PrimitiveType]s.
1318
1317
///
1319
1318
/// See [`Self::def_id`] for more.
1320
- ///
1321
- /// [`clean::Type`]: Type
1322
1319
fn def_id_full ( & self , cache : & Cache ) -> Option < DefId > ;
1323
1320
}
1324
1321
@@ -1419,31 +1416,28 @@ impl Type {
1419
1416
1420
1417
impl Type {
1421
1418
fn inner_def_id ( & self , cache : Option < & Cache > ) -> Option < DefId > {
1422
- let t: & dyn GetDefId = match * self {
1419
+ let t: PrimitiveType = match * self {
1423
1420
ResolvedPath { did, .. } => return Some ( did) ,
1424
1421
Primitive ( p) => return cache. and_then ( |c| c. primitive_locations . get ( & p) . cloned ( ) ) ,
1425
- BorrowedRef { type_ : box Generic ( ..) , .. } => & Primitive ( PrimitiveType :: Reference ) ,
1422
+ BorrowedRef { type_ : box Generic ( ..) , .. } => PrimitiveType :: Reference ,
1426
1423
BorrowedRef { ref type_, .. } => return type_. inner_def_id ( cache) ,
1427
1424
Tuple ( ref tys) => {
1428
1425
if tys. is_empty ( ) {
1429
- & Primitive ( PrimitiveType :: Unit )
1426
+ PrimitiveType :: Unit
1430
1427
} else {
1431
- & Primitive ( PrimitiveType :: Tuple )
1428
+ PrimitiveType :: Tuple
1432
1429
}
1433
1430
}
1434
- BareFunction ( ..) => & Primitive ( PrimitiveType :: Fn ) ,
1435
- Never => & Primitive ( PrimitiveType :: Never ) ,
1436
- Slice ( ..) => & Primitive ( PrimitiveType :: Slice ) ,
1437
- Array ( ..) => & Primitive ( PrimitiveType :: Array ) ,
1438
- RawPointer ( ..) => & Primitive ( PrimitiveType :: RawPointer ) ,
1431
+ BareFunction ( ..) => PrimitiveType :: Fn ,
1432
+ Never => PrimitiveType :: Never ,
1433
+ Slice ( ..) => PrimitiveType :: Slice ,
1434
+ Array ( ..) => PrimitiveType :: Array ,
1435
+ RawPointer ( ..) => PrimitiveType :: RawPointer ,
1439
1436
QPath { ref self_type, .. } => return self_type. inner_def_id ( cache) ,
1440
1437
// FIXME: remove this wildcard
1441
1438
_ => return None ,
1442
1439
} ;
1443
- match cache {
1444
- Some ( c) => t. def_id_full ( c) ,
1445
- None => t. def_id ( ) ,
1446
- }
1440
+ cache. and_then ( |c| Primitive ( t) . def_id_full ( c) )
1447
1441
}
1448
1442
}
1449
1443
0 commit comments