mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Remove unused EmptyTuple variant from FlatType enum
This commit is contained in:
parent
fe029c85b6
commit
edd0bb553d
22 changed files with 34 additions and 111 deletions
|
@ -16,9 +16,6 @@ pub static WILDCARD: &str = "*";
|
|||
static EMPTY_RECORD: &str = "{}";
|
||||
static EMPTY_TAG_UNION: &str = "[]";
|
||||
|
||||
// TODO: since we technically don't support empty tuples at the source level, this should probably be removed
|
||||
static EMPTY_TUPLE: &str = "()";
|
||||
|
||||
/// Requirements for parentheses.
|
||||
///
|
||||
/// If we're inside a function (that is, this is either an argument or a return
|
||||
|
@ -402,11 +399,7 @@ fn find_names_needed(
|
|||
find_under_alias,
|
||||
);
|
||||
}
|
||||
Error
|
||||
| Structure(EmptyRecord)
|
||||
| Structure(EmptyTuple)
|
||||
| Structure(EmptyTagUnion)
|
||||
| ErasedLambda => {
|
||||
Error | Structure(EmptyRecord) | Structure(EmptyTagUnion) | ErasedLambda => {
|
||||
// Errors and empty records don't need names.
|
||||
}
|
||||
}
|
||||
|
@ -1113,7 +1106,6 @@ fn write_flat_type<'a>(
|
|||
pol,
|
||||
),
|
||||
EmptyRecord => buf.push_str(EMPTY_RECORD),
|
||||
EmptyTuple => buf.push_str(EMPTY_TUPLE),
|
||||
EmptyTagUnion => buf.push_str(EMPTY_TAG_UNION),
|
||||
Func(args, closure, ret) => write_fn(
|
||||
env,
|
||||
|
@ -1220,19 +1212,12 @@ fn write_flat_type<'a>(
|
|||
|
||||
buf.push_str(" )");
|
||||
|
||||
match subs.get_content_without_compacting(ext_var) {
|
||||
Content::Structure(EmptyTuple) => {
|
||||
// This is a closed tuple. We're done!
|
||||
}
|
||||
_ => {
|
||||
// This is an open tuple, so print the variable
|
||||
// right after the ')'
|
||||
//
|
||||
// e.g. the "*" at the end of `( I64, I64 )*`
|
||||
// or the "r" at the end of `( I64, I64 )r`
|
||||
write_content(env, ctx, ext_var, subs, buf, parens, pol)
|
||||
}
|
||||
}
|
||||
// This is an open tuple, so print the variable
|
||||
// right after the ')'
|
||||
//
|
||||
// e.g. the "*" at the end of `( I64, I64 )*`
|
||||
// or the "r" at the end of `( I64, I64 )r`
|
||||
write_content(env, ctx, ext_var, subs, buf, parens, pol)
|
||||
}
|
||||
TagUnion(tags, ext_var) => {
|
||||
buf.push('[');
|
||||
|
|
|
@ -815,7 +815,6 @@ fn subs_fmt_flat_type(this: &FlatType, subs: &Subs, f: &mut fmt::Formatter) -> f
|
|||
write!(f, "]<{new_ext:?}> as <{rec:?}>")
|
||||
}
|
||||
FlatType::EmptyRecord => write!(f, "EmptyRecord"),
|
||||
FlatType::EmptyTuple => write!(f, "EmptyTuple"),
|
||||
FlatType::EmptyTagUnion => write!(f, "EmptyTagUnion"),
|
||||
}
|
||||
}
|
||||
|
@ -2512,7 +2511,6 @@ pub enum FlatType {
|
|||
|
||||
RecursiveTagUnion(Variable, UnionTags, TagExt),
|
||||
EmptyRecord,
|
||||
EmptyTuple,
|
||||
EmptyTagUnion,
|
||||
}
|
||||
|
||||
|
@ -3409,7 +3407,7 @@ fn occurs(
|
|||
|
||||
short_circuit_help(subs, root_var, ctx, ext_var)
|
||||
}
|
||||
EmptyRecord | EmptyTuple | EmptyTagUnion => Ok(()),
|
||||
EmptyRecord | EmptyTagUnion => Ok(()),
|
||||
},
|
||||
Alias(_, args, _, _) => {
|
||||
// THEORY: we only need to explore the args, as that is the surface of all
|
||||
|
@ -3599,7 +3597,7 @@ fn explicit_substitute(
|
|||
subs.set_content(in_var, Structure(Tuple(vars_by_elem, new_ext)));
|
||||
}
|
||||
|
||||
EmptyRecord | EmptyTuple | EmptyTagUnion => {}
|
||||
EmptyRecord | EmptyTagUnion => {}
|
||||
}
|
||||
|
||||
in_var
|
||||
|
@ -3782,9 +3780,7 @@ fn get_var_names(
|
|||
accum
|
||||
}
|
||||
|
||||
FlatType::EmptyRecord | FlatType::EmptyTuple | FlatType::EmptyTagUnion => {
|
||||
taken_names
|
||||
}
|
||||
FlatType::EmptyRecord | FlatType::EmptyTagUnion => taken_names,
|
||||
|
||||
FlatType::Record(vars_by_field, ext) => {
|
||||
let mut accum = get_var_names(subs, ext, taken_names);
|
||||
|
@ -4130,7 +4126,6 @@ fn flat_type_to_err_type(
|
|||
}
|
||||
|
||||
EmptyRecord => ErrorType::Record(SendMap::default(), TypeExt::Closed),
|
||||
EmptyTuple => ErrorType::Tuple(Vec::default(), TypeExt::Closed),
|
||||
EmptyTagUnion => ErrorType::TagUnion(SendMap::default(), TypeExt::Closed, pol),
|
||||
|
||||
Record(vars_by_field, ext) => {
|
||||
|
@ -4586,7 +4581,6 @@ impl StorageSubs {
|
|||
ext.map(|v| Self::offset_variable(offsets, v)),
|
||||
),
|
||||
FlatType::EmptyRecord => FlatType::EmptyRecord,
|
||||
FlatType::EmptyTuple => FlatType::EmptyTuple,
|
||||
FlatType::EmptyTagUnion => FlatType::EmptyTagUnion,
|
||||
}
|
||||
}
|
||||
|
@ -4881,7 +4875,7 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
Func(new_arguments, new_closure_var, new_ret_var)
|
||||
}
|
||||
|
||||
same @ EmptyRecord | same @ EmptyTuple | same @ EmptyTagUnion => same,
|
||||
same @ EmptyRecord | same @ EmptyTagUnion => same,
|
||||
|
||||
Record(fields, ext) => {
|
||||
let record_fields = {
|
||||
|
@ -5351,7 +5345,7 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
Func(new_arguments, new_closure_var, new_ret_var)
|
||||
}
|
||||
|
||||
same @ EmptyRecord | same @ EmptyTuple | same @ EmptyTagUnion => same,
|
||||
same @ EmptyRecord | same @ EmptyTagUnion => same,
|
||||
|
||||
Record(fields, ext) => {
|
||||
let record_fields = {
|
||||
|
@ -5729,7 +5723,7 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) {
|
|||
stack.push(closure_var);
|
||||
}
|
||||
|
||||
EmptyRecord | EmptyTuple | EmptyTagUnion => (),
|
||||
EmptyRecord | EmptyTagUnion => (),
|
||||
|
||||
Record(fields, ext) => {
|
||||
let fields = *fields;
|
||||
|
@ -5880,7 +5874,7 @@ pub fn get_member_lambda_sets_at_region(subs: &Subs, var: Variable, target_regio
|
|||
);
|
||||
stack.push(ext.var());
|
||||
}
|
||||
FlatType::EmptyRecord | FlatType::EmptyTuple | FlatType::EmptyTagUnion => {}
|
||||
FlatType::EmptyRecord | FlatType::EmptyTagUnion => {}
|
||||
},
|
||||
Content::Alias(_, _, real_var, _) => {
|
||||
stack.push(*real_var);
|
||||
|
@ -5955,7 +5949,6 @@ fn is_inhabited(subs: &Subs, var: Variable) -> bool {
|
|||
}
|
||||
FlatType::FunctionOrTagUnion(_, _, _) => {}
|
||||
FlatType::EmptyRecord => {}
|
||||
FlatType::EmptyTuple => {}
|
||||
FlatType::EmptyTagUnion => {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue