Skip to content

Commit 583437a

Browse files
committed
Auto merge of #89203 - GuillaumeGomez:cleanup-rustdoc-types, r=camelid
Clean up clean/types.rs file by making the implementations follow the type declaration This PR doesn't change anything, it simply moves things around: when reading the code, I realized a few times that a type declaration and implementations on it might be separated by some other type declarations, which makes the reading much more complicated. I put back impl and declaration together. r? `@camelid`
2 parents 04006d8 + 1c23349 commit 583437a

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)
@@ -1419,37 +1419,6 @@ crate enum Type {
14191419
ImplTrait(Vec<GenericBound>),
14201420
}
14211421

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

1570-
impl Type {
15711538
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
15721539
let t: PrimitiveType = match *self {
15731540
ResolvedPath { did, .. } => return Some(did),
@@ -1604,6 +1571,37 @@ impl GetDefId for Type {
16041571
}
16051572
}
16061573

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

0 commit comments

Comments
 (0)