@@ -1370,17 +1370,10 @@ crate enum FnRetTy {
1370
1370
DefaultReturn ,
1371
1371
}
1372
1372
1373
- impl GetDefId for FnRetTy {
1374
- fn def_id ( & self ) -> Option < DefId > {
1375
- match * self {
1376
- Return ( ref ty) => ty. def_id ( ) ,
1377
- DefaultReturn => None ,
1378
- }
1379
- }
1380
-
1381
- fn def_id_full ( & self , cache : & Cache ) -> Option < DefId > {
1382
- match * self {
1383
- Return ( ref ty) => ty. def_id_full ( cache) ,
1373
+ impl FnRetTy {
1374
+ crate fn as_return ( & self ) -> Option < & Type > {
1375
+ match self {
1376
+ Return ( ret) => Some ( ret) ,
1384
1377
DefaultReturn => None ,
1385
1378
}
1386
1379
}
@@ -1458,34 +1451,6 @@ crate enum Type {
1458
1451
#[ cfg( all( target_arch = "x86_64" , target_pointer_width = "64" ) ) ]
1459
1452
rustc_data_structures:: static_assert_size!( Type , 72 ) ;
1460
1453
1461
- crate trait GetDefId {
1462
- /// Use this method to get the [`DefId`] of a [`clean`] AST node.
1463
- /// This will return [`None`] when called on a primitive [`clean::Type`].
1464
- /// Use [`Self::def_id_full`] if you want to include primitives.
1465
- ///
1466
- /// [`clean`]: crate::clean
1467
- /// [`clean::Type`]: crate::clean::Type
1468
- // FIXME: get rid of this function and always use `def_id_full`
1469
- fn def_id ( & self ) -> Option < DefId > ;
1470
-
1471
- /// Use this method to get the [DefId] of a [clean] AST node, including [PrimitiveType]s.
1472
- ///
1473
- /// See [`Self::def_id`] for more.
1474
- ///
1475
- /// [clean]: crate::clean
1476
- fn def_id_full ( & self , cache : & Cache ) -> Option < DefId > ;
1477
- }
1478
-
1479
- impl < T : GetDefId > GetDefId for Option < T > {
1480
- fn def_id ( & self ) -> Option < DefId > {
1481
- self . as_ref ( ) . and_then ( |d| d. def_id ( ) )
1482
- }
1483
-
1484
- fn def_id_full ( & self , cache : & Cache ) -> Option < DefId > {
1485
- self . as_ref ( ) . and_then ( |d| d. def_id_full ( cache) )
1486
- }
1487
- }
1488
-
1489
1454
impl Type {
1490
1455
crate fn primitive_type ( & self ) -> Option < PrimitiveType > {
1491
1456
match * self {
@@ -1564,17 +1529,27 @@ impl Type {
1564
1529
QPath { ref self_type, .. } => return self_type. inner_def_id ( cache) ,
1565
1530
Generic ( _) | Infer | ImplTrait ( _) => return None ,
1566
1531
} ;
1567
- cache. and_then ( |c| Primitive ( t) . def_id_full ( c) )
1532
+ cache. and_then ( |c| Primitive ( t) . def_id ( c) )
1568
1533
}
1569
- }
1570
1534
1571
- impl GetDefId for Type {
1572
- fn def_id ( & self ) -> Option < DefId > {
1573
- self . inner_def_id ( None )
1535
+ /// Use this method to get the [DefId] of a [clean] AST node, including [PrimitiveType]s.
1536
+ ///
1537
+ /// See [`Self::def_id_no_primitives`] for more.
1538
+ ///
1539
+ /// [clean]: crate::clean
1540
+ crate fn def_id ( & self , cache : & Cache ) -> Option < DefId > {
1541
+ self . inner_def_id ( Some ( cache) )
1574
1542
}
1575
1543
1576
- fn def_id_full ( & self , cache : & Cache ) -> Option < DefId > {
1577
- self . inner_def_id ( Some ( cache) )
1544
+ /// Use this method to get the [`DefId`] of a [`clean`] AST node.
1545
+ /// This will return [`None`] when called on a primitive [`clean::Type`].
1546
+ /// Use [`Self::def_id`] if you want to include primitives.
1547
+ ///
1548
+ /// [`clean`]: crate::clean
1549
+ /// [`clean::Type`]: crate::clean::Type
1550
+ // FIXME: get rid of this function and always use `def_id`
1551
+ crate fn def_id_no_primitives ( & self ) -> Option < DefId > {
1552
+ self . inner_def_id ( None )
1578
1553
}
1579
1554
}
1580
1555
@@ -2092,16 +2067,6 @@ crate struct Typedef {
2092
2067
crate item_type : Option < Type > ,
2093
2068
}
2094
2069
2095
- impl GetDefId for Typedef {
2096
- fn def_id ( & self ) -> Option < DefId > {
2097
- self . type_ . def_id ( )
2098
- }
2099
-
2100
- fn def_id_full ( & self , cache : & Cache ) -> Option < DefId > {
2101
- self . type_ . def_id_full ( cache)
2102
- }
2103
- }
2104
-
2105
2070
#[ derive( Clone , Debug ) ]
2106
2071
crate struct OpaqueTy {
2107
2072
crate bounds : Vec < GenericBound > ,
0 commit comments