turn vec into boxed slice

This commit is contained in:
Folkert 2021-08-02 22:21:23 +02:00
parent 203c5b53be
commit fd9d57d314
5 changed files with 12 additions and 7 deletions

View file

@ -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

View file

@ -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,

View file

@ -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<Symbol>,
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::<Vec<_>>(),
),
alloc.reflow("Recursion in aliases is only allowed if recursion happens behind a tag."),

View file

@ -4497,8 +4497,9 @@ mod solve_expr {
std::mem::size_of::<roc_types::subs::Content>(),
std::mem::size_of::<roc_types::subs::FlatType>(),
std::mem::size_of::<roc_types::types::Problem>(),
std::mem::size_of::<roc_module::ident::Ident>(),
);
assert_eq!(query, (40, 96, 80, 72, 64))
assert_eq!(query, (40, 96, 80, 72, 64, 32))
}
}

View file

@ -1117,7 +1117,7 @@ pub struct Alias {
pub enum Problem {
CanonicalizationProblem,
CircularType(Symbol, Box<ErrorType>, Region),
CyclicAlias(Symbol, Region, Vec<Symbol>),
CyclicAlias(Symbol, Region, Box<[Symbol]>),
UnrecognizedIdent(InlinableString),
Shadowed(Region, Located<Ident>),
BadTypeArguments {