mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
ugh clippy
This commit is contained in:
parent
fb82897e3d
commit
1cd8b21670
1 changed files with 15 additions and 14 deletions
|
@ -1143,7 +1143,7 @@ fn test_to_equality<'a>(
|
||||||
// TODO procs and layout are currently unused, but potentially required
|
// TODO procs and layout are currently unused, but potentially required
|
||||||
// for defining optional fields?
|
// for defining optional fields?
|
||||||
// if not, do remove
|
// if not, do remove
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments, clippy::needless_collect)]
|
||||||
fn decide_to_branching<'a>(
|
fn decide_to_branching<'a>(
|
||||||
env: &mut Env<'a, '_>,
|
env: &mut Env<'a, '_>,
|
||||||
procs: &mut Procs<'a>,
|
procs: &mut Procs<'a>,
|
||||||
|
@ -1256,6 +1256,9 @@ fn decide_to_branching<'a>(
|
||||||
|
|
||||||
// TODO There must be some way to remove this iterator/loop
|
// TODO There must be some way to remove this iterator/loop
|
||||||
let nr = (tests.len() as i64) - 1 + (guard.is_some() as i64);
|
let nr = (tests.len() as i64) - 1 + (guard.is_some() as i64);
|
||||||
|
|
||||||
|
let arena = env.arena;
|
||||||
|
|
||||||
let accum_symbols = std::iter::once(true_symbol)
|
let accum_symbols = std::iter::once(true_symbol)
|
||||||
.chain((0..nr).map(|_| env.unique_symbol()))
|
.chain((0..nr).map(|_| env.unique_symbol()))
|
||||||
.rev()
|
.rev()
|
||||||
|
@ -1268,15 +1271,14 @@ fn decide_to_branching<'a>(
|
||||||
let accum = accum_it.next().unwrap();
|
let accum = accum_it.next().unwrap();
|
||||||
let test_symbol = env.unique_symbol();
|
let test_symbol = env.unique_symbol();
|
||||||
|
|
||||||
let and_expr =
|
let and_expr = Expr::RunLowLevel(LowLevel::And, arena.alloc([test_symbol, accum]));
|
||||||
Expr::RunLowLevel(LowLevel::And, env.arena.alloc([test_symbol, accum]));
|
|
||||||
|
|
||||||
// write to the branching symbol
|
// write to the branching symbol
|
||||||
cond = Stmt::Let(
|
cond = Stmt::Let(
|
||||||
current_symbol,
|
current_symbol,
|
||||||
and_expr,
|
and_expr,
|
||||||
Layout::Builtin(Builtin::Int1),
|
Layout::Builtin(Builtin::Int1),
|
||||||
env.arena.alloc(cond),
|
arena.alloc(cond),
|
||||||
);
|
);
|
||||||
|
|
||||||
// calculate the guard value
|
// calculate the guard value
|
||||||
|
@ -1287,9 +1289,9 @@ fn decide_to_branching<'a>(
|
||||||
};
|
};
|
||||||
cond = Stmt::Join {
|
cond = Stmt::Join {
|
||||||
id,
|
id,
|
||||||
parameters: env.arena.alloc([param]),
|
parameters: arena.alloc([param]),
|
||||||
remainder: env.arena.alloc(stmt),
|
remainder: arena.alloc(stmt),
|
||||||
continuation: env.arena.alloc(cond),
|
continuation: arena.alloc(cond),
|
||||||
};
|
};
|
||||||
|
|
||||||
// load all the variables (the guard might need them);
|
// load all the variables (the guard might need them);
|
||||||
|
@ -1301,18 +1303,17 @@ fn decide_to_branching<'a>(
|
||||||
let test_symbol = env.unique_symbol();
|
let test_symbol = env.unique_symbol();
|
||||||
let test = Expr::RunLowLevel(
|
let test = Expr::RunLowLevel(
|
||||||
LowLevel::Eq,
|
LowLevel::Eq,
|
||||||
bumpalo::vec![in env.arena; lhs, rhs].into_bump_slice(),
|
bumpalo::vec![in arena; lhs, rhs].into_bump_slice(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let and_expr =
|
let and_expr = Expr::RunLowLevel(LowLevel::And, arena.alloc([test_symbol, accum]));
|
||||||
Expr::RunLowLevel(LowLevel::And, env.arena.alloc([test_symbol, accum]));
|
|
||||||
|
|
||||||
// write to the branching symbol
|
// write to the branching symbol
|
||||||
cond = Stmt::Let(
|
cond = Stmt::Let(
|
||||||
current_symbol,
|
current_symbol,
|
||||||
and_expr,
|
and_expr,
|
||||||
Layout::Builtin(Builtin::Int1),
|
Layout::Builtin(Builtin::Int1),
|
||||||
env.arena.alloc(cond),
|
arena.alloc(cond),
|
||||||
);
|
);
|
||||||
|
|
||||||
// write to the test symbol
|
// write to the test symbol
|
||||||
|
@ -1320,11 +1321,11 @@ fn decide_to_branching<'a>(
|
||||||
test_symbol,
|
test_symbol,
|
||||||
test,
|
test,
|
||||||
Layout::Builtin(Builtin::Int1),
|
Layout::Builtin(Builtin::Int1),
|
||||||
env.arena.alloc(cond),
|
arena.alloc(cond),
|
||||||
);
|
);
|
||||||
|
|
||||||
for (symbol, layout, expr) in new_stores.into_iter() {
|
for (symbol, layout, expr) in new_stores.into_iter() {
|
||||||
cond = Stmt::Let(symbol, expr, layout, env.arena.alloc(cond));
|
cond = Stmt::Let(symbol, expr, layout, arena.alloc(cond));
|
||||||
}
|
}
|
||||||
|
|
||||||
current_symbol = accum;
|
current_symbol = accum;
|
||||||
|
@ -1334,7 +1335,7 @@ fn decide_to_branching<'a>(
|
||||||
true_symbol,
|
true_symbol,
|
||||||
Expr::Literal(Literal::Bool(true)),
|
Expr::Literal(Literal::Bool(true)),
|
||||||
Layout::Builtin(Builtin::Int1),
|
Layout::Builtin(Builtin::Int1),
|
||||||
env.arena.alloc(cond),
|
arena.alloc(cond),
|
||||||
);
|
);
|
||||||
|
|
||||||
cond
|
cond
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue