mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
use a SubsIndex instead of Box
This commit is contained in:
parent
dd73428dc1
commit
ad3d006a11
7 changed files with 65 additions and 30 deletions
|
@ -499,7 +499,7 @@ fn write_flat_type(env: &Env, flat_type: &FlatType, subs: &Subs, buf: &mut Strin
|
|||
buf.push_str("[ ");
|
||||
|
||||
let mut tags: MutMap<TagName, _> = MutMap::default();
|
||||
tags.insert(*tag_name.clone(), vec![]);
|
||||
tags.insert(subs[*tag_name].clone(), vec![]);
|
||||
let ext_content = write_sorted_tags(env, subs, buf, &tags, *ext_var);
|
||||
|
||||
buf.push_str(" ]");
|
||||
|
@ -562,7 +562,7 @@ pub fn chase_ext_tag_union<'a>(
|
|||
chase_ext_tag_union(subs, *ext_var, fields)
|
||||
}
|
||||
Content::Structure(FunctionOrTagUnion(tag_name, _, ext_var)) => {
|
||||
fields.push((*tag_name.clone(), vec![]));
|
||||
fields.push((subs[*tag_name].clone(), vec![]));
|
||||
|
||||
chase_ext_tag_union(subs, *ext_var, fields)
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@ impl SolvedType {
|
|||
FunctionOrTagUnion(tag_name, symbol, ext_var) => {
|
||||
let ext = Self::from_var_help(subs, recursion_vars, *ext_var);
|
||||
|
||||
SolvedType::FunctionOrTagUnion(*tag_name.clone(), *symbol, Box::new(ext))
|
||||
SolvedType::FunctionOrTagUnion(subs[*tag_name].clone(), *symbol, Box::new(ext))
|
||||
}
|
||||
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
||||
recursion_vars.insert(subs, *rec_var);
|
||||
|
|
|
@ -100,6 +100,20 @@ impl std::ops::Index<SubsIndex<Lowercase>> for Subs {
|
|||
}
|
||||
}
|
||||
|
||||
impl std::ops::Index<SubsIndex<TagName>> for Subs {
|
||||
type Output = TagName;
|
||||
|
||||
fn index(&self, index: SubsIndex<TagName>) -> &Self::Output {
|
||||
&self.tag_names[index.start as usize]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<TagName>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<TagName>) -> &mut Self::Output {
|
||||
&mut self.tag_names[index.start as usize]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<Lowercase>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<Lowercase>) -> &mut Self::Output {
|
||||
&mut self.field_names[index.start as usize]
|
||||
|
@ -833,7 +847,7 @@ pub enum FlatType {
|
|||
Func(VariableSubsSlice, Variable, Variable),
|
||||
Record(RecordFields, Variable),
|
||||
TagUnion(MutMap<TagName, Vec<Variable>>, Variable),
|
||||
FunctionOrTagUnion(Box<TagName>, Symbol, Variable),
|
||||
FunctionOrTagUnion(SubsIndex<TagName>, Symbol, Variable),
|
||||
RecursiveTagUnion(Variable, MutMap<TagName, Vec<Variable>>, Variable),
|
||||
Erroneous(Box<Problem>),
|
||||
EmptyRecord,
|
||||
|
@ -1661,7 +1675,7 @@ fn flat_type_to_err_type(
|
|||
}
|
||||
|
||||
FunctionOrTagUnion(tag_name, _, ext_var) => {
|
||||
let tag_name = *tag_name;
|
||||
let tag_name = subs[tag_name].clone();
|
||||
|
||||
let mut err_tags = SendMap::default();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue