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§
- auto_
trait 🔒 - blanket_
impl 🔒 - cfg 🔒
- The representation of a
#[doc(cfg(...))]
attribute. - inline 🔒
- Support for inlining external documentation into the current AST.
- render_
macro_ 🔒matchers - simplify 🔒
- Simplification of where-clauses and parameter bounds into a prettier and more canonical form.
- types 🔒
- utils 🔒
Enums§
- Container
Ty 🔒 - Function
Args 🔒 - Object
Lifetime 🔒Default - Param
Defaults 🔒 - Whether to clean generic parameter defaults or not.
Functions§
- add_
without_ 🔒unwanted_ attributes - When inlining items, we merge their attributes (and all the reexports attributes too) with the final reexport. For example:
- can_
elide_ 🔒trait_ object_ lifetime_ bound - clean_
args_ 🔒from_ types_ and_ body_ id - clean_
args_ 🔒from_ types_ and_ names - clean_
assoc_ 🔒item_ constraint - clean_
bare_ 🔒fn_ ty - clean_
bound_ 🔒vars - clean_
const 🔒 - clean_
doc_ 🔒module - clean_
extern_ 🔒crate - clean_
field 🔒 - clean_
field_ 🔒with_ def_ id - clean_
fn_ 🔒decl_ legacy_ const_ generics - 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_
fn_ 🔒decl_ with_ args - clean_
fn_ 🔒or_ proc_ macro - clean_
function 🔒 - clean_
generic_ 🔒args - clean_
generic_ 🔒bound - clean_
generic_ 🔒param - clean_
generic_ 🔒param_ def - clean_
generics 🔒 - clean_
hir_ 🔒term - clean_
impl 🔒 - clean_
impl_ 🔒item - clean_
lifetime 🔒 - clean_
maybe_ 🔒renamed_ foreign_ item - clean_
maybe_ 🔒renamed_ item - clean_
middle_ 🔒assoc_ item - clean_
middle_ 🔒const - clean_
middle_ 🔒field - clean_
middle_ 🔒opaque_ bounds - clean_
middle_ 🔒region - clean_
middle_ 🔒term - clean_
middle_ 🔒ty - clean_
path 🔒 - clean_
path_ 🔒segment - clean_
poly_ 🔒fn_ sig - clean_
poly_ 🔒trait_ predicate - clean_
poly_ 🔒trait_ ref - clean_
poly_ 🔒trait_ ref_ with_ constraints - clean_
predicate 🔒 - clean_
proc_ 🔒macro - clean_
projection 🔒 - clean_
projection_ 🔒predicate - clean_
qpath 🔒 - clean_
region_ 🔒outlives_ predicate - clean_
trait_ 🔒item - clean_
trait_ 🔒object_ lifetime_ bound - clean_
trait_ 🔒ref - clean_
trait_ 🔒ref_ with_ constraints - clean_
ty 🔒 - clean_
ty_ 🔒alias_ inner_ type - clean_
ty_ 🔒generics - clean_
type_ 🔒outlives_ predicate - clean_
unsafe_ 🔒binder_ ty - clean_
use_ 🔒statement - clean_
use_ 🔒statement_ inner - clean_
variant 🔒 - clean_
variant_ 🔒data - clean_
variant_ 🔒def - clean_
variant_ 🔒def_ with_ args - clean_
where_ 🔒predicate - compute_
should_ 🔒show_ cast - filter_
doc_ 🔒attr - Remove attributes from
normal
that should not be inherited byuse
re-export. Before calling this function, make surenormal
is a#[doc]
attribute. - filter_
doc_ 🔒attr_ ident - filter_
tokens_ 🔒from_ list - first_
non_ 🔒private - 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”. - first_
non_ 🔒private_ clean_ path - generate_
item_ 🔒with_ correct_ attrs - get_
all_ 🔒import_ attributes - Collect attributes from the whole import chain.
- is_
elided_ 🔒lifetime - This can happen for
async fn
, e.g.async fn f<'_>(&'_ self)
. - is_
glob_ 🔒import - is_
impl_ 🔒trait - Synthetic type-parameters are inserted after normal ones. In order for normal parameters to be able to refer to synthetic ones, scans them first.
- maybe_
expand_ 🔒private_ type_ alias - normalize 🔒
- Returns
None
if the type could not be normalized - projection_
to_ 🔒path_ segment - reexport_
chain 🔒