diff --git a/compiler/can/src/def.rs b/compiler/can/src/def.rs index 1c8f99f3ff..0c44cebd0d 100644 --- a/compiler/can/src/def.rs +++ b/compiler/can/src/def.rs @@ -1642,7 +1642,11 @@ fn make_tag_union_recursive<'a>( can_report_error, ), _ => { - let problem = roc_types::types::Problem::CyclicAlias(symbol, region, others.clone()); + let problem = roc_types::types::Problem::CyclicAlias( + symbol, + region, + others.clone().into_boxed_slice(), + ); *typ = Type::Erroneous(problem); // ensure cyclic error is only reported for one element of the cycle diff --git a/compiler/reporting/src/error/canonicalize.rs b/compiler/reporting/src/error/canonicalize.rs index 1a259cb8f6..25ea1cf7ed 100644 --- a/compiler/reporting/src/error/canonicalize.rs +++ b/compiler/reporting/src/error/canonicalize.rs @@ -146,7 +146,7 @@ pub fn can_problem<'b>( }, ), Problem::CyclicAlias(symbol, region, others) => { - let (doc, title) = crate::error::r#type::cyclic_alias(alloc, symbol, region, others); + let (doc, title) = crate::error::r#type::cyclic_alias(alloc, symbol, region, &*others); return Report { title, diff --git a/compiler/reporting/src/error/type.rs b/compiler/reporting/src/error/type.rs index e5c6763279..529ecbe1ac 100644 --- a/compiler/reporting/src/error/type.rs +++ b/compiler/reporting/src/error/type.rs @@ -91,7 +91,7 @@ pub fn type_problem<'b>( } } CyclicAlias(symbol, region, others) => { - let (doc, title) = cyclic_alias(alloc, symbol, region, others); + let (doc, title) = cyclic_alias(alloc, symbol, region, &*others); Report { title, @@ -110,7 +110,7 @@ pub fn cyclic_alias<'b>( alloc: &'b RocDocAllocator<'b>, symbol: Symbol, region: roc_region::all::Region, - others: Vec, + others: &[Symbol], ) -> (RocDocBuilder<'b>, String) { let doc = if others.is_empty() { alloc.stack(vec![ @@ -140,7 +140,7 @@ pub fn cyclic_alias<'b>( alloc.symbol_unqualified(symbol), others .into_iter() - .map(|other| alloc.symbol_unqualified(other)) + .map(|other| alloc.symbol_unqualified(*other)) .collect::>(), ), alloc.reflow("Recursion in aliases is only allowed if recursion happens behind a tag."), diff --git a/compiler/solve/tests/solve_expr.rs b/compiler/solve/tests/solve_expr.rs index 55cbeef6c9..7ccc1f2910 100644 --- a/compiler/solve/tests/solve_expr.rs +++ b/compiler/solve/tests/solve_expr.rs @@ -4497,8 +4497,9 @@ mod solve_expr { std::mem::size_of::(), std::mem::size_of::(), std::mem::size_of::(), + std::mem::size_of::(), ); - assert_eq!(query, (40, 96, 80, 72, 64)) + assert_eq!(query, (40, 96, 80, 72, 64, 32)) } } diff --git a/compiler/types/src/types.rs b/compiler/types/src/types.rs index 5859862e03..91643ddecb 100644 --- a/compiler/types/src/types.rs +++ b/compiler/types/src/types.rs @@ -1117,7 +1117,7 @@ pub struct Alias { pub enum Problem { CanonicalizationProblem, CircularType(Symbol, Box, Region), - CyclicAlias(Symbol, Region, Vec), + CyclicAlias(Symbol, Region, Box<[Symbol]>), UnrecognizedIdent(InlinableString), Shadowed(Region, Located), BadTypeArguments {