Expand description
This module defines the primary IR1 used in rustdoc together with the procedures that transform rustc data types into it.
This IR — commonly referred to as the cleaned AST — is modeled after the AST.
There are two kinds of transformation — cleaning — procedures:
- Cleans HIR types. Used for user-written code and inlined local re-exports both found in the local crate.
- Cleans
rustc_middle::ty
types. Used for inlined cross-crate re-exports and anything output by the trait solver (e.g., when synthesizing blanket and auto-trait impls). They usually havety
ormiddle
in their name.
Their name is prefixed by clean_
.
Both the HIR and the rustc_middle::ty
IR are quite removed from the source code.
The cleaned AST on the other hand is closer to it which simplifies the rendering process.
Furthermore, operating on a single IR instead of two avoids duplicating efforts down the line.
This IR is consumed by both the HTML and the JSON backend.
Intermediate representation. ↩
Modules§
- cfg 🔒The representation of a
#[doc(cfg(...))]
attribute. - inline 🔒Support for inlining external documentation into the current AST.
- simplify 🔒Simplification of where-clauses and parameter bounds into a prettier and more canonical form.
- types 🔒
- utils 🔒
Enums§
- Whether to clean generic parameter defaults or not.
Functions§
- When inlining items, we merge their attributes (and all the reexports attributes too) with the final reexport. For example:
- This is needed to make it more “readable” when documenting functions using
rustc_legacy_const_generics
. More information in https://github.com/rust-lang/rust/issues/83167. - clean_
ty 🔒 - Remove attributes from
normal
that should not be inherited byuse
re-export. Before calling this function, make surenormal
is a#[doc]
attribute. - The goal of this function is to return the first
Path
which is not private (ie not private ordoc(hidden)
). If it’s not possible, it’ll return the “end type”. - Collect attributes from the whole import chain.
- This can happen for
async fn
, e.g.async fn f<'_>(&'_ self)
. - Synthetic type-parameters are inserted after normal ones. In order for normal parameters to be able to refer to synthetic ones, scans them first.
- Returns
None
if the type could not be normalized