1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Writer logic for simple IDs
//!
//! `RenderAsRust` impls for identifiers which are either too small or too
//! shared to belong anywhere else belong here.
use std::fmt::{Formatter, Result};

use chalk_ir::interner::Interner;
use chalk_ir::*;

use super::{render_trait::RenderAsRust, state::InternalWriterState};

impl<I: Interner> RenderAsRust<I> for AdtId<I> {
    fn fmt(&self, s: &InternalWriterState<'_, I>, f: &'_ mut Formatter<'_>) -> Result {
        // TODO: use debug methods?
        write!(
            f,
            "{}",
            s.alias_for_adt_id_name(self.0, s.db().adt_name(*self))
        )
    }
}

impl<I: Interner> RenderAsRust<I> for TraitId<I> {
    fn fmt(&self, s: &InternalWriterState<'_, I>, f: &'_ mut Formatter<'_>) -> Result {
        // TODO: use debug methods?
        write!(
            f,
            "{}",
            s.alias_for_id_name(self.0, s.db().trait_name(*self))
        )
    }
}

impl<I: Interner> RenderAsRust<I> for AssocTypeId<I> {
    fn fmt(&self, s: &InternalWriterState<'_, I>, f: &'_ mut Formatter<'_>) -> Result {
        // TODO: use debug methods?
        write!(
            f,
            "{}",
            s.alias_for_id_name(self.0, s.db().assoc_type_name(*self))
        )
    }
}

impl<I: Interner> RenderAsRust<I> for OpaqueTyId<I> {
    fn fmt(&self, s: &InternalWriterState<'_, I>, f: &'_ mut Formatter<'_>) -> Result {
        // TODO: use debug methods?
        write!(
            f,
            "{}",
            s.alias_for_id_name(self.0, s.db().opaque_type_name(*self))
        )
    }
}