1
Fork 0

Rollup merge of #59170 - varkor:const-generics-rustdoc, r=QuietMisdreavus,eddyb

Add const generics to rustdoc

Split out from #53645. This work is a collaborative effort with @yodaldevoid.

The `FIXME`s are waiting on a refactor to `LazyConst`. I'll address these in a follow up, but I thought it would be better to implement the rest now to avoid bitrot.

r? @QuietMisdreavus
This commit is contained in:
Mazdak Farrokhzad 2019-03-22 19:31:18 +01:00 committed by GitHub
commit 4c79967760
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 156 additions and 117 deletions

View file

@ -271,7 +271,7 @@ pub struct Cache {
/// Mapping of typaram ids to the name of the type parameter. This is used
/// when pretty-printing a type (so pretty-printing doesn't have to
/// painfully maintain a context like this)
pub typarams: FxHashMap<DefId, String>,
pub param_names: FxHashMap<DefId, String>,
/// Maps a type ID to all known implementations for that type. This is only
/// recognized for intra-crate `ResolvedPath` types, and is used to print
@ -368,7 +368,7 @@ pub struct Cache {
pub struct RenderInfo {
pub inlined: FxHashSet<DefId>,
pub external_paths: crate::core::ExternalPaths,
pub external_typarams: FxHashMap<DefId, String>,
pub external_param_names: FxHashMap<DefId, String>,
pub exact_paths: FxHashMap<DefId, Vec<String>>,
pub access_levels: AccessLevels<DefId>,
pub deref_trait_did: Option<DefId>,
@ -601,7 +601,7 @@ pub fn run(mut krate: clean::Crate,
let RenderInfo {
inlined: _,
external_paths,
external_typarams,
external_param_names,
exact_paths,
access_levels,
deref_trait_did,
@ -635,7 +635,7 @@ pub fn run(mut krate: clean::Crate,
deref_mut_trait_did,
owned_box_did,
masked_crates: mem::replace(&mut krate.masked_crates, Default::default()),
typarams: external_typarams,
param_names: external_param_names,
aliases: Default::default(),
};
@ -1751,7 +1751,7 @@ impl<'a> Cache {
clean::GenericParamDefKind::Lifetime => {}
clean::GenericParamDefKind::Type { did, .. } |
clean::GenericParamDefKind::Const { did, .. } => {
self.typarams.insert(did, param.name.clone());
self.param_names.insert(did, param.name.clone());
}
}
}