Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
bhansconnect committed Nov 20, 2023
1 parent c2b0980 commit ed88232
Showing 1 changed file with 52 additions and 56 deletions.
108 changes: 52 additions & 56 deletions crates/compiler/mono/src/ir/pattern.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::ir::{substitute_in_exprs, Env, Expr, Procs, Stmt};
use crate::layout::{
self, Builtin, InLayout, LambdaName, Layout, LayoutCache, LayoutInterner, LayoutProblem,
LayoutRepr, LayoutWrapper, SemanticRepr, TagIdIntType, UnionLayout, WrappedVariant,
self, Builtin, InLayout, Layout, LayoutCache, LayoutInterner, LayoutProblem, LayoutRepr,
TagIdIntType, UnionLayout, WrappedVariant,
};
use bumpalo::collections::Vec;
use roc_builtins::bitcode::{FloatWidth, IntWidth};
Expand Down Expand Up @@ -1544,66 +1544,62 @@ fn store_list_pattern<'a>(
}
}

match opt_rest {
Some((index, Some(rest_sym))) => {
let usize_layout = Layout::usize(env.target_info);
if let Some((index, Some(rest_sym))) = opt_rest {
let usize_layout = Layout::usize(env.target_info);

let total_dropped = elements.len();
let total_dropped = elements.len();

let total_dropped_sym = env.unique_symbol();
let total_dropped_expr =
Expr::Literal(Literal::Int((total_dropped as u128).to_ne_bytes()));
let total_dropped_sym = env.unique_symbol();
let total_dropped_expr = Expr::Literal(Literal::Int((total_dropped as u128).to_ne_bytes()));

let list_len_sym = env.unique_symbol();
let list_len_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::ListLen,
update_mode: env.next_update_mode_id(),
},
arguments: env.arena.alloc([list_sym]),
});
let list_len_sym = env.unique_symbol();
let list_len_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::ListLen,
update_mode: env.next_update_mode_id(),
},
arguments: env.arena.alloc([list_sym]),
});

let rest_len_sym = env.unique_symbol();
let rest_len_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::NumSub,
update_mode: env.next_update_mode_id(),
},
arguments: env.arena.alloc([list_len_sym, total_dropped_sym]),
});
let rest_len_sym = env.unique_symbol();
let rest_len_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::NumSub,
update_mode: env.next_update_mode_id(),
},
arguments: env.arena.alloc([list_len_sym, total_dropped_sym]),
});

let start_sym = env.unique_symbol();
let start_expr = Expr::Literal(Literal::Int((*index as u128).to_ne_bytes()));
let start_sym = env.unique_symbol();
let start_expr = Expr::Literal(Literal::Int((*index as u128).to_ne_bytes()));

let rest_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::ListSublist,
update_mode: env.next_update_mode_id(),
},
arguments: env.arena.alloc([list_sym, start_sym, rest_len_sym]),
});
stmt = Stmt::Let(*rest_sym, rest_expr, list_layout, env.arena.alloc(stmt));
stmt = Stmt::Let(start_sym, start_expr, usize_layout, env.arena.alloc(stmt));
stmt = Stmt::Let(
rest_len_sym,
rest_len_expr,
usize_layout,
env.arena.alloc(stmt),
);
stmt = Stmt::Let(
list_len_sym,
list_len_expr,
usize_layout,
env.arena.alloc(stmt),
);
stmt = Stmt::Let(
total_dropped_sym,
total_dropped_expr,
usize_layout,
env.arena.alloc(stmt),
);
}
_ => {}
let rest_expr = Expr::Call(Call {
call_type: CallType::LowLevel {
op: LowLevel::ListSublist,
update_mode: env.next_update_mode_id(),
},
arguments: env.arena.alloc([list_sym, start_sym, rest_len_sym]),
});
stmt = Stmt::Let(*rest_sym, rest_expr, list_layout, env.arena.alloc(stmt));
stmt = Stmt::Let(start_sym, start_expr, usize_layout, env.arena.alloc(stmt));
stmt = Stmt::Let(
rest_len_sym,
rest_len_expr,
usize_layout,
env.arena.alloc(stmt),
);
stmt = Stmt::Let(
list_len_sym,
list_len_expr,
usize_layout,
env.arena.alloc(stmt),
);
stmt = Stmt::Let(
total_dropped_sym,
total_dropped_expr,
usize_layout,
env.arena.alloc(stmt),
);
}

if is_productive {
Expand Down

0 comments on commit ed88232

Please sign in to comment.