Add Interns::module_name and use it.

This commit is contained in:
Richard Feldman 2020-03-29 23:26:56 -04:00
parent 62c7a7c3e2
commit 555528c483
2 changed files with 11 additions and 2 deletions

View file

@ -180,6 +180,15 @@ pub struct Interns {
} }
impl Interns { impl Interns {
pub fn module_name(&self, module_id: ModuleId) -> &InlinableString {
self.module_ids.get_name(module_id).unwrap_or_else(|| {
panic!(
"Unable to find interns entry for module_id {:?} in Interns {:?}",
module_id, self
)
})
}
pub fn symbol(&self, module_id: ModuleId, ident: InlinableString) -> Symbol { pub fn symbol(&self, module_id: ModuleId, ident: InlinableString) -> Symbol {
match self.all_ident_ids.get(&module_id) { match self.all_ident_ids.get(&module_id) {
Some(ident_ids) => match ident_ids.get_id(&ident) { Some(ident_ids) => match ident_ids.get_id(&ident) {

View file

@ -299,7 +299,7 @@ impl ReportText {
} }
} }
Module(module_id) => { Module(module_id) => {
buf.push_str(&module_id.name()); buf.push_str(&interns.module_name(module_id));
} }
Type(content) => buf.push_str(content_to_string(content, subs, home, interns).as_str()), Type(content) => buf.push_str(content_to_string(content, subs, home, interns).as_str()),
Region(region) => { Region(region) => {
@ -380,7 +380,7 @@ impl ReportText {
} }
} }
Module(module_id) => { Module(module_id) => {
buf.push_str(&palette.module_name.render(&module_id.name())); buf.push_str(&palette.module_name.render(&interns.module_name(module_id)));
} }
Type(content) => match content { Type(content) => match content {
Content::FlexVar(flex_var) => buf.push_str(&palette.flex_var.render( Content::FlexVar(flex_var) => buf.push_str(&palette.flex_var.render(