mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
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`
This commit is contained in:
commit
583437a6dd
@ -908,18 +908,10 @@ impl<'a> FromIterator<&'a DocFragment> for String {
|
||||
}
|
||||
}
|
||||
|
||||
/// The attributes on an [`Item`], including attributes like `#[derive(...)]` and `#[inline]`,
|
||||
/// as well as doc comments.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
crate struct Attributes {
|
||||
crate doc_strings: Vec<DocFragment>,
|
||||
crate other_attrs: Vec<ast::Attribute>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
/// A link that has not yet been rendered.
|
||||
///
|
||||
/// This link will be turned into a rendered link by [`Item::links`].
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
crate struct ItemLink {
|
||||
/// The original link written in the markdown
|
||||
pub(crate) link: String,
|
||||
@ -944,6 +936,14 @@ pub struct RenderedLink {
|
||||
pub(crate) href: String,
|
||||
}
|
||||
|
||||
/// The attributes on an [`Item`], including attributes like `#[derive(...)]` and `#[inline]`,
|
||||
/// as well as doc comments.
|
||||
#[derive(Clone, Debug, Default)]
|
||||
crate struct Attributes {
|
||||
crate doc_strings: Vec<DocFragment>,
|
||||
crate other_attrs: Vec<ast::Attribute>,
|
||||
}
|
||||
|
||||
impl Attributes {
|
||||
crate fn lists(&self, name: Symbol) -> ListAttributesIter<'_> {
|
||||
self.other_attrs.lists(name)
|
||||
@ -1419,37 +1419,6 @@ crate enum Type {
|
||||
ImplTrait(Vec<GenericBound>),
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)]
|
||||
/// N.B. this has to be different from `hir::PrimTy` because it also includes types that aren't
|
||||
/// paths, like `Unit`.
|
||||
crate enum PrimitiveType {
|
||||
Isize,
|
||||
I8,
|
||||
I16,
|
||||
I32,
|
||||
I64,
|
||||
I128,
|
||||
Usize,
|
||||
U8,
|
||||
U16,
|
||||
U32,
|
||||
U64,
|
||||
U128,
|
||||
F32,
|
||||
F64,
|
||||
Char,
|
||||
Bool,
|
||||
Str,
|
||||
Slice,
|
||||
Array,
|
||||
Tuple,
|
||||
Unit,
|
||||
RawPointer,
|
||||
Reference,
|
||||
Fn,
|
||||
Never,
|
||||
}
|
||||
|
||||
crate trait GetDefId {
|
||||
/// Use this method to get the [`DefId`] of a [`clean`] AST node.
|
||||
/// This will return [`None`] when called on a primitive [`clean::Type`].
|
||||
@ -1565,9 +1534,7 @@ impl Type {
|
||||
};
|
||||
Some((&self_, trait_did, *name))
|
||||
}
|
||||
}
|
||||
|
||||
impl Type {
|
||||
fn inner_def_id(&self, cache: Option<&Cache>) -> Option<DefId> {
|
||||
let t: PrimitiveType = match *self {
|
||||
ResolvedPath { did, .. } => return Some(did),
|
||||
@ -1604,6 +1571,37 @@ impl GetDefId for Type {
|
||||
}
|
||||
}
|
||||
|
||||
/// N.B. this has to be different from `hir::PrimTy` because it also includes types that aren't
|
||||
/// paths, like `Unit`.
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Copy, Debug)]
|
||||
crate enum PrimitiveType {
|
||||
Isize,
|
||||
I8,
|
||||
I16,
|
||||
I32,
|
||||
I64,
|
||||
I128,
|
||||
Usize,
|
||||
U8,
|
||||
U16,
|
||||
U32,
|
||||
U64,
|
||||
U128,
|
||||
F32,
|
||||
F64,
|
||||
Char,
|
||||
Bool,
|
||||
Str,
|
||||
Slice,
|
||||
Array,
|
||||
Tuple,
|
||||
Unit,
|
||||
RawPointer,
|
||||
Reference,
|
||||
Fn,
|
||||
Never,
|
||||
}
|
||||
|
||||
impl PrimitiveType {
|
||||
crate fn from_hir(prim: hir::PrimTy) -> PrimitiveType {
|
||||
use ast::{FloatTy, IntTy, UintTy};
|
||||
|
Loading…
Reference in New Issue
Block a user