@@ -1307,18 +1307,15 @@ crate enum TypeKind {
13071307crate trait GetDefId {
13081308 /// Use this method to get the [`DefId`] of a [`clean`] AST node.
13091309 /// 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 .
13111311 ///
13121312 /// [`clean`]: crate::clean
1313- /// [`clean::Type`]: Type
1313+ // FIXME: get rid of this function and always use `def_id_full`
13141314 fn def_id ( & self ) -> Option < DefId > ;
13151315
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.
13181317 ///
13191318 /// See [`Self::def_id`] for more.
1320- ///
1321- /// [`clean::Type`]: Type
13221319 fn def_id_full ( & self , cache : & Cache ) -> Option < DefId > ;
13231320}
13241321
@@ -1419,31 +1416,28 @@ impl Type {
14191416
14201417impl Type {
14211418 fn inner_def_id ( & self , cache : Option < & Cache > ) -> Option < DefId > {
1422- let t: & dyn GetDefId = match * self {
1419+ let t: PrimitiveType = match * self {
14231420 ResolvedPath { did, .. } => return Some ( did) ,
14241421 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 ,
14261423 BorrowedRef { ref type_, .. } => return type_. inner_def_id ( cache) ,
14271424 Tuple ( ref tys) => {
14281425 if tys. is_empty ( ) {
1429- & Primitive ( PrimitiveType :: Unit )
1426+ PrimitiveType :: Unit
14301427 } else {
1431- & Primitive ( PrimitiveType :: Tuple )
1428+ PrimitiveType :: Tuple
14321429 }
14331430 }
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 ,
14391436 QPath { ref self_type, .. } => return self_type. inner_def_id ( cache) ,
14401437 // FIXME: remove this wildcard
14411438 _ => return None ,
14421439 } ;
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) )
14471441 }
14481442}
14491443
0 commit comments