]> git.lizzy.rs Git - rust.git/blob - src/librustdoc/formats/mod.rs
Use empty Cache for methods requiring it when filling Cache itself
[rust.git] / src / librustdoc / formats / mod.rs
1 crate mod cache;
2 crate mod item_type;
3 crate mod renderer;
4
5 crate use renderer::{run_format, FormatRenderer};
6
7 use rustc_span::def_id::DefId;
8
9 use crate::clean;
10 use crate::clean::types::GetDefId;
11 use crate::formats::cache::Cache;
12
13 /// Specifies whether rendering directly implemented trait items or ones from a certain Deref
14 /// impl.
15 crate enum AssocItemRender<'a> {
16     All,
17     DerefFor { trait_: &'a clean::Type, type_: &'a clean::Type, deref_mut_: bool },
18 }
19
20 /// For different handling of associated items from the Deref target of a type rather than the type
21 /// itself.
22 #[derive(Copy, Clone, PartialEq)]
23 crate enum RenderMode {
24     Normal,
25     ForDeref { mut_: bool },
26 }
27
28 /// Metadata about implementations for a type or trait.
29 #[derive(Clone, Debug)]
30 crate struct Impl {
31     crate impl_item: clean::Item,
32 }
33
34 impl Impl {
35     crate fn inner_impl(&self) -> &clean::Impl {
36         match *self.impl_item.kind {
37             clean::ImplItem(ref impl_) => impl_,
38             _ => panic!("non-impl item found in impl"),
39         }
40     }
41
42     crate fn trait_did(&self, cache: &Cache) -> Option<DefId> {
43         self.inner_impl().trait_.def_id(cache)
44     }
45 }