Skip to content

Commit 1c23349

Browse files
Clean up clean/types.rs file by making the implementations follow the type declaration
1 parent cfff31b commit 1c23349

File tree

1 file changed

+40
-42
lines changed

1 file changed

+40
-42
lines changed

Diff for: src/librustdoc/clean/types.rs

+40-42
Original file line numberDiff line numberDiff line change
@@ -908,18 +908,10 @@ impl<'a> FromIterator<&'a DocFragment> for String {
908908
}
909909
}
910910

911-
/// The attributes on an [`Item`], including attributes like `#[derive(...)]` and `#[inline]`,
912-
/// as well as doc comments.
913-
#[derive(Clone, Debug, Default)]
914-
crate struct Attributes {
915-
crate doc_strings: Vec<DocFragment>,
916-
crate other_attrs: Vec<ast::Attribute>,
917-
}
918-
919-
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
920911
/// A link that has not yet been rendered.
921912
///
922913
/// This link will be turned into a rendered link by [`Item::links`].
914+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
923915
crate struct ItemLink {
924916
/// The original link written in the markdown
925917
pub(crate) link: String,
@@ -944,6 +936,14 @@ pub struct RenderedLink {
944936
pub(crate) href: String,
945937
}
946938

939+
/// The attributes on an [`Item`], including attributes like `#[derive(...)]` and `#[inline]`,
940+
/// as well as doc comments.
941+
#[derive(Clone, Debug, Default)]
942+
crate struct Attributes {
943+
crate doc_strings: Vec<DocFragment>,
944+
crate other_attrs: Vec<ast::Attribute>,
945+
}
946+
947947
impl Attributes {
948948
crate fn lists(&self, name: Symbol) -> ListAttributesIter<'_> {
949949
self.other_attrs.lists(name)
@@ -1424,37 +1424,6 @@ crate enum Type {
14241424
ImplTrait(Vec<GenericBound>),
14251425
}
14261426

1427-
#[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)]
1428-
/// N.B. this has to be different from `hir::PrimTy` because it also includes types that aren't
1429-
/// paths, like `Unit`.
1430-
crate enum PrimitiveType {
1431-
Isize,
1432-
I8,
1433-
I16,
1434-
I32,
1435-
I64,
1436-
I128,
1437-
Usize,
1438-
U8,
1439-
U16,
1440-
U32,
1441-
U64,
1442-
U128,
1443-
F32,
1444-
F64,
1445-
Char,
1446-
Bool,
1447-
Str,
1448-
Slice,
1449-
Array,
1450-
Tuple,
1451-
Unit,
1452-
RawPointer,
1453-
Reference,
1454-
Fn,
1455-
Never,
1456-
}
1457-
14581427
crate trait GetDefId {
14591428
/// Use this method to get the [`DefId`] of a [`clean`] AST node.
14601429
/// This will return [`None`] when called on a primitive [`clean::Type`].
@@ -1569,9 +1538,7 @@ impl Type {
15691538
};
15701539
Some((&self_, trait_did, *name))
15711540
}
1572-
}
15731541

1574-
impl Type {
15751542
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
15761543
let t: PrimitiveType = match *self {
15771544
ResolvedPath { did, .. } => return Some(did),
@@ -1608,6 +1575,37 @@ impl GetDefId for Type {
16081575
}
16091576
}
16101577

1578+
/// N.B. this has to be different from `hir::PrimTy` because it also includes types that aren't
1579+
/// paths, like `Unit`.
1580+
#[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)]
1581+
crate enum PrimitiveType {
1582+
Isize,
1583+
I8,
1584+
I16,
1585+
I32,
1586+
I64,
1587+
I128,
1588+
Usize,
1589+
U8,
1590+
U16,
1591+
U32,
1592+
U64,
1593+
U128,
1594+
F32,
1595+
F64,
1596+
Char,
1597+
Bool,
1598+
Str,
1599+
Slice,
1600+
Array,
1601+
Tuple,
1602+
Unit,
1603+
RawPointer,
1604+
Reference,
1605+
Fn,
1606+
Never,
1607+
}
1608+
16111609
impl PrimitiveType {
16121610
crate fn from_hir(prim: hir::PrimTy) -> PrimitiveType {
16131611
use ast::{FloatTy, IntTy, UintTy};

0 commit comments

Comments
 (0)