mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
clippy
This commit is contained in:
parent
1d32be0818
commit
0643efa571
5 changed files with 21 additions and 26 deletions
|
@ -162,8 +162,7 @@ fn jit_to_ast_help<'a>(
|
|||
Content::Structure(FlatType::TagUnion(tags, _)) => {
|
||||
debug_assert_eq!(tags.len(), 1);
|
||||
|
||||
let (tag_name, payload_vars) =
|
||||
unpack_single_element_tag_union(&env.subs, *tags);
|
||||
let (tag_name, payload_vars) = unpack_single_element_tag_union(env.subs, *tags);
|
||||
|
||||
Ok(single_tag_union_to_ast(
|
||||
env,
|
||||
|
@ -216,7 +215,7 @@ fn jit_to_ast_help<'a>(
|
|||
debug_assert_eq!(union_layouts.len(), tags.len());
|
||||
|
||||
let tags_vec: std::vec::Vec<(TagName, std::vec::Vec<Variable>)> = tags
|
||||
.unsorted_iterator(&env.subs, Variable::EMPTY_TAG_UNION)
|
||||
.unsorted_iterator(env.subs, Variable::EMPTY_TAG_UNION)
|
||||
.map(|(a, b)| (a.clone(), b.to_vec()))
|
||||
.collect();
|
||||
|
||||
|
@ -450,7 +449,7 @@ fn ptr_to_ast<'a>(
|
|||
Content::Structure(FlatType::TagUnion(tags, _)) => {
|
||||
debug_assert_eq!(tags.len(), 1);
|
||||
|
||||
let (tag_name, payload_vars) = unpack_single_element_tag_union(&env.subs, *tags);
|
||||
let (tag_name, payload_vars) = unpack_single_element_tag_union(env.subs, *tags);
|
||||
single_tag_union_to_ast(env, ptr, field_layouts, tag_name, payload_vars)
|
||||
}
|
||||
Content::Structure(FlatType::FunctionOrTagUnion(tag_name, _, _)) => {
|
||||
|
@ -681,7 +680,7 @@ fn unpack_two_element_tag_union(
|
|||
let subs_slice = subs[payload_vars_index].as_subs_slice();
|
||||
let payload_vars2 = subs.get_subs_slice(*subs_slice);
|
||||
|
||||
(tag_name1, payload_vars2, tag_name2, payload_vars2)
|
||||
(tag_name1, payload_vars1, tag_name2, payload_vars2)
|
||||
}
|
||||
|
||||
fn bool_to_ast<'a>(env: &Env<'a, '_>, value: bool, content: &Content) -> Expr<'a> {
|
||||
|
@ -730,8 +729,7 @@ fn bool_to_ast<'a>(env: &Env<'a, '_>, value: bool, content: &Content) -> Expr<'a
|
|||
}
|
||||
}
|
||||
FlatType::TagUnion(tags, _) if tags.len() == 1 => {
|
||||
let (tag_name, payload_vars) =
|
||||
unpack_single_element_tag_union(&env.subs, *tags);
|
||||
let (tag_name, payload_vars) = unpack_single_element_tag_union(env.subs, *tags);
|
||||
|
||||
let loc_tag_expr = {
|
||||
let tag_name = &tag_name.as_ident_str(env.interns, env.home);
|
||||
|
@ -767,7 +765,7 @@ fn bool_to_ast<'a>(env: &Env<'a, '_>, value: bool, content: &Content) -> Expr<'a
|
|||
}
|
||||
FlatType::TagUnion(tags, _) if tags.len() == 2 => {
|
||||
let (tag_name_1, payload_vars_1, tag_name_2, payload_vars_2) =
|
||||
unpack_two_element_tag_union(&env.subs, *tags);
|
||||
unpack_two_element_tag_union(env.subs, *tags);
|
||||
|
||||
debug_assert!(payload_vars_1.is_empty());
|
||||
debug_assert!(payload_vars_2.is_empty());
|
||||
|
@ -846,8 +844,7 @@ fn byte_to_ast<'a>(env: &Env<'a, '_>, value: u8, content: &Content) -> Expr<'a>
|
|||
}
|
||||
}
|
||||
FlatType::TagUnion(tags, _) if tags.len() == 1 => {
|
||||
let (tag_name, payload_vars) =
|
||||
unpack_single_element_tag_union(&env.subs, *tags);
|
||||
let (tag_name, payload_vars) = unpack_single_element_tag_union(env.subs, *tags);
|
||||
|
||||
let loc_tag_expr = {
|
||||
let tag_name = &tag_name.as_ident_str(env.interns, env.home);
|
||||
|
@ -886,7 +883,7 @@ fn byte_to_ast<'a>(env: &Env<'a, '_>, value: u8, content: &Content) -> Expr<'a>
|
|||
debug_assert!(tags.len() > 2);
|
||||
|
||||
let tags_vec: std::vec::Vec<(TagName, std::vec::Vec<Variable>)> = tags
|
||||
.unsorted_iterator(&env.subs, Variable::EMPTY_TAG_UNION)
|
||||
.unsorted_iterator(env.subs, Variable::EMPTY_TAG_UNION)
|
||||
.map(|(a, b)| (a.clone(), b.to_vec()))
|
||||
.collect();
|
||||
|
||||
|
@ -971,8 +968,7 @@ fn num_to_ast<'a>(env: &Env<'a, '_>, num_expr: Expr<'a>, content: &Content) -> E
|
|||
// This was a single-tag union that got unwrapped at runtime.
|
||||
debug_assert_eq!(tags.len(), 1);
|
||||
|
||||
let (tag_name, payload_vars) =
|
||||
unpack_single_element_tag_union(&env.subs, *tags);
|
||||
let (tag_name, payload_vars) = unpack_single_element_tag_union(env.subs, *tags);
|
||||
|
||||
// If this tag union represents a number, skip right to
|
||||
// returning tis as an Expr::Num
|
||||
|
|
|
@ -446,7 +446,7 @@ fn write_sorted_tags<'a>(
|
|||
// If the `ext` contains tags, merge them into the list of tags.
|
||||
// this can occur when inferring mutually recursive tags
|
||||
let mut from_ext = Default::default();
|
||||
let ext_content = chase_ext_tag_union(subs, ext_var, &mut from_ext);
|
||||
let _ext_content = chase_ext_tag_union(subs, ext_var, &mut from_ext);
|
||||
|
||||
for (tag_name, arguments) in from_ext.iter() {
|
||||
sorted_fields.push((tag_name, arguments));
|
||||
|
|
|
@ -1119,7 +1119,7 @@ pub fn is_empty_tag_union(subs: &Subs, mut var: Variable) -> bool {
|
|||
var = *actual_var;
|
||||
}
|
||||
|
||||
other => {
|
||||
_other => {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1454,7 +1454,7 @@ fn explicit_substitute(
|
|||
Structure(Func(arg_vars, new_closure_var, new_ret_var)),
|
||||
);
|
||||
}
|
||||
TagUnion(mut tags, ext_var) => {
|
||||
TagUnion(tags, ext_var) => {
|
||||
let new_ext_var = explicit_substitute(subs, from, to, ext_var, seen);
|
||||
|
||||
let mut new_slices = Vec::new();
|
||||
|
|
|
@ -1617,16 +1617,16 @@ pub fn gather_tags_unsorted_iter(
|
|||
var = *sub_ext;
|
||||
}
|
||||
|
||||
Structure(FunctionOrTagUnion(tag_name_index, _, sub_ext)) => {
|
||||
todo!()
|
||||
Structure(FunctionOrTagUnion(_tag_name_index, _, _sub_ext)) => {
|
||||
todo!("this variant does not use SOA yet, and therefore this case is unreachable right now")
|
||||
// let sub_fields: UnionTags = (*tag_name_index).into();
|
||||
// stack.push(sub_fields);
|
||||
//
|
||||
// var = *sub_ext;
|
||||
}
|
||||
|
||||
Structure(RecursiveTagUnion(_, sub_fields, sub_ext)) => {
|
||||
todo!()
|
||||
Structure(RecursiveTagUnion(_, _sub_fields, _sub_ext)) => {
|
||||
todo!("this variant does not use SOA yet, and therefore this case is unreachable right now")
|
||||
// stack.push(*sub_fields);
|
||||
//
|
||||
// var = *sub_ext;
|
||||
|
|
|
@ -630,6 +630,7 @@ fn separate_union_tags(
|
|||
(separate(it1, it2), new_ext1, new_ext2)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn unify_tag_union_new(
|
||||
subs: &mut Subs,
|
||||
pool: &mut Pool,
|
||||
|
@ -1458,7 +1459,7 @@ fn unify_flat_type(
|
|||
debug_assert!(is_recursion_var(subs, *recursion_var));
|
||||
// this never happens in type-correct programs, but may happen if there is a type error
|
||||
let union1 = gather_tags(subs, tags1.clone(), *ext1);
|
||||
let union2 = gather_tags_new(subs, tags2.clone(), *ext2);
|
||||
let union2 = gather_tags_new(subs, *tags2, *ext2);
|
||||
|
||||
unify_tag_union(
|
||||
subs,
|
||||
|
@ -1472,7 +1473,7 @@ fn unify_flat_type(
|
|||
|
||||
(TagUnion(tags1, ext1), RecursiveTagUnion(recursion_var, tags2, ext2)) => {
|
||||
debug_assert!(is_recursion_var(subs, *recursion_var));
|
||||
let union1 = gather_tags_new(subs, tags1.clone(), *ext1);
|
||||
let union1 = gather_tags_new(subs, *tags1, *ext1);
|
||||
let union2 = gather_tags(subs, tags2.clone(), *ext2);
|
||||
|
||||
unify_tag_union_not_recursive_recursive(subs, pool, ctx, union1, union2, *recursion_var)
|
||||
|
@ -1573,7 +1574,7 @@ fn unify_flat_type(
|
|||
}
|
||||
(TagUnion(tags1, ext1), FunctionOrTagUnion(tag_name, _, ext2)) => {
|
||||
let tag_name = subs[*tag_name].clone();
|
||||
let union1 = gather_tags_new(subs, tags1.clone(), *ext1);
|
||||
let union1 = gather_tags_new(subs, *tags1, *ext1);
|
||||
|
||||
let mut tags2 = MutMap::default();
|
||||
tags2.insert(tag_name, vec![]);
|
||||
|
@ -1587,7 +1588,7 @@ fn unify_flat_type(
|
|||
tags1.insert(tag_name, vec![]);
|
||||
|
||||
let union1 = gather_tags(subs, tags1, *ext1);
|
||||
let union2 = gather_tags_new(subs, tags2.clone(), *ext2);
|
||||
let union2 = gather_tags_new(subs, *tags2, *ext2);
|
||||
|
||||
unify_tag_union(subs, pool, ctx, union1, union2, (None, None))
|
||||
}
|
||||
|
@ -1906,8 +1907,6 @@ fn unify_function_or_tag_union_and_func(
|
|||
function_lambda_set: Variable,
|
||||
left: bool,
|
||||
) -> Outcome {
|
||||
use FlatType::*;
|
||||
|
||||
let tag_name = subs[*tag_name_index].clone();
|
||||
|
||||
let mut new_tags = MutMap::with_capacity_and_hasher(1, default_hasher());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue