mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
get rid of UnitWithArguments
This commit is contained in:
parent
29244112df
commit
639c1e5fa3
2 changed files with 5 additions and 16 deletions
|
@ -3270,7 +3270,6 @@ impl From<Symbol> for TagOrClosure {
|
|||
pub enum UnionVariant<'a> {
|
||||
Never,
|
||||
Unit,
|
||||
UnitWithArguments,
|
||||
BoolUnion {
|
||||
ttrue: TagOrClosure,
|
||||
ffalse: TagOrClosure,
|
||||
|
@ -3628,19 +3627,13 @@ where
|
|||
|
||||
// just one tag in the union (but with arguments) can be a struct
|
||||
let mut layouts = Vec::with_capacity_in(tags_vec.len(), env.arena);
|
||||
let mut contains_zero_sized = false;
|
||||
|
||||
for var in arguments {
|
||||
let Cacheable(result, criteria) = Layout::from_var(env, var);
|
||||
cache_criteria.and(criteria);
|
||||
match result {
|
||||
Ok(layout) => {
|
||||
// Drop any zero-sized arguments like {}
|
||||
if !layout.is_dropped_because_empty() {
|
||||
layouts.push(layout);
|
||||
} else {
|
||||
contains_zero_sized = true;
|
||||
}
|
||||
layouts.push(layout);
|
||||
}
|
||||
Err(LayoutProblem::UnresolvedTypeVar(_)) => {
|
||||
// If we encounter an unbound type var (e.g. `Ok *`)
|
||||
|
@ -3663,11 +3656,7 @@ where
|
|||
});
|
||||
|
||||
if layouts.is_empty() {
|
||||
if contains_zero_sized {
|
||||
Cacheable(UnionVariant::UnitWithArguments, cache_criteria)
|
||||
} else {
|
||||
Cacheable(UnionVariant::Unit, cache_criteria)
|
||||
}
|
||||
Cacheable(UnionVariant::Unit, cache_criteria)
|
||||
} else if let Some(rec_var) = opt_rec_var {
|
||||
let variant = UnionVariant::Wrapped(WrappedVariant::NonNullableUnwrapped {
|
||||
tag_name: tag_name.into(),
|
||||
|
@ -3866,7 +3855,7 @@ where
|
|||
|
||||
let result = match variant {
|
||||
Never => Layout::VOID,
|
||||
Unit | UnitWithArguments => Layout::UNIT,
|
||||
Unit => Layout::UNIT,
|
||||
BoolUnion { .. } => Layout::bool(),
|
||||
ByteUnion(_) => Layout::u8(),
|
||||
Newtype {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue