Merge remote-tracking branch 'origin/clippy-1.54' into alias-nominal-equality

This commit is contained in:
Folkert 2021-07-30 14:25:50 +02:00
commit 13b05e54e8
81 changed files with 427 additions and 390 deletions

View File

@ -65,7 +65,7 @@ pub fn build_file<'a>(
};
let loaded = roc_load::file::load_and_monomorphize(
&arena,
arena,
roc_file_path.clone(),
stdlib,
src_dir.as_path(),
@ -128,11 +128,11 @@ pub fn build_file<'a>(
let cwd = roc_file_path.parent().unwrap();
let binary_path = cwd.join(&*loaded.output_path); // TODO should join ".exe" on Windows
let code_gen_timing = program::gen_from_mono_module(
&arena,
arena,
loaded,
&roc_file_path,
Triple::host(),
&app_o_file,
app_o_file,
opt_level,
emit_debug_info,
);

View File

@ -479,7 +479,7 @@ fn list_to_ast<'a>(
};
let arena = env.arena;
let mut output = Vec::with_capacity_in(len, &arena);
let mut output = Vec::with_capacity_in(len, arena);
let elem_size = elem_layout.stack_size(env.ptr_bytes) as usize;
for index in 0..len {
@ -533,7 +533,7 @@ where
{
let arena = env.arena;
let subs = env.subs;
let mut output = Vec::with_capacity_in(sequence.len(), &arena);
let mut output = Vec::with_capacity_in(sequence.len(), arena);
// We'll advance this as we iterate through the fields
let mut field_ptr = ptr as *const u8;
@ -560,7 +560,7 @@ fn struct_to_ast<'a>(
) -> Expr<'a> {
let arena = env.arena;
let subs = env.subs;
let mut output = Vec::with_capacity_in(field_layouts.len(), &arena);
let mut output = Vec::with_capacity_in(field_layouts.len(), arena);
// The fields, sorted alphabetically
let mut sorted_fields = {

View File

@ -219,7 +219,7 @@ pub fn gen_and_eval<'a>(
);
}
let lib = module_to_dylib(&env.module, &target, opt_level)
let lib = module_to_dylib(env.module, &target, opt_level)
.expect("Error loading compiled dylib for test");
let res_answer = unsafe {
eval::jit_to_ast(

View File

@ -3,6 +3,7 @@ extern crate pretty_assertions;
extern crate bumpalo;
extern crate inlinable_string;
extern crate roc_build;
extern crate roc_collections;
extern crate roc_load;
extern crate roc_module;
@ -16,6 +17,28 @@ mod cli_run {
use serial_test::serial;
use std::path::Path;
use std::sync::Once;
static INIT: Once = Once::new();
pub fn initialize() {
let env_path = "";
let env_home = "";
let emit_bin = "-femit-bin=examples/benchmarks/platform/host.o";
let zig_host_src = "examples/benchmarks/platform/host.zig";
let zig_str_path = "compiler/builtins/bitcodes/src/str.zig";
INIT.call_once_force(|_| {
roc_build::link::try_build_zig_host(
env_path,
env_home,
emit_bin,
zig_host_src,
zig_str_path,
);
});
}
#[cfg(not(target_os = "macos"))]
const ALLOW_VALGRIND: bool = true;
@ -126,6 +149,9 @@ mod cli_run {
let example = $example;
let file_name = example_file(dir_name, example.filename);
// make sure the `benchmarks` platform is already compiled
initialize();
// Check with and without optimizations
check_output_with_stdin(
&file_name,
@ -247,7 +273,6 @@ mod cli_run {
macro_rules! benchmarks {
($($test_name:ident => $benchmark:expr,)+) => {
$(
#[test]
#[cfg_attr(not(debug_assertions), serial(benchmark))]
fn $test_name() {
let benchmark = $benchmark;
@ -392,6 +417,7 @@ mod cli_run {
// We test benchmarks separately
if example_dir_name != "benchmarks" {
dbg!(&examples_dir, &example_dir_name);
all_examples.remove(example_dir_name.as_str()).unwrap_or_else(|| {
panic!("The example directory {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", examples_dir, example_dir_name);
});
@ -431,9 +457,15 @@ mod cli_run {
// Only app modules in this directory are considered benchmarks.
if "app".as_bytes() == buf {
all_benchmarks.remove(benchmark_file_name.as_str()).unwrap_or_else(|| {
panic!("The benchmark {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!", benchmarks_dir, benchmark_file_name);
});
match all_benchmarks.remove(benchmark_file_name.as_str()) {
Some(_) => {}
None => {
eprintln!(
r"The benchmark {}/{} does not have any corresponding tests in cli_run. Please add one, so if it ever stops working, we'll know about it right away!",
benchmarks_dir, benchmark_file_name
);
}
};
}
}
}

View File

@ -55,14 +55,24 @@ fn find_zig_str_path() -> PathBuf {
panic!("cannot find `str.zig`")
}
#[cfg(not(target_os = "macos"))]
fn build_zig_host(
pub fn try_build_zig_host(
env_path: &str,
env_home: &str,
emit_bin: &str,
zig_host_src: &str,
zig_str_path: &str,
) -> Output {
) -> Result<Output, std::io::Error> {
build_zig_host_help(env_path, env_home, emit_bin, zig_host_src, zig_str_path)
}
#[cfg(not(target_os = "macos"))]
fn build_zig_host_help(
env_path: &str,
env_home: &str,
emit_bin: &str,
zig_host_src: &str,
zig_str_path: &str,
) -> Result<Output, std::io::Error> {
Command::new("zig")
.env_clear()
.env("PATH", env_path)
@ -82,17 +92,16 @@ fn build_zig_host(
"c",
])
.output()
.unwrap()
}
#[cfg(target_os = "macos")]
fn build_zig_host(
pub fn build_zig_host_help(
env_path: &str,
env_home: &str,
emit_bin: &str,
zig_host_src: &str,
zig_str_path: &str,
) -> Output {
) -> Result<Output, std::io::Error> {
use serde_json::Value;
// Run `zig env` to find the location of zig's std/ directory
@ -155,7 +164,6 @@ fn build_zig_host(
"c",
])
.output()
.unwrap()
}
pub fn rebuild_host(host_input_path: &Path) {
@ -185,13 +193,14 @@ pub fn rebuild_host(host_input_path: &Path) {
validate_output(
"host.zig",
"zig",
build_zig_host(
try_build_zig_host(
&env_path,
&env_home,
&emit_bin,
zig_host_src.to_str().unwrap(),
zig_str_path.to_str().unwrap(),
),
)
.unwrap(),
);
} else {
// Compile host.c

View File

@ -132,7 +132,7 @@ pub fn gen_from_mono_module(
// Compile and add all the Procs before adding main
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
let env = roc_gen_llvm::llvm::build::Env {
arena: &arena,
arena,
builder: &builder,
dibuilder: &dibuilder,
compile_unit: &compile_unit,
@ -243,7 +243,7 @@ pub fn gen_from_mono_module(
target::target_machine(&target, convert_opt_level(opt_level), reloc, model).unwrap();
target_machine
.write_to_file(&env.module, FileType::Object, &app_o_file)
.write_to_file(env.module, FileType::Object, app_o_file)
.expect("Writing .o file failed");
}

View File

@ -64,7 +64,7 @@ impl Constraint {
fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDetail) {
for var in &detail.type_variables {
if !(declared.rigid_vars.contains(&var) || declared.flex_vars.contains(&var)) {
if !(declared.rigid_vars.contains(var) || declared.flex_vars.contains(var)) {
accum.type_variables.insert(*var);
}
}
@ -82,11 +82,11 @@ fn subtract(declared: &Declared, detail: &VariableDetail, accum: &mut VariableDe
// recursion vars should be always rigid
for var in &detail.recursion_variables {
if declared.flex_vars.contains(&var) {
if declared.flex_vars.contains(var) {
panic!("recursion variable {:?} is declared as flex", var);
}
if !declared.rigid_vars.contains(&var) {
if !declared.rigid_vars.contains(var) {
accum.recursion_variables.insert(*var);
}
}

View File

@ -380,7 +380,7 @@ pub fn sort_can_defs(
//
// In the above example, `f` cannot reference `a`, and in the closure
// a call to `f` cannot cycle back to `a`.
let mut loc_succ = local_successors(&references, &env.closures);
let mut loc_succ = local_successors(references, &env.closures);
// if the current symbol is a closure, peek into its body
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
@ -430,7 +430,7 @@ pub fn sort_can_defs(
//
// In the above example, `f` cannot reference `a`, and in the closure
// a call to `f` cannot cycle back to `a`.
let mut loc_succ = local_successors(&references, &env.closures);
let mut loc_succ = local_successors(references, &env.closures);
// if the current symbol is a closure, peek into its body
if let Some(References { lookups, .. }) = env.closures.get(symbol) {
@ -454,7 +454,7 @@ pub fn sort_can_defs(
let direct_successors = |symbol: &Symbol| -> ImSet<Symbol> {
match refs_by_symbol.get(symbol) {
Some((_, references)) => {
let mut loc_succ = local_successors(&references, &env.closures);
let mut loc_succ = local_successors(references, &env.closures);
// NOTE: if the symbol is a closure we DONT look into its body
@ -540,7 +540,7 @@ pub fn sort_can_defs(
),
Some((region, _)) => {
let expr_region =
can_defs_by_symbol.get(&symbol).unwrap().loc_expr.region;
can_defs_by_symbol.get(symbol).unwrap().loc_expr.region;
let entry = CycleEntry {
symbol: *symbol,
@ -662,11 +662,11 @@ fn group_to_declaration(
// for a definition, so every definition is only inserted (thus typechecked and emitted) once
let mut seen_pattern_regions: ImSet<Region> = ImSet::default();
for cycle in strongly_connected_components(&group, filtered_successors) {
for cycle in strongly_connected_components(group, filtered_successors) {
if cycle.len() == 1 {
let symbol = &cycle[0];
if let Some(can_def) = can_defs_by_symbol.get(&symbol) {
if let Some(can_def) = can_defs_by_symbol.get(symbol) {
let mut new_def = can_def.clone();
// Determine recursivity of closures that are not tail-recursive
@ -678,7 +678,7 @@ fn group_to_declaration(
*recursive = closure_recursivity(*symbol, closures);
}
let is_recursive = successors(&symbol).contains(&symbol);
let is_recursive = successors(symbol).contains(symbol);
if !seen_pattern_regions.contains(&new_def.loc_pattern.region) {
if is_recursive {
@ -854,7 +854,7 @@ fn canonicalize_pending_def<'a>(
};
for (_, (symbol, _)) in scope.idents() {
if !vars_by_symbol.contains_key(&symbol) {
if !vars_by_symbol.contains_key(symbol) {
continue;
}
@ -999,7 +999,7 @@ fn canonicalize_pending_def<'a>(
//
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
if let (
&ast::Pattern::Identifier(ref _name),
&ast::Pattern::Identifier(_name),
&Pattern::Identifier(ref defined_symbol),
&Closure {
function_type,
@ -1021,7 +1021,7 @@ fn canonicalize_pending_def<'a>(
// Since everywhere in the code it'll be referred to by its defined name,
// remove its generated name from the closure map. (We'll re-insert it later.)
let references = env.closures.remove(&symbol).unwrap_or_else(|| {
let references = env.closures.remove(symbol).unwrap_or_else(|| {
panic!(
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
symbol, env.closures
@ -1065,7 +1065,7 @@ fn canonicalize_pending_def<'a>(
// Store the referenced locals in the refs_by_symbol map, so we can later figure out
// which defined names reference each other.
for (_, (symbol, region)) in scope.idents() {
if !vars_by_symbol.contains_key(&symbol) {
if !vars_by_symbol.contains_key(symbol) {
continue;
}
@ -1111,7 +1111,7 @@ fn canonicalize_pending_def<'a>(
let outer_identifier = env.tailcallable_symbol;
if let (
&ast::Pattern::Identifier(ref _name),
&ast::Pattern::Identifier(_name),
&Pattern::Identifier(ref defined_symbol),
) = (&loc_pattern.value, &loc_can_pattern.value)
{
@ -1144,7 +1144,7 @@ fn canonicalize_pending_def<'a>(
//
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
if let (
&ast::Pattern::Identifier(ref _name),
&ast::Pattern::Identifier(_name),
&Pattern::Identifier(ref defined_symbol),
&Closure {
function_type,
@ -1166,7 +1166,7 @@ fn canonicalize_pending_def<'a>(
// Since everywhere in the code it'll be referred to by its defined name,
// remove its generated name from the closure map. (We'll re-insert it later.)
let references = env.closures.remove(&symbol).unwrap_or_else(|| {
let references = env.closures.remove(symbol).unwrap_or_else(|| {
panic!(
"Tried to remove symbol {:?} from procedures, but it was not found: {:?}",
symbol, env.closures
@ -1555,7 +1555,7 @@ fn correct_mutual_recursive_type_alias<'a>(
let mut loc_succ = alias.typ.symbols();
// remove anything that is not defined in the current block
loc_succ.retain(|key| symbols_introduced.contains(key));
loc_succ.remove(&symbol);
loc_succ.remove(symbol);
loc_succ
}

View File

@ -980,7 +980,7 @@ where
visited.insert(defined_symbol);
for local in refs.lookups.iter() {
if !visited.contains(&local) {
if !visited.contains(local) {
let other_refs: References =
references_from_local(*local, visited, refs_by_def, closures);
@ -991,7 +991,7 @@ where
}
for call in refs.calls.iter() {
if !visited.contains(&call) {
if !visited.contains(call) {
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
answer = answer.union(other_refs);
@ -1022,7 +1022,7 @@ where
visited.insert(call_symbol);
for closed_over_local in references.lookups.iter() {
if !visited.contains(&closed_over_local) {
if !visited.contains(closed_over_local) {
let other_refs =
references_from_local(*closed_over_local, visited, refs_by_def, closures);
@ -1033,7 +1033,7 @@ where
}
for call in references.calls.iter() {
if !visited.contains(&call) {
if !visited.contains(call) {
let other_refs = references_from_call(*call, visited, refs_by_def, closures);
answer = answer.union(other_refs);

View File

@ -276,7 +276,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
})
}
When(loc_cond_expr, branches) => {
let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, &loc_cond_expr));
let loc_desugared_cond = &*arena.alloc(desugar_expr(arena, loc_cond_expr));
let mut desugared_branches = Vec::with_capacity_in(branches.len(), arena);
for branch in branches.iter() {
@ -346,7 +346,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
}
If(if_thens, final_else_branch) => {
// If does not get desugared into `when` so we can give more targeted error messages during type checking.
let desugared_final_else = &*arena.alloc(desugar_expr(arena, &final_else_branch));
let desugared_final_else = &*arena.alloc(desugar_expr(arena, final_else_branch));
let mut desugared_if_thens = Vec::with_capacity_in(if_thens.len(), arena);
@ -363,8 +363,8 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
})
}
Expect(condition, continuation) => {
let desugared_condition = &*arena.alloc(desugar_expr(arena, &condition));
let desugared_continuation = &*arena.alloc(desugar_expr(arena, &continuation));
let desugared_condition = &*arena.alloc(desugar_expr(arena, condition));
let desugared_continuation = &*arena.alloc(desugar_expr(arena, continuation));
arena.alloc(Located {
value: Expect(desugared_condition, desugared_continuation),
region: loc_expr.region,

View File

@ -185,7 +185,7 @@ pub fn canonicalize_pattern<'a>(
}
}
FloatLiteral(ref string) => match pattern_type {
FloatLiteral(string) => match pattern_type {
WhenBranch => match finish_parsing_float(string) {
Err(_error) => {
let problem = MalformedPatternProblem::MalformedFloat;

View File

@ -124,7 +124,7 @@ impl Scope {
// If this IdentId was already added previously
// when the value was exposed in the module header,
// use that existing IdentId. Otherwise, create a fresh one.
let ident_id = match exposed_ident_ids.get_id(&ident.as_inline_str()) {
let ident_id = match exposed_ident_ids.get_id(ident.as_inline_str()) {
Some(ident_id) => *ident_id,
None => all_ident_ids.add(ident.clone().into()),
};

View File

@ -34,7 +34,7 @@ pub struct CanExprOut {
#[allow(dead_code)]
pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut {
let loc_expr = roc_parse::test_helpers::parse_loc_with(&arena, expr_str).unwrap_or_else(|e| {
let loc_expr = roc_parse::test_helpers::parse_loc_with(arena, expr_str).unwrap_or_else(|e| {
panic!(
"can_expr_with() got a parse error when attempting to canonicalize:\n\n{:?} {:?}",
expr_str, e

View File

@ -145,7 +145,7 @@ mod test_can {
let region = Region::zero();
assert_can(
&string.clone(),
string.clone(),
RuntimeError(RuntimeError::InvalidFloat(
FloatErrorKind::Error,
region,
@ -658,7 +658,7 @@ mod test_can {
recursive: recursion,
..
}) => recursion.clone(),
Some(other @ _) => {
Some(other) => {
panic!("assignment at {} is not a closure, but a {:?}", i, other)
}
None => {
@ -680,7 +680,7 @@ mod test_can {
recursive: recursion,
..
} => recursion.clone(),
other @ _ => {
other => {
panic!("assignment at {} is not a closure, but a {:?}", i, other)
}
}

View File

@ -79,7 +79,7 @@ where
let mut buf = String::new_in(arena);
if let Some(first) = strings.next() {
buf.push_str(&first);
buf.push_str(first);
for string in strings {
buf.reserve(join_str.len() + string.len());
@ -133,7 +133,7 @@ where
let mut answer = MutMap::default();
for (key, right_value) in map2 {
match std::collections::HashMap::get(map1, &key) {
match std::collections::HashMap::get(map1, key) {
None => (),
Some(left_value) => {
answer.insert(key.clone(), (left_value.clone(), right_value.clone()));

View File

@ -1446,7 +1446,7 @@ fn instantiate_rigids(
let mut rigid_substitution: ImMap<Variable, Type> = ImMap::default();
for (name, var) in introduced_vars.var_by_name.iter() {
if let Some(existing_rigid) = ftv.get(&name) {
if let Some(existing_rigid) = ftv.get(name) {
rigid_substitution.insert(*var, Type::Variable(*existing_rigid));
} else {
// It's possible to use this rigid in nested defs

View File

@ -206,7 +206,7 @@ pub fn constrain_pattern(
let pat_type = Type::Variable(*var);
let expected = PExpected::NoExpectation(pat_type.clone());
if !state.headers.contains_key(&symbol) {
if !state.headers.contains_key(symbol) {
state
.headers
.insert(*symbol, Located::at(region, pat_type.clone()));

View File

@ -295,7 +295,7 @@ impl<'a> Formattable<'a> for Expr<'a> {
items,
final_comments,
} => {
fmt_list(buf, &items, final_comments, indent);
fmt_list(buf, items, final_comments, indent);
}
BinOps(lefts, right) => fmt_bin_ops(buf, lefts, right, false, parens, indent),
UnaryOp(sub_expr, unary_op) => {

View File

@ -74,7 +74,7 @@ where
/// build_proc creates a procedure and outputs it to the wrapped object writer.
fn build_proc(&mut self, proc: Proc<'a>) -> Result<(&'a [u8], &[Relocation]), String> {
self.reset();
self.load_args(&proc.args)?;
self.load_args(proc.args)?;
// let start = std::time::Instant::now();
self.scan_ast(&proc.body);
self.create_free_map();

View File

@ -31,7 +31,7 @@ mod dev_num {
assert_evals_to!("-0.0", 0.0, f64);
assert_evals_to!("1.0", 1.0, f64);
assert_evals_to!("-1.0", -1.0, f64);
assert_evals_to!("3.1415926535897932", 3.1415926535897932, f64);
assert_evals_to!("3.1415926535897932", 3.141_592_653_589_793, f64);
assert_evals_to!(&format!("{:0.1}", f64::MIN), f64::MIN, f64);
assert_evals_to!(&format!("{:0.1}", f64::MAX), f64::MAX, f64);
}

View File

@ -49,7 +49,7 @@ pub fn helper<'a>(
let loaded = roc_load::file::load_and_monomorphize_from_str(
arena,
filename,
&module_src,
module_src,
&stdlib,
src_dir,
exposed_types,

View File

@ -78,7 +78,7 @@ pub fn build_has_tag_id<'a, 'ctx, 'env>(
match env.module.get_function(fn_name) {
Some(function_value) => function_value,
None => build_has_tag_id_help(env, union_layout, &fn_name),
None => build_has_tag_id_help(env, union_layout, fn_name),
}
}
@ -97,9 +97,9 @@ fn build_has_tag_id_help<'a, 'ctx, 'env>(
let function_value = crate::llvm::refcounting::build_header_help(
env,
&fn_name,
fn_name,
output_type.into(),
&argument_types,
argument_types,
);
// called from zig, must use C calling convention
@ -204,7 +204,7 @@ pub fn build_transform_caller<'a, 'ctx, 'env>(
function,
closure_data_layout,
argument_layouts,
&fn_name,
fn_name,
),
}
}
@ -225,7 +225,7 @@ fn build_transform_caller_help<'a, 'ctx, 'env>(
let function_value = crate::llvm::refcounting::build_header_help(
env,
&fn_name,
fn_name,
env.context.void_type().into(),
&(bumpalo::vec![ in env.arena; BasicTypeEnum::PointerType(arg_type); argument_layouts.len() + 2 ]),
);
@ -394,7 +394,7 @@ fn build_rc_wrapper<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_RC_REF;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let fn_name = match rc_operation {
@ -489,7 +489,7 @@ pub fn build_eq_wrapper<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_EQ_REF;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function_value = match env.module.get_function(fn_name.as_str()) {
@ -576,7 +576,7 @@ pub fn build_compare_wrapper<'a, 'ctx, 'env>(
let function_value = crate::llvm::refcounting::build_header_help(
env,
&fn_name,
fn_name,
env.context.i8_type().into(),
&[arg_type.into(), arg_type.into(), arg_type.into()],
);

View File

@ -347,7 +347,7 @@ pub fn module_from_builtins<'ctx>(ctx: &'ctx Context, module_name: &str) -> Modu
// we compile the builtins into LLVM bitcode
let bitcode_bytes: &[u8] = include_bytes!("../../../builtins/bitcode/builtins.bc");
let memory_buffer = MemoryBuffer::create_from_memory_range(&bitcode_bytes, module_name);
let memory_buffer = MemoryBuffer::create_from_memory_range(bitcode_bytes, module_name);
let module = Module::parse_bitcode_from_buffer(&memory_buffer, ctx)
.unwrap_or_else(|err| panic!("Unable to import builtins bitcode. LLVM error: {:?}", err));
@ -632,7 +632,7 @@ pub fn float_with_precision<'a, 'ctx, 'env>(
Builtin::Decimal => call_bitcode_fn(
env,
&[env.context.f64_type().const_float(value).into()],
&bitcode::DEC_FROM_F64,
bitcode::DEC_FROM_F64,
),
Builtin::Float64 => env.context.f64_type().const_float(value).into(),
Builtin::Float32 => env.context.f32_type().const_float(value).into(),
@ -976,7 +976,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
// The layout of the struct expects them to be dropped!
let (field_expr, field_layout) = load_symbol_and_layout(scope, symbol);
if !field_layout.is_dropped_because_empty() {
field_types.push(basic_type_from_layout(env, &field_layout));
field_types.push(basic_type_from_layout(env, field_layout));
field_vals.push(field_expr);
}
@ -1187,7 +1187,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
)
}
UnionLayout::NonNullableUnwrapped(field_layouts) => {
let struct_layout = Layout::Struct(&field_layouts);
let struct_layout = Layout::Struct(field_layouts);
let struct_type = basic_type_from_layout(env, &struct_layout);
@ -1260,7 +1260,7 @@ pub fn build_exp_expr<'a, 'ctx, 'env>(
// cast the argument bytes into the desired shape for this tag
let (argument, _structure_layout) = load_symbol_and_layout(scope, structure);
get_tag_id(env, parent, &union_layout, argument).into()
get_tag_id(env, parent, union_layout, argument).into()
}
}
}
@ -1459,7 +1459,7 @@ pub fn build_tag<'a, 'ctx, 'env>(
union_layout,
tag_id,
arguments,
&tag_field_layouts,
tag_field_layouts,
tags,
reuse_allocation,
parent,
@ -1491,7 +1491,7 @@ pub fn build_tag<'a, 'ctx, 'env>(
union_layout,
tag_id,
arguments,
&tag_field_layouts,
tag_field_layouts,
tags,
reuse_allocation,
parent,
@ -2269,7 +2269,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
scope,
parent,
layout,
&expr,
expr,
);
// Make a new scope which includes the binding we just encountered.
@ -2399,7 +2399,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
cond_layout,
cond_symbol,
} => {
let ret_type = basic_type_from_layout(env, &ret_layout);
let ret_type = basic_type_from_layout(env, ret_layout);
let switch_args = SwitchArgsIr {
cond_layout: *cond_layout,
@ -2477,7 +2477,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
);
// remove this join point again
scope.join_points.remove(&id);
scope.join_points.remove(id);
cont_block.move_after(phi_block).unwrap();
@ -3121,7 +3121,7 @@ where
let call_result = {
let call = builder.build_invoke(
function,
&arguments,
arguments,
then_block,
catch_block,
"call_roc_function",
@ -3291,7 +3291,7 @@ fn make_exception_catching_wrapper<'a, 'ctx, 'env>(
// Add main to the module.
let wrapper_function = add_func(
env.module,
&wrapper_function_name,
wrapper_function_name,
wrapper_function_type,
Linkage::External,
C_CALL_CONV,
@ -3414,7 +3414,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
// Add all the Proc headers to the module.
// We have to do this in a separate pass first,
// because their bodies may reference each other.
let headers = build_proc_headers(env, &mod_solutions, procedures, &mut scope);
let headers = build_proc_headers(env, mod_solutions, procedures, &mut scope);
let (_, function_pass) = construct_optimization_passes(env.module, opt_level);
@ -3428,7 +3428,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
current_scope.retain_top_level_thunks_for_module(home);
build_proc(
&env,
env,
mod_solutions,
&mut layout_ids,
func_spec_solutions,
@ -3441,7 +3441,7 @@ fn build_procedures_help<'a, 'ctx, 'env>(
env.dibuilder.finalize();
if fn_val.verify(true) {
function_pass.run_on(&fn_val);
function_pass.run_on(fn_val);
} else {
let mode = "NON-OPTIMIZED";
@ -3511,7 +3511,7 @@ fn build_proc_header<'a, 'ctx, 'env>(
let mut arg_basic_types = Vec::with_capacity_in(args.len(), arena);
for (layout, _) in args.iter() {
let arg_type = basic_type_from_layout(env, &layout);
let arg_type = basic_type_from_layout(env, layout);
arg_basic_types.push(arg_type);
}
@ -5426,7 +5426,7 @@ fn build_int_binop<'a, 'ctx, 'env>(
}
}
NumDivUnchecked => bd.build_int_signed_div(lhs, rhs, "div_int").into(),
NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], &bitcode::NUM_POW_INT),
NumPowInt => call_bitcode_fn(env, &[lhs.into(), rhs.into()], bitcode::NUM_POW_INT),
NumBitwiseAnd => bd.build_and(lhs, rhs, "int_bitwise_and").into(),
NumBitwiseXor => bd.build_xor(lhs, rhs, "int_bitwise_xor").into(),
NumBitwiseOr => bd.build_or(lhs, rhs, "int_bitwise_or").into(),
@ -5523,7 +5523,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_add(lhs, rhs, "add_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let then_block = context.append_basic_block(parent, "then_block");
let throw_block = context.append_basic_block(parent, "throw_block");
@ -5544,7 +5544,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_add(lhs, rhs, "add_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let is_infinite = bd.build_not(is_finite, "negate");
let struct_type = context.struct_type(
@ -5572,7 +5572,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_sub(lhs, rhs, "sub_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let then_block = context.append_basic_block(parent, "then_block");
let throw_block = context.append_basic_block(parent, "throw_block");
@ -5593,7 +5593,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_sub(lhs, rhs, "sub_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let is_infinite = bd.build_not(is_finite, "negate");
let struct_type = context.struct_type(
@ -5621,7 +5621,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_mul(lhs, rhs, "mul_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let then_block = context.append_basic_block(parent, "then_block");
let throw_block = context.append_basic_block(parent, "throw_block");
@ -5642,7 +5642,7 @@ fn build_float_binop<'a, 'ctx, 'env>(
let result = bd.build_float_mul(lhs, rhs, "mul_float");
let is_finite =
call_bitcode_fn(env, &[result.into()], &bitcode::NUM_IS_FINITE).into_int_value();
call_bitcode_fn(env, &[result.into()], bitcode::NUM_IS_FINITE).into_int_value();
let is_infinite = bd.build_not(is_finite, "negate");
let struct_type = context.struct_type(
@ -5688,9 +5688,9 @@ fn build_dec_binop<'a, 'ctx, 'env>(
use roc_module::low_level::LowLevel::*;
match op {
NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_ADD_WITH_OVERFLOW),
NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_SUB_WITH_OVERFLOW),
NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_MUL_WITH_OVERFLOW),
NumAddChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_ADD_WITH_OVERFLOW),
NumSubChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_SUB_WITH_OVERFLOW),
NumMulChecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_MUL_WITH_OVERFLOW),
NumAdd => build_dec_binop_throw_on_overflow(
env,
parent,
@ -5715,7 +5715,7 @@ fn build_dec_binop<'a, 'ctx, 'env>(
rhs,
"decimal multiplication overflowed",
),
NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], &bitcode::DEC_DIV),
NumDivUnchecked => call_bitcode_fn(env, &[lhs, rhs], bitcode::DEC_DIV),
_ => {
unreachable!("Unrecognized int binary operation: {:?}", op);
}
@ -5938,10 +5938,10 @@ fn build_float_unary_op<'a, 'ctx, 'env>(
env.context.i64_type(),
"num_floor",
),
NumIsFinite => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_IS_FINITE),
NumAtan => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ATAN),
NumAcos => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ACOS),
NumAsin => call_bitcode_fn(env, &[arg.into()], &bitcode::NUM_ASIN),
NumIsFinite => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_IS_FINITE),
NumAtan => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ATAN),
NumAcos => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ACOS),
NumAsin => call_bitcode_fn(env, &[arg.into()], bitcode::NUM_ASIN),
_ => {
unreachable!("Unrecognized int unary operation: {:?}", op);
}
@ -6107,7 +6107,7 @@ fn cxa_allocate_exception<'a, 'ctx, 'env>(
let context = env.context;
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
// void *__cxa_allocate_exception(size_t thrown_size);
@ -6141,7 +6141,7 @@ fn cxa_throw_exception<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>, info: BasicVal
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(value) => value,
None => {
// void __cxa_throw (void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) );
@ -6207,7 +6207,7 @@ fn get_gxx_personality_v0<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> Function
let module = env.module;
let context = env.context;
match module.get_function(&name) {
match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
let personality_func = add_func(
@ -6229,7 +6229,7 @@ fn cxa_end_catch(env: &Env<'_, '_, '_>) {
let module = env.module;
let context = env.context;
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
let cxa_end_catch = add_func(
@ -6257,7 +6257,7 @@ fn cxa_begin_catch<'a, 'ctx, 'env>(
let module = env.module;
let context = env.context;
let function = match module.get_function(&name) {
let function = match module.get_function(name) {
Some(gvalue) => gvalue,
None => {
let u8_ptr = context.i8_type().ptr_type(AddressSpace::Generic);

View File

@ -64,7 +64,7 @@ pub fn dict_len<'a, 'ctx, 'env>(
.build_alloca(dict_as_zig_dict.get_type(), "dict_ptr");
env.builder.build_store(dict_ptr, dict_as_zig_dict);
call_bitcode_fn(env, &[dict_ptr.into()], &bitcode::DICT_LEN)
call_bitcode_fn(env, &[dict_ptr.into()], bitcode::DICT_LEN)
}
Layout::Builtin(Builtin::EmptyDict) => ctx.i64_type().const_zero().into(),
_ => unreachable!("Invalid layout given to Dict.len : {:?}", dict_layout),
@ -78,7 +78,7 @@ pub fn dict_empty<'a, 'ctx, 'env>(env: &Env<'a, 'ctx, 'env>) -> BasicValueEnum<'
// we must give a pointer for the bitcode function to write the result into
let result_alloc = env.builder.build_alloca(roc_dict_type, "dict_empty");
call_void_bitcode_fn(env, &[result_alloc.into()], &bitcode::DICT_EMPTY);
call_void_bitcode_fn(env, &[result_alloc.into()], bitcode::DICT_EMPTY);
env.builder.build_load(result_alloc, "load_result")
}
@ -140,7 +140,7 @@ pub fn dict_insert<'a, 'ctx, 'env>(
dec_value_fn.as_global_value().as_pointer_value().into(),
result_ptr.into(),
],
&bitcode::DICT_INSERT,
bitcode::DICT_INSERT,
);
env.builder.build_load(result_ptr, "load_result")
@ -199,7 +199,7 @@ pub fn dict_remove<'a, 'ctx, 'env>(
dec_value_fn.as_global_value().as_pointer_value().into(),
result_ptr.into(),
],
&bitcode::DICT_REMOVE,
bitcode::DICT_REMOVE,
);
env.builder.build_load(result_ptr, "load_result")
@ -250,7 +250,7 @@ pub fn dict_contains<'a, 'ctx, 'env>(
hash_fn.as_global_value().as_pointer_value().into(),
eq_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::DICT_CONTAINS,
bitcode::DICT_CONTAINS,
)
}
@ -303,7 +303,7 @@ pub fn dict_get<'a, 'ctx, 'env>(
eq_fn.as_global_value().as_pointer_value().into(),
inc_value_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::DICT_GET,
bitcode::DICT_GET,
)
.into_struct_value();
@ -415,7 +415,7 @@ pub fn dict_elements_rc<'a, 'ctx, 'env>(
key_fn.as_global_value().as_pointer_value().into(),
value_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::DICT_ELEMENTS_RC,
bitcode::DICT_ELEMENTS_RC,
);
}
@ -460,7 +460,7 @@ pub fn dict_keys<'a, 'ctx, 'env>(
inc_key_fn.as_global_value().as_pointer_value().into(),
list_ptr.into(),
],
&bitcode::DICT_KEYS,
bitcode::DICT_KEYS,
);
let list_ptr = env
@ -527,7 +527,7 @@ pub fn dict_union<'a, 'ctx, 'env>(
inc_value_fn.as_global_value().as_pointer_value().into(),
output_ptr.into(),
],
&bitcode::DICT_UNION,
bitcode::DICT_UNION,
);
env.builder.build_load(output_ptr, "load_output_ptr")
@ -549,7 +549,7 @@ pub fn dict_difference<'a, 'ctx, 'env>(
dict2,
key_layout,
value_layout,
&bitcode::DICT_DIFFERENCE,
bitcode::DICT_DIFFERENCE,
)
}
@ -569,7 +569,7 @@ pub fn dict_intersection<'a, 'ctx, 'env>(
dict2,
key_layout,
value_layout,
&bitcode::DICT_INTERSECTION,
bitcode::DICT_INTERSECTION,
)
}
@ -674,7 +674,7 @@ pub fn dict_walk<'a, 'ctx, 'env>(
layout_width(env, accum_layout),
env.builder.build_bitcast(output_ptr, u8_ptr, "to_opaque"),
],
&bitcode::DICT_WALK,
bitcode::DICT_WALK,
);
env.builder.build_load(output_ptr, "load_output_ptr")
@ -721,7 +721,7 @@ pub fn dict_values<'a, 'ctx, 'env>(
inc_value_fn.as_global_value().as_pointer_value().into(),
list_ptr.into(),
],
&bitcode::DICT_VALUES,
bitcode::DICT_VALUES,
);
let list_ptr = env
@ -784,7 +784,7 @@ pub fn set_from_list<'a, 'ctx, 'env>(
dec_key_fn.as_global_value().as_pointer_value().into(),
result_alloca.into(),
],
&bitcode::SET_FROM_LIST,
bitcode::SET_FROM_LIST,
);
env.builder.build_load(result_alloca, "load_result")
@ -800,7 +800,7 @@ fn build_hash_wrapper<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_HASH_REF;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function_value = match env.module.get_function(fn_name.as_str()) {
@ -867,7 +867,7 @@ fn dict_symbol_to_zig_dict<'a, 'ctx, 'env>(
let zig_dict_type = env.module.get_struct_type("dict.RocDict").unwrap();
complex_bitcast(&env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict")
complex_bitcast(env.builder, dict, zig_dict_type.into(), "dict_to_zig_dict")
.into_struct_value()
}

View File

@ -130,7 +130,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
| Builtin::Float16
| Builtin::Decimal
| Builtin::Usize => {
let hash_bytes = store_and_use_as_u8_ptr(env, val, &layout);
let hash_bytes = store_and_use_as_u8_ptr(env, val, layout);
hash_bitcode_fn(env, seed, hash_bytes, layout.stack_size(ptr_bytes))
}
Builtin::Str => {
@ -138,7 +138,7 @@ fn hash_builtin<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[seed.into(), build_str::str_to_i128(env, val).into()],
&bitcode::DICT_HASH_STR,
bitcode::DICT_HASH_STR,
)
.into_int_value()
}
@ -327,7 +327,7 @@ fn build_hash_tag<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_HASH;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function = match env.module.get_function(fn_name.as_str()) {
@ -335,7 +335,7 @@ fn build_hash_tag<'a, 'ctx, 'env>(
None => {
let seed_type = env.context.i64_type();
let arg_type = basic_type_from_layout(env, &layout);
let arg_type = basic_type_from_layout(env, layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -659,7 +659,7 @@ fn build_hash_list<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_HASH;
let fn_name = layout_ids
.get(symbol, &layout)
.get(symbol, layout)
.to_symbol_string(symbol, &env.interns);
let function = match env.module.get_function(fn_name.as_str()) {
@ -667,7 +667,7 @@ fn build_hash_list<'a, 'ctx, 'env>(
None => {
let seed_type = env.context.i64_type();
let arg_type = basic_type_from_layout(env, &layout);
let arg_type = basic_type_from_layout(env, layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -870,7 +870,7 @@ fn store_and_use_as_u8_ptr<'a, 'ctx, 'env>(
value: BasicValueEnum<'ctx>,
layout: &Layout<'a>,
) -> PointerValue<'ctx> {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let alloc = env.builder.build_alloca(basic_type, "store");
env.builder.build_store(alloc, value);
@ -895,7 +895,7 @@ fn hash_bitcode_fn<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[seed.into(), buffer.into(), num_bytes.into()],
&bitcode::DICT_HASH,
bitcode::DICT_HASH,
)
.into_int_value()
}

View File

@ -94,7 +94,7 @@ pub fn list_single<'a, 'ctx, 'env>(
pass_element_as_opaque(env, element),
layout_width(env, element_layout),
],
&bitcode::LIST_SINGLE,
bitcode::LIST_SINGLE,
)
}
@ -206,7 +206,7 @@ pub fn list_join<'a, 'ctx, 'env>(
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
],
&bitcode::LIST_JOIN,
bitcode::LIST_JOIN,
)
}
_ => {
@ -239,7 +239,7 @@ pub fn list_reverse<'a, 'ctx, 'env>(
env.alignment_intvalue(&element_layout),
layout_width(env, &element_layout),
],
&bitcode::LIST_REVERSE,
bitcode::LIST_REVERSE,
)
}
@ -291,11 +291,11 @@ pub fn list_append<'a, 'ctx, 'env>(
env,
&[
pass_list_as_i128(env, original_wrapper.into()),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
pass_element_as_opaque(env, element),
layout_width(env, element_layout),
],
&bitcode::LIST_APPEND,
bitcode::LIST_APPEND,
)
}
@ -311,12 +311,12 @@ pub fn list_swap<'a, 'ctx, 'env>(
env,
&[
pass_list_as_i128(env, original_wrapper.into()),
env.alignment_intvalue(&element_layout),
layout_width(env, &element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
index_1.into(),
index_2.into(),
],
&bitcode::LIST_SWAP,
bitcode::LIST_SWAP,
)
}
@ -328,17 +328,17 @@ pub fn list_drop<'a, 'ctx, 'env>(
count: IntValue<'ctx>,
element_layout: &Layout<'a>,
) -> BasicValueEnum<'ctx> {
let dec_element_fn = build_dec_wrapper(env, layout_ids, &element_layout);
let dec_element_fn = build_dec_wrapper(env, layout_ids, element_layout);
call_bitcode_fn_returns_list(
env,
&[
pass_list_as_i128(env, original_wrapper.into()),
env.alignment_intvalue(&element_layout),
layout_width(env, &element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
count.into(),
dec_element_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::LIST_DROP,
bitcode::LIST_DROP,
)
}
@ -377,7 +377,7 @@ pub fn list_set<'a, 'ctx, 'env>(
&[
bytes.into(),
length.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
index.into(),
pass_element_as_opaque(env, element),
layout_width(env, element_layout),
@ -456,7 +456,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>(
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
pass_as_opaque(env, default_ptr),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, default_layout),
pass_as_opaque(env, result_ptr),
@ -487,7 +487,7 @@ pub fn list_walk_generic<'a, 'ctx, 'env>(
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
pass_as_opaque(env, default_ptr),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, function_call_return_layout),
layout_width(env, default_layout),
@ -563,7 +563,7 @@ pub fn list_range<'a, 'ctx, 'env>(
pass_as_opaque(env, low_ptr),
pass_as_opaque(env, high_ptr),
],
&bitcode::LIST_RANGE,
bitcode::LIST_RANGE,
)
}
@ -611,12 +611,12 @@ pub fn list_keep_if<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
inc_element_fn.as_global_value().as_pointer_value().into(),
dec_element_fn.as_global_value().as_pointer_value().into(),
],
&bitcode::LIST_KEEP_IF,
bitcode::LIST_KEEP_IF,
)
}
@ -653,7 +653,7 @@ pub fn list_keep_oks<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&before_layout),
env.alignment_intvalue(before_layout),
layout_width(env, before_layout),
layout_width(env, result_layout),
layout_width(env, after_layout),
@ -697,7 +697,7 @@ pub fn list_keep_errs<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&before_layout),
env.alignment_intvalue(before_layout),
layout_width(env, before_layout),
layout_width(env, result_layout),
layout_width(env, after_layout),
@ -724,7 +724,7 @@ pub fn list_sort_with<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
],
bitcode::LIST_SORT_WITH,
@ -747,7 +747,7 @@ pub fn list_map_with_index<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, return_layout),
],
@ -771,7 +771,7 @@ pub fn list_map<'a, 'ctx, 'env>(
pass_as_opaque(env, roc_function_call.data),
roc_function_call.inc_n_data.into(),
roc_function_call.data_is_owned.into(),
env.alignment_intvalue(&element_layout),
env.alignment_intvalue(element_layout),
layout_width(env, element_layout),
layout_width(env, return_layout),
],
@ -873,7 +873,7 @@ pub fn list_concat<'a, 'ctx, 'env>(
env.alignment_intvalue(elem_layout),
layout_width(env, elem_layout),
],
&bitcode::LIST_CONCAT,
bitcode::LIST_CONCAT,
),
_ => {
unreachable!("Invalid List layout for List.concat {:?}", list_layout);

View File

@ -27,7 +27,7 @@ pub fn str_split<'a, 'ctx, 'env>(
let segment_count = call_bitcode_fn(
env,
&[str_i128.into(), delim_i128.into()],
&bitcode::STR_COUNT_SEGMENTS,
bitcode::STR_COUNT_SEGMENTS,
)
.into_int_value();
@ -47,7 +47,7 @@ pub fn str_split<'a, 'ctx, 'env>(
call_void_bitcode_fn(
env,
&[ret_list_ptr_zig_rocstr, str_i128.into(), delim_i128.into()],
&bitcode::STR_STR_SPLIT_IN_PLACE,
bitcode::STR_STR_SPLIT_IN_PLACE,
);
store_list(env, ret_list_ptr, segment_count)
@ -62,7 +62,7 @@ fn str_symbol_to_i128<'a, 'ctx, 'env>(
let i128_type = env.context.i128_type().into();
complex_bitcast(&env.builder, string, i128_type, "str_to_i128").into_int_value()
complex_bitcast(env.builder, string, i128_type, "str_to_i128").into_int_value()
}
pub fn str_to_i128<'a, 'ctx, 'env>(
@ -119,7 +119,7 @@ pub fn str_concat<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str1_i128.into(), str2_i128.into()],
&bitcode::STR_CONCAT,
bitcode::STR_CONCAT,
)
}
@ -138,7 +138,7 @@ pub fn str_join_with<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[list_i128.into(), str_i128.into()],
&bitcode::STR_JOIN_WITH,
bitcode::STR_JOIN_WITH,
)
}
@ -151,7 +151,7 @@ pub fn str_number_of_bytes<'a, 'ctx, 'env>(
// the builtin will always return an u64
let length =
call_bitcode_fn(env, &[str_i128.into()], &bitcode::STR_NUMBER_OF_BYTES).into_int_value();
call_bitcode_fn(env, &[str_i128.into()], bitcode::STR_NUMBER_OF_BYTES).into_int_value();
// cast to the appropriate usize of the current build
env.builder
@ -171,7 +171,7 @@ pub fn str_starts_with<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into(), prefix_i128.into()],
&bitcode::STR_STARTS_WITH,
bitcode::STR_STARTS_WITH,
)
}
@ -188,7 +188,7 @@ pub fn str_starts_with_code_point<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into(), prefix],
&bitcode::STR_STARTS_WITH_CODE_POINT,
bitcode::STR_STARTS_WITH_CODE_POINT,
)
}
@ -205,7 +205,7 @@ pub fn str_ends_with<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into(), prefix_i128.into()],
&bitcode::STR_ENDS_WITH,
bitcode::STR_ENDS_WITH,
)
}
@ -220,7 +220,7 @@ pub fn str_count_graphemes<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str_i128.into()],
&bitcode::STR_COUNT_GRAPEHEME_CLUSTERS,
bitcode::STR_COUNT_GRAPEHEME_CLUSTERS,
)
}
@ -232,7 +232,7 @@ pub fn str_from_int<'a, 'ctx, 'env>(
) -> BasicValueEnum<'ctx> {
let int = load_symbol(scope, &int_symbol);
call_bitcode_fn(env, &[int], &bitcode::STR_FROM_INT)
call_bitcode_fn(env, &[int], bitcode::STR_FROM_INT)
}
/// Str.toBytes : Str -> List U8
@ -247,7 +247,7 @@ pub fn str_to_bytes<'a, 'ctx, 'env>(
"to_bytes",
);
call_bitcode_fn_returns_list(env, &[string], &bitcode::STR_TO_BYTES)
call_bitcode_fn_returns_list(env, &[string], bitcode::STR_TO_BYTES)
}
/// Str.fromUtf8 : List U8 -> { a : Bool, b : Str, c : Nat, d : I8 }
@ -273,7 +273,7 @@ pub fn str_from_utf8<'a, 'ctx, 'env>(
),
result_ptr.into(),
],
&bitcode::STR_FROM_UTF8,
bitcode::STR_FROM_UTF8,
);
let record_type = env.context.struct_type(
@ -306,7 +306,7 @@ pub fn str_from_float<'a, 'ctx, 'env>(
) -> BasicValueEnum<'ctx> {
let float = load_symbol(scope, &int_symbol);
call_bitcode_fn(env, &[float], &bitcode::STR_FROM_FLOAT)
call_bitcode_fn(env, &[float], bitcode::STR_FROM_FLOAT)
}
/// Str.equal : Str, Str -> Bool
@ -321,7 +321,7 @@ pub fn str_equal<'a, 'ctx, 'env>(
call_bitcode_fn(
env,
&[str1_i128.into(), str2_i128.into()],
&bitcode::STR_EQUAL,
bitcode::STR_EQUAL,
)
}

View File

@ -99,7 +99,7 @@ fn build_eq_builtin<'a, 'ctx, 'env>(
Builtin::Usize => int_cmp(IntPredicate::EQ, "eq_usize"),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_EQ),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_EQ),
Builtin::Float128 => float_cmp(FloatPredicate::OEQ, "eq_f128"),
Builtin::Float64 => float_cmp(FloatPredicate::OEQ, "eq_f64"),
Builtin::Float32 => float_cmp(FloatPredicate::OEQ, "eq_f32"),
@ -245,7 +245,7 @@ fn build_neq_builtin<'a, 'ctx, 'env>(
Builtin::Usize => int_cmp(IntPredicate::NE, "neq_usize"),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], &bitcode::DEC_NEQ),
Builtin::Decimal => call_bitcode_fn(env, &[lhs_val, rhs_val], bitcode::DEC_NEQ),
Builtin::Float128 => float_cmp(FloatPredicate::ONE, "neq_f128"),
Builtin::Float64 => float_cmp(FloatPredicate::ONE, "neq_f64"),
Builtin::Float32 => float_cmp(FloatPredicate::ONE, "neq_f32"),
@ -361,13 +361,13 @@ fn build_list_eq<'a, 'ctx, 'env>(
let symbol = Symbol::LIST_EQ;
let fn_name = layout_ids
.get(symbol, &element_layout)
.get(symbol, element_layout)
.to_symbol_string(symbol, &env.interns);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let arg_type = basic_type_from_layout(env, &list_layout);
let arg_type = basic_type_from_layout(env, list_layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -428,7 +428,7 @@ fn build_list_eq_help<'a, 'ctx, 'env>(
/* current_scope */ lexical_block.as_debug_info_scope(),
/* inlined_at */ None,
);
builder.set_current_debug_location(&ctx, loc);
builder.set_current_debug_location(ctx, loc);
}
// Add args to scope
@ -636,7 +636,7 @@ fn build_struct_eq_help<'a, 'ctx, 'env>(
/* current_scope */ lexical_block.as_debug_info_scope(),
/* inlined_at */ None,
);
builder.set_current_debug_location(&ctx, loc);
builder.set_current_debug_location(ctx, loc);
}
// Add args to scope
@ -752,13 +752,13 @@ fn build_tag_eq<'a, 'ctx, 'env>(
let symbol = Symbol::GENERIC_EQ;
let fn_name = layout_ids
.get(symbol, &tag_layout)
.get(symbol, tag_layout)
.to_symbol_string(symbol, &env.interns);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let arg_type = basic_type_from_layout(env, &tag_layout);
let arg_type = basic_type_from_layout(env, tag_layout);
let function_value = crate::llvm::refcounting::build_header_help(
env,
@ -817,7 +817,7 @@ fn build_tag_eq_help<'a, 'ctx, 'env>(
/* current_scope */ lexical_block.as_debug_info_scope(),
/* inlined_at */ None,
);
builder.set_current_debug_location(&ctx, loc);
builder.set_current_debug_location(ctx, loc);
}
// Add args to scope

View File

@ -59,7 +59,7 @@ pub fn basic_type_from_layout<'a, 'ctx, 'env>(
}
NullableUnwrapped { other_fields, .. } => {
let block =
block_of_memory_slices(env.context, &[&other_fields], env.ptr_bytes);
block_of_memory_slices(env.context, &[other_fields], env.ptr_bytes);
block.ptr_type(AddressSpace::Generic).into()
}
NonNullableUnwrapped(fields) => {

View File

@ -720,14 +720,14 @@ fn modify_refcount_list<'a, 'ctx, 'env>(
&env.interns,
"increment_list",
"decrement_list",
&layout,
layout,
mode,
);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let function_value = build_header(env, basic_type, mode, &fn_name);
modify_refcount_list_help(
@ -857,14 +857,14 @@ fn modify_refcount_str<'a, 'ctx, 'env>(
&env.interns,
"increment_str",
"decrement_str",
&layout,
layout,
mode,
);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let function_value = build_header(env, basic_type, mode, &fn_name);
modify_refcount_str_help(env, mode, layout, function_value);
@ -956,14 +956,14 @@ fn modify_refcount_dict<'a, 'ctx, 'env>(
&env.interns,
"increment_dict",
"decrement_dict",
&layout,
layout,
mode,
);
let function = match env.module.get_function(fn_name.as_str()) {
Some(function_value) => function_value,
None => {
let basic_type = basic_type_from_layout(env, &layout);
let basic_type = basic_type_from_layout(env, layout);
let function_value = build_header(env, basic_type, mode, &fn_name);
modify_refcount_dict_help(
@ -1118,7 +1118,7 @@ pub fn build_header_help<'a, 'ctx, 'env>(
FAST_CALL_CONV, // Because it's an internal-only function, it should use the fast calling convention.
);
let subprogram = env.new_subprogram(&fn_name);
let subprogram = env.new_subprogram(fn_name);
fn_val.set_subprogram(subprogram);
env.dibuilder.finalize();

View File

@ -225,7 +225,7 @@ impl<'a> Dependencies<'a> {
if let Some(to_notify) = self.notifies.get(&key) {
for notify_key in to_notify {
let mut is_empty = false;
if let Some(waiting_for_pairs) = self.waiting_for.get_mut(&notify_key) {
if let Some(waiting_for_pairs) = self.waiting_for.get_mut(notify_key) {
waiting_for_pairs.remove(&key);
is_empty = waiting_for_pairs.is_empty();
}
@ -469,7 +469,7 @@ fn start_phase<'a>(
for dep_id in deps_by_name.values() {
// We already verified that these are all present,
// so unwrapping should always succeed here.
let idents = ident_ids_by_module.get(&dep_id).unwrap();
let idents = ident_ids_by_module.get(dep_id).unwrap();
dep_idents.insert(*dep_id, idents.clone());
}
@ -535,7 +535,7 @@ fn start_phase<'a>(
var_store,
imported_modules,
&mut state.exposed_types,
&state.stdlib,
state.stdlib,
declarations,
)
}
@ -1635,7 +1635,7 @@ fn start_tasks<'a>(
) -> Result<(), LoadingProblem<'a>> {
for (module_id, phase) in work {
for task in start_phase(module_id, phase, arena, state) {
enqueue_task(&injector, worker_listeners, task)?
enqueue_task(injector, worker_listeners, task)?
}
}
@ -1759,11 +1759,11 @@ fn update<'a>(
state.module_cache.headers.insert(header.module_id, header);
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
let work = state.dependencies.notify(home, Phase::LoadHeader);
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
Ok(state)
}
@ -1796,7 +1796,7 @@ fn update<'a>(
let work = state.dependencies.notify(module_id, Phase::Parse);
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
Ok(state)
}
@ -1831,7 +1831,7 @@ fn update<'a>(
.dependencies
.notify(module_id, Phase::CanonicalizeAndConstrain);
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
Ok(state)
}
@ -1882,7 +1882,7 @@ fn update<'a>(
.notify(module_id, Phase::CanonicalizeAndConstrain),
);
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
Ok(state)
}
@ -1986,7 +1986,7 @@ fn update<'a>(
state.constrained_ident_ids.insert(module_id, ident_ids);
}
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
}
Ok(state)
@ -2041,7 +2041,7 @@ fn update<'a>(
.dependencies
.notify(module_id, Phase::FindSpecializations);
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
Ok(state)
}
@ -2143,7 +2143,7 @@ fn update<'a>(
existing.extend(requested);
}
start_tasks(arena, &mut state, work, &injector, worker_listeners)?;
start_tasks(arena, &mut state, work, injector, worker_listeners)?;
}
Ok(state)
@ -2348,7 +2348,7 @@ fn load_pkg_config<'a>(
let parse_start = SystemTime::now();
let bytes = arena.alloc(bytes_vec);
let parse_state = parser::State::new(bytes);
let parsed = roc_parse::module::parse_header(&arena, parse_state);
let parsed = roc_parse::module::parse_header(arena, parse_state);
let parse_header_duration = parse_start.elapsed().unwrap();
// Insert the first entries for this module's timings
@ -2518,7 +2518,7 @@ fn parse_header<'a>(
) -> Result<(ModuleId, Msg<'a>), LoadingProblem<'a>> {
let parse_start = SystemTime::now();
let parse_state = parser::State::new(src_bytes);
let parsed = roc_parse::module::parse_header(&arena, parse_state);
let parsed = roc_parse::module::parse_header(arena, parse_state);
let parse_header_duration = parse_start.elapsed().unwrap();
// Insert the first entries for this module's timings
@ -2667,7 +2667,7 @@ fn parse_header<'a>(
}
Ok((ast::Module::Platform { header }, _parse_state)) => Ok(fabricate_effects_module(
arena,
&"",
"",
module_ids,
ident_ids_by_module,
header,
@ -2825,7 +2825,7 @@ fn send_header<'a>(
let name = match opt_shorthand {
Some(shorthand) => {
PQModuleName::Qualified(&shorthand, declared_name.as_inline_str().clone())
PQModuleName::Qualified(shorthand, declared_name.as_inline_str().clone())
}
None => PQModuleName::Unqualified(declared_name.as_inline_str().clone()),
};
@ -2901,13 +2901,13 @@ fn send_header<'a>(
}
if cfg!(debug_assertions) {
home.register_debug_idents(&ident_ids);
home.register_debug_idents(ident_ids);
}
ident_ids.clone()
};
let mut parse_entries: Vec<_> = (&packages).iter().map(|x| &x.value).collect();
let mut parse_entries: Vec<_> = packages.iter().map(|x| &x.value).collect();
let mut package_entries = MutMap::default();
while let Some(parse_entry) = parse_entries.pop() {
@ -3053,7 +3053,7 @@ fn send_header_two<'a>(
let mut module_ids = (*module_ids).lock();
let mut ident_ids_by_module = (*ident_ids_by_module).lock();
let name = PQModuleName::Qualified(&shorthand, declared_name);
let name = PQModuleName::Qualified(shorthand, declared_name);
home = module_ids.get_or_insert(&name);
// Ensure this module has an entry in the exposed_ident_ids map.
@ -3138,13 +3138,13 @@ fn send_header_two<'a>(
}
if cfg!(debug_assertions) {
home.register_debug_idents(&ident_ids);
home.register_debug_idents(ident_ids);
}
ident_ids.clone()
};
let mut parse_entries: Vec<_> = (&packages).iter().map(|x| &x.value).collect();
let mut parse_entries: Vec<_> = packages.iter().map(|x| &x.value).collect();
let mut package_entries = MutMap::default();
while let Some(parse_entry) = parse_entries.pop() {
@ -3390,7 +3390,7 @@ fn fabricate_effects_module<'a>(
let module_id: ModuleId;
let effect_entries = unpack_exposes_entries(arena, &effects.entries);
let effect_entries = unpack_exposes_entries(arena, effects.entries);
let name = effects.effect_type_name;
let declared_name: ModuleName = name.into();
@ -3464,7 +3464,7 @@ fn fabricate_effects_module<'a>(
}
if cfg!(debug_assertions) {
module_id.register_debug_idents(&ident_ids);
module_id.register_debug_idents(ident_ids);
}
ident_ids.clone()
@ -3685,7 +3685,7 @@ where
let mut var_store = VarStore::default();
let canonicalized = canonicalize_module_defs(
&arena,
arena,
parsed_defs,
module_id,
module_ids,
@ -3712,7 +3712,7 @@ where
module_output.scope,
name.as_str().into(),
&module_output.ident_ids,
&parsed_defs,
parsed_defs,
)),
};
@ -3761,7 +3761,7 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result<Msg<'a>, Loadi
let parse_start = SystemTime::now();
let source = header.parse_state.bytes;
let parse_state = header.parse_state;
let parsed_defs = match module_defs().parse(&arena, parse_state) {
let parsed_defs = match module_defs().parse(arena, parse_state) {
Ok((_, success, _state)) => success,
Err((_, fail, _)) => {
return Err(LoadingProblem::ParsingFailed(fail.into_parse_problem(

View File

@ -188,8 +188,8 @@ mod test_load {
name_all_type_vars(*expr_var, subs);
let actual_str = content_to_string(content, subs, home, &interns);
let fully_qualified = symbol.fully_qualified(&interns, home).to_string();
let actual_str = content_to_string(content, subs, home, interns);
let fully_qualified = symbol.fully_qualified(interns, home).to_string();
let expected_type = expected_types
.remove(fully_qualified.as_str())
.unwrap_or_else(|| {

View File

@ -368,7 +368,7 @@ impl<'a> PackageModuleIds<'a> {
self.by_name.insert(module_name.clone(), module_id);
if cfg!(debug_assertions) {
Self::insert_debug_name(module_id, &module_name);
Self::insert_debug_name(module_id, module_name);
}
module_id
@ -449,7 +449,7 @@ impl ModuleIds {
self.by_name.insert(module_name.clone(), module_id);
if cfg!(debug_assertions) {
Self::insert_debug_name(module_id, &module_name);
Self::insert_debug_name(module_id, module_name);
}
module_id

View File

@ -1108,7 +1108,7 @@ fn expr_spec<'a>(
let index = (*index) as u32;
let tag_value_id = env.symbols[structure];
let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes();
let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes();
let type_name = TypeName(&type_name_bytes);
let union_id = builder.add_unwrap_named(block, MOD_APP, type_name, tag_value_id)?;
@ -1128,7 +1128,7 @@ fn expr_spec<'a>(
let tag_value_id = env.symbols[structure];
let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes();
let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes();
let type_name = TypeName(&type_name_bytes);
let variant_id =
@ -1234,7 +1234,7 @@ fn layout_spec_help(
| UnionLayout::NullableUnwrapped { .. }
| UnionLayout::NullableWrapped { .. }
| UnionLayout::NonNullableUnwrapped(_) => {
let type_name_bytes = recursive_tag_union_name_bytes(&union_layout).as_bytes();
let type_name_bytes = recursive_tag_union_name_bytes(union_layout).as_bytes();
let type_name = TypeName(&type_name_bytes);
Ok(builder.add_named_type(MOD_APP, type_name))

View File

@ -924,7 +924,7 @@ fn pick_path<'a>(branches: &'a [Branch]) -> &'a Vec<PathInstruction> {
for (path, pattern) in &branch.patterns {
// NOTE we no longer check for the guard here
// if !branch.guard.is_none() || needs_tests(&pattern) {
if needs_tests(&pattern) {
if needs_tests(pattern) {
all_paths.push(path);
} else {
// do nothing
@ -996,7 +996,7 @@ where
let mut min_paths = vec![first_path];
for path in all_paths {
let weight = small_defaults(branches, &path);
let weight = small_defaults(branches, path);
use std::cmp::Ordering;
match weight.cmp(&min_weight) {
@ -1219,7 +1219,7 @@ fn test_to_equality<'a>(
test: Test<'a>,
) -> (StoresVec<'a>, Symbol, Symbol, Option<ConstructorKnown<'a>>) {
let (rhs_symbol, mut stores, test_layout) =
path_to_expr_help(env, cond_symbol, &path, *cond_layout);
path_to_expr_help(env, cond_symbol, path, *cond_layout);
match test {
Test::IsCtor { tag_id, union, .. } => {
@ -1328,7 +1328,7 @@ fn stores_and_condition<'a>(
tests.push(test_to_equality(
env,
cond_symbol,
&cond_layout,
cond_layout,
&path,
test,
))
@ -1540,7 +1540,7 @@ fn decide_to_branching<'a>(
match decider {
Leaf(Jump(label)) => {
let index = jumps
.binary_search_by_key(&label, |ref r| r.0)
.binary_search_by_key(&label, |r| r.0)
.expect("jump not in list of jumps");
Stmt::Jump(jumps[index].1, &[])

View File

@ -187,7 +187,7 @@ impl<'a, 'i> Env<'a, 'i> {
pub fn unique_symbol(&mut self) -> Symbol {
let ident_id = self.ident_ids.gen_unique();
self.home.register_debug_idents(&self.ident_ids);
self.home.register_debug_idents(self.ident_ids);
Symbol::new(self.home, ident_id)
}
@ -195,7 +195,7 @@ impl<'a, 'i> Env<'a, 'i> {
fn manual_unique_symbol(home: ModuleId, ident_ids: &mut IdentIds) -> Symbol {
let ident_id = ident_ids.gen_unique();
home.register_debug_idents(&ident_ids);
home.register_debug_idents(ident_ids);
Symbol::new(home, ident_id)
}

View File

@ -740,7 +740,7 @@ impl<'a> Context<'a> {
) -> (&'a Stmt<'a>, LiveVarSet) {
use Expr::*;
let mut live_vars = update_live_vars(&v, &b_live_vars);
let mut live_vars = update_live_vars(&v, b_live_vars);
live_vars.remove(&z);
let new_b = match v {
@ -750,7 +750,7 @@ impl<'a> Context<'a> {
| Array { elems: ys, .. } => self.add_inc_before_consume_all(
ys,
self.arena.alloc(Stmt::Let(z, v, l, b)),
&b_live_vars,
b_live_vars,
),
Call(crate::ir::Call {

View File

@ -809,7 +809,7 @@ impl<'a, 'i> Env<'a, 'i> {
pub fn unique_symbol(&mut self) -> Symbol {
let ident_id = self.ident_ids.gen_unique();
self.home.register_debug_idents(&self.ident_ids);
self.home.register_debug_idents(self.ident_ids);
Symbol::new(self.home, ident_id)
}
@ -2468,7 +2468,7 @@ fn specialize_solved_type<'a>(
// for debugging only
let attempted_layout = layout_cache
.from_var(&env.arena, fn_var, env.subs)
.from_var(env.arena, fn_var, env.subs)
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err));
let raw = match attempted_layout {
@ -2509,7 +2509,7 @@ fn specialize_solved_type<'a>(
debug_assert_eq!(
attempted_layout,
layout_cache
.from_var(&env.arena, fn_var, env.subs)
.from_var(env.arena, fn_var, env.subs)
.unwrap_or_else(|err| panic!("TODO handle invalid function {:?}", err))
);
@ -3855,7 +3855,7 @@ pub fn with_hole<'a>(
let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena);
for (_, arg_expr) in args.iter() {
arg_symbols.push(possible_reuse_symbol(env, procs, &arg_expr));
arg_symbols.push(possible_reuse_symbol(env, procs, arg_expr));
}
let arg_symbols = arg_symbols.into_bump_slice();
@ -3885,7 +3885,7 @@ pub fn with_hole<'a>(
let mut arg_symbols = Vec::with_capacity_in(args.len(), env.arena);
for (_, arg_expr) in args.iter() {
arg_symbols.push(possible_reuse_symbol(env, procs, &arg_expr));
arg_symbols.push(possible_reuse_symbol(env, procs, arg_expr));
}
let arg_symbols = arg_symbols.into_bump_slice();
@ -5540,7 +5540,7 @@ fn store_pattern_help<'a>(
layout_cache,
outer_symbol,
&layout,
&arguments,
arguments,
stmt,
);
}
@ -5557,7 +5557,7 @@ fn store_pattern_help<'a>(
layout_cache,
outer_symbol,
*layout,
&arguments,
arguments,
*tag_id,
stmt,
);
@ -6374,7 +6374,7 @@ fn call_by_name_help<'a>(
// the variables of the given arguments
let mut pattern_vars = Vec::with_capacity_in(loc_args.len(), arena);
for (var, _) in &loc_args {
match layout_cache.from_var(&env.arena, *var, &env.subs) {
match layout_cache.from_var(env.arena, *var, env.subs) {
Ok(_) => {
pattern_vars.push(*var);
}

View File

@ -1317,7 +1317,7 @@ fn layout_from_flat_type<'a>(
}
} else if tag_layouts.len() == 1 {
// drop the tag id
UnionLayout::NonNullableUnwrapped(&tag_layouts.pop().unwrap())
UnionLayout::NonNullableUnwrapped(tag_layouts.pop().unwrap())
} else {
UnionLayout::Recursive(tag_layouts.into_bump_slice())
};
@ -2114,7 +2114,7 @@ impl<'a> LayoutIds<'a> {
});
// Get the id associated with this layout, or default to next_id.
let answer = ids.by_id.get(&layout).copied().unwrap_or(ids.next_id);
let answer = ids.by_id.get(layout).copied().unwrap_or(ids.next_id);
// If we had to default to next_id, it must not have been found;
// store the ID we're going to return and increment next_id.
@ -2145,7 +2145,7 @@ impl<'a> LayoutIds<'a> {
// Get the id associated with this layout, or default to next_id.
let answer = ids
.toplevels_by_id
.get(&layout)
.get(layout)
.copied()
.unwrap_or(ids.next_id);

View File

@ -58,7 +58,7 @@ impl<'a, 'i> Env<'a, 'i> {
fn unique_symbol(&mut self) -> Symbol {
let ident_id = self.ident_ids.gen_unique();
self.home.register_debug_idents(&self.ident_ids);
self.home.register_debug_idents(self.ident_ids);
Symbol::new(self.home, ident_id)
}

View File

@ -252,7 +252,7 @@ fn underscore_expression<'a>() -> impl Parser<'a, Expr<'a>, EExpr<'a>> {
match output {
Some(name) => Ok((MadeProgress, Expr::Underscore(name), final_state)),
None => Ok((MadeProgress, Expr::Underscore(&""), final_state)),
None => Ok((MadeProgress, Expr::Underscore(""), final_state)),
}
}
}

View File

@ -15,7 +15,7 @@ pub fn positive_number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, Number>
move |_arena, state: State<'a>| {
match state.bytes.get(0) {
Some(first_byte) if (*first_byte as char).is_ascii_digit() => {
parse_number_base(false, &state.bytes, state)
parse_number_base(false, state.bytes, state)
}
_ => {
// this is not a number at all
@ -33,7 +33,7 @@ pub fn number_literal<'a>() -> impl Parser<'a, NumLiteral<'a>, Number> {
parse_number_base(true, &state.bytes[1..], state)
}
Some(first_byte) if (*first_byte as char).is_ascii_digit() => {
parse_number_base(false, &state.bytes, state)
parse_number_base(false, state.bytes, state)
}
_ => {
// this is not a number at all

View File

@ -259,7 +259,7 @@ fn loc_ident_pattern_help<'a>(
Located {
region: loc_ident.region,
value: Pattern::Malformed(
String::from_str_in(&malformed_str, &arena).into_bump_str(),
String::from_str_in(&malformed_str, arena).into_bump_str(),
),
},
state,
@ -299,7 +299,7 @@ fn underscore_pattern_help<'a>() -> impl Parser<'a, Pattern<'a>, EPattern<'a>> {
match output {
Some(name) => Ok((MadeProgress, Pattern::Underscore(name), final_state)),
None => Ok((MadeProgress, Pattern::Underscore(&""), final_state)),
None => Ok((MadeProgress, Pattern::Underscore(""), final_state)),
}
}
}

View File

@ -303,12 +303,12 @@ fn applied_type<'a>(min_indent: u16) -> impl Parser<'a, TypeAnnotation<'a>, Type
),
|(ctor, args): (TypeAnnotation<'a>, Vec<'a, Located<TypeAnnotation<'a>>>)| {
match &ctor {
TypeAnnotation::Apply(ref module_name, ref name, _) => {
TypeAnnotation::Apply(module_name, name, _) => {
if args.is_empty() {
// ctor is already an Apply with no args, so return it directly.
ctor
} else {
TypeAnnotation::Apply(*module_name, *name, args.into_bump_slice())
TypeAnnotation::Apply(module_name, name, args.into_bump_slice())
}
}
TypeAnnotation::Malformed(_) => ctor,
@ -371,7 +371,7 @@ fn expression<'a>(min_indent: u16) -> impl Parser<'a, Located<TypeAnnotation<'a>
.parse(arena, state)?;
// prepare arguments
let mut arguments = Vec::with_capacity_in(rest.len() + 1, &arena);
let mut arguments = Vec::with_capacity_in(rest.len() + 1, arena);
arguments.push(first);
arguments.extend(rest);
let output = arena.alloc(arguments);

View File

@ -1609,7 +1609,7 @@ mod test_parse {
#[test]
fn single_underscore_closure() {
let arena = Bump::new();
let pattern = Located::new(0, 0, 1, 2, Pattern::Underscore(&""));
let pattern = Located::new(0, 0, 1, 2, Pattern::Underscore(""));
let patterns = &[pattern];
let expected = Closure(patterns, arena.alloc(Located::new(0, 0, 6, 8, Num("42"))));
let actual = parse_expr_with(&arena, "\\_ -> 42");
@ -1629,7 +1629,7 @@ mod test_parse {
0,
1,
11,
Pattern::MalformedIdent(&"the_answer", roc_parse::ident::BadIdent::Underscore(0, 5)),
Pattern::MalformedIdent("the_answer", roc_parse::ident::BadIdent::Underscore(0, 5)),
);
let patterns = &[pattern];
let expr = Located::new(0, 0, 15, 17, Expr::Num("42"));
@ -1671,8 +1671,8 @@ mod test_parse {
#[test]
fn closure_with_underscores() {
let arena = Bump::new();
let underscore1 = Located::new(0, 0, 1, 2, Pattern::Underscore(&""));
let underscore2 = Located::new(0, 0, 4, 9, Pattern::Underscore(&"name"));
let underscore1 = Located::new(0, 0, 1, 2, Pattern::Underscore(""));
let underscore2 = Located::new(0, 0, 4, 9, Pattern::Underscore("name"));
let patterns = bumpalo::vec![in &arena; underscore1, underscore2];
let expected = Closure(
arena.alloc(patterns),
@ -1906,7 +1906,7 @@ mod test_parse {
fn underscore_backpassing() {
let arena = Bump::new();
let newlines = bumpalo::vec![in &arena; Newline, Newline];
let underscore = Located::new(1, 1, 0, 1, Pattern::Underscore(&""));
let underscore = Located::new(1, 1, 0, 1, Pattern::Underscore(""));
let identifier_y = Located::new(1, 1, 7, 8, Identifier("y"));
let num_4 = Num("4");
@ -3531,7 +3531,7 @@ mod test_parse {
match parsed {
Ok((_, _, _state)) => {
// dbg!(_state);
return;
}
Err((_, _fail, _state)) => {
// dbg!(_fail, _state);
@ -3707,7 +3707,7 @@ mod test_parse {
guard: None,
});
let newlines = &[Newline];
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore(&"")), newlines);
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore("")), newlines);
let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2);
let expr2 = Num("4");
let loc_expr2 = Located::new(2, 2, 9, 10, expr2);
@ -3752,7 +3752,7 @@ mod test_parse {
guard: None,
});
let newlines = &[Newline];
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore(&"")), newlines);
let pattern2 = Pattern::SpaceBefore(arena.alloc(Pattern::Underscore("")), newlines);
let loc_pattern2 = Located::new(2, 2, 4, 5, pattern2);
let expr2 = Num("4");
let loc_expr2 = Located::new(2, 2, 9, 10, expr2);

View File

@ -159,17 +159,17 @@ fn to_syntax_report<'a>(
title: "PARSE PROBLEM".to_string(),
}
}
Type(typ) => to_type_report(alloc, filename, &typ, 0, 0),
Pattern(pat) => to_pattern_report(alloc, filename, &pat, 0, 0),
Type(typ) => to_type_report(alloc, filename, typ, 0, 0),
Pattern(pat) => to_pattern_report(alloc, filename, pat, 0, 0),
Expr(expr) => to_expr_report(
alloc,
filename,
Context::InDef(start_row, start_col),
&expr,
expr,
0,
0,
),
Header(header) => to_header_report(alloc, filename, &header, 0, 0),
Header(header) => to_header_report(alloc, filename, header, 0, 0),
_ => todo!("unhandled parse error: {:?}", parse_problem),
}
}
@ -205,19 +205,19 @@ fn to_expr_report<'a>(
use roc_parse::parser::EExpr;
match parse_problem {
EExpr::If(if_, row, col) => to_if_report(alloc, filename, context, &if_, *row, *col),
EExpr::When(when, row, col) => to_when_report(alloc, filename, context, &when, *row, *col),
EExpr::If(if_, row, col) => to_if_report(alloc, filename, context, if_, *row, *col),
EExpr::When(when, row, col) => to_when_report(alloc, filename, context, when, *row, *col),
EExpr::Lambda(lambda, row, col) => {
to_lambda_report(alloc, filename, context, &lambda, *row, *col)
to_lambda_report(alloc, filename, context, lambda, *row, *col)
}
EExpr::List(list, row, col) => to_list_report(alloc, filename, context, &list, *row, *col),
EExpr::List(list, row, col) => to_list_report(alloc, filename, context, list, *row, *col),
EExpr::Str(string, row, col) => {
to_str_report(alloc, filename, context, &string, *row, *col)
to_str_report(alloc, filename, context, string, *row, *col)
}
EExpr::InParens(expr, row, col) => {
to_expr_in_parens_report(alloc, filename, context, &expr, *row, *col)
to_expr_in_parens_report(alloc, filename, context, expr, *row, *col)
}
EExpr::Type(tipe, row, col) => to_type_report(alloc, filename, &tipe, *row, *col),
EExpr::Type(tipe, row, col) => to_type_report(alloc, filename, tipe, *row, *col),
EExpr::ElmStyleFunction(region, row, col) => {
let surroundings = Region::from_rows_cols(start_row, start_col, *row, *col);
let region = *region;
@ -529,7 +529,7 @@ fn to_expr_report<'a>(
}
}
EExpr::Space(error, row, col) => to_space_report(alloc, filename, &error, *row, *col),
EExpr::Space(error, row, col) => to_space_report(alloc, filename, error, *row, *col),
_ => todo!("unhandled parse error: {:?}", parse_problem),
}
@ -1557,10 +1557,10 @@ fn to_pattern_report<'a>(
}
}
EPattern::Record(record, row, col) => {
to_precord_report(alloc, filename, &record, *row, *col)
to_precord_report(alloc, filename, record, *row, *col)
}
EPattern::PInParens(inparens, row, col) => {
to_pattern_in_parens_report(alloc, filename, &inparens, *row, *col)
to_pattern_in_parens_report(alloc, filename, inparens, *row, *col)
}
_ => todo!("unhandled parse error: {:?}", parse_problem),
}
@ -1958,14 +1958,14 @@ fn to_type_report<'a>(
use roc_parse::parser::Type;
match parse_problem {
Type::TRecord(record, row, col) => to_trecord_report(alloc, filename, &record, *row, *col),
Type::TRecord(record, row, col) => to_trecord_report(alloc, filename, record, *row, *col),
Type::TTagUnion(tag_union, row, col) => {
to_ttag_union_report(alloc, filename, &tag_union, *row, *col)
to_ttag_union_report(alloc, filename, tag_union, *row, *col)
}
Type::TInParens(tinparens, row, col) => {
to_tinparens_report(alloc, filename, &tinparens, *row, *col)
to_tinparens_report(alloc, filename, tinparens, *row, *col)
}
Type::TApply(tapply, row, col) => to_tapply_report(alloc, filename, &tapply, *row, *col),
Type::TApply(tapply, row, col) => to_tapply_report(alloc, filename, tapply, *row, *col),
Type::TFunctionArgument(row, col) => match what_is_next(alloc.src_lines, *row, *col) {
Next::Other(Some(',')) => {
@ -2856,27 +2856,27 @@ fn to_header_report<'a>(
match parse_problem {
EHeader::Provides(provides, row, col) => {
to_provides_report(alloc, filename, &provides, *row, *col)
to_provides_report(alloc, filename, provides, *row, *col)
}
EHeader::Exposes(exposes, row, col) => {
to_exposes_report(alloc, filename, &exposes, *row, *col)
to_exposes_report(alloc, filename, exposes, *row, *col)
}
EHeader::Imports(imports, row, col) => {
to_imports_report(alloc, filename, &imports, *row, *col)
to_imports_report(alloc, filename, imports, *row, *col)
}
EHeader::Requires(requires, row, col) => {
to_requires_report(alloc, filename, &requires, *row, *col)
to_requires_report(alloc, filename, requires, *row, *col)
}
EHeader::Packages(packages, row, col) => {
to_packages_report(alloc, filename, &packages, *row, *col)
to_packages_report(alloc, filename, packages, *row, *col)
}
EHeader::Effects(effects, row, col) => {
to_effects_report(alloc, filename, &effects, *row, *col)
to_effects_report(alloc, filename, effects, *row, *col)
}
EHeader::IndentStart(row, col) => {
@ -2988,7 +2988,7 @@ fn to_header_report<'a>(
}
}
EHeader::Space(error, row, col) => to_space_report(alloc, filename, &error, *row, *col),
EHeader::Space(error, row, col) => to_space_report(alloc, filename, error, *row, *col),
}
}

View File

@ -214,7 +214,7 @@ fn report_bad_type<'b>(
alloc,
found,
expected_type,
add_category(alloc, this_is, &category),
add_category(alloc, this_is, category),
further_details,
),
];
@ -1443,7 +1443,7 @@ pub fn to_doc<'b>(
Record(fields_map, ext) => {
let mut fields = fields_map.into_iter().collect::<Vec<_>>();
fields.sort_by(|(a, _), (b, _)| a.cmp(&b));
fields.sort_by(|(a, _), (b, _)| a.cmp(b));
report_text::record(
alloc,
@ -1482,7 +1482,7 @@ pub fn to_doc<'b>(
)
})
.collect::<Vec<_>>();
tags.sort_by(|(a, _), (b, _)| a.cmp(&b));
tags.sort_by(|(a, _), (b, _)| a.cmp(b));
report_text::tag_union(
alloc,
@ -1505,7 +1505,7 @@ pub fn to_doc<'b>(
)
})
.collect::<Vec<_>>();
tags.sort_by(|(a, _), (b, _)| a.cmp(&b));
tags.sort_by(|(a, _), (b, _)| a.cmp(b));
report_text::recursive_tag_union(
alloc,

View File

@ -70,7 +70,7 @@ impl<'b> Report<'b> {
pub fn render_ci(self, buf: &'b mut String, alloc: &'b RocDocAllocator<'b>) {
let err_msg = "<buffer is not a utf-8 encoded string>";
self.pretty(&alloc)
self.pretty(alloc)
.1
.render_raw(70, &mut CiWrite::new(buf))
.expect(err_msg);
@ -85,7 +85,7 @@ impl<'b> Report<'b> {
) {
let err_msg = "<buffer is not a utf-8 encoded string>";
self.pretty(&alloc)
self.pretty(alloc)
.1
.render_raw(70, &mut ColorWrite::new(palette, buf))
.expect(err_msg);

View File

@ -110,7 +110,7 @@ pub fn can_expr_with<'a>(
home: ModuleId,
expr_str: &'a str,
) -> Result<CanExprOut, ParseErrOut<'a>> {
let loc_expr = match roc_parse::test_helpers::parse_loc_with(&arena, expr_str) {
let loc_expr = match roc_parse::test_helpers::parse_loc_with(arena, expr_str) {
Ok(e) => e,
Err(fail) => {
let interns = Interns::default();

View File

@ -65,7 +65,7 @@ mod test_reporting {
problems: can_problems,
..
} = can_expr(arena, expr_src)?;
let mut subs = Subs::new(var_store.into());
let mut subs = Subs::new(var_store);
for (var, name) in output.introduced_variables.name_by_var {
subs.rigid_var(var, name);
@ -223,13 +223,11 @@ mod test_reporting {
list_reports(&arena, src, &mut buf, callback);
// convenient to copy-paste the generated message
if true {
if buf != expected_rendering {
for line in buf.split("\n") {
if true && buf != expected_rendering {
for line in buf.split('\n') {
println!(" {}", line);
}
}
}
assert_eq!(buf, expected_rendering);
}
@ -247,13 +245,11 @@ mod test_reporting {
list_header_reports(&arena, src, &mut buf, callback);
// convenient to copy-paste the generated message
if true {
if buf != expected_rendering {
for line in buf.split("\n") {
if true && buf != expected_rendering {
for line in buf.split('\n') {
println!(" {}", line);
}
}
}
assert_eq!(buf, expected_rendering);
}

View File

@ -56,17 +56,17 @@ pub fn make_solved_types(
for loc_named_var in alias.type_variables.iter() {
let (name, var) = &loc_named_var.value;
args.push((name.clone(), SolvedType::new(&solved_subs, *var)));
args.push((name.clone(), SolvedType::new(solved_subs, *var)));
}
let mut lambda_set_variables = Vec::with_capacity(alias.lambda_set_variables.len());
for set in alias.lambda_set_variables.iter() {
lambda_set_variables.push(roc_types::solved_types::SolvedLambdaSet(
SolvedType::from_type(&solved_subs, &set.0),
SolvedType::from_type(solved_subs, &set.0),
));
}
let solved_type = SolvedType::from_type(&solved_subs, &alias.typ);
let solved_type = SolvedType::from_type(solved_subs, &alias.typ);
let solved_alias =
SolvedType::Alias(*symbol, args, lambda_set_variables, Box::new(solved_type));
@ -79,7 +79,7 @@ pub fn make_solved_types(
// other modules will generate constraints for imported values
// within the context of their own Subs.
for (symbol, var) in exposed_vars_by_symbol.iter() {
let solved_type = SolvedType::new(&solved_subs, *var);
let solved_type = SolvedType::new(solved_subs, *var);
solved_types.insert(*symbol, solved_type);
}

View File

@ -257,7 +257,7 @@ fn solve(
}
}
Lookup(symbol, expectation, region) => {
match env.vars_by_symbol.get(&symbol) {
match env.vars_by_symbol.get(symbol) {
Some(var) => {
// Deep copy the vars associated with this symbol before unifying them.
// Otherwise, suppose we have this:
@ -390,7 +390,7 @@ fn solve(
// If the return expression is guaranteed to solve,
// solve the assignments themselves and move on.
solve(
&env,
env,
state,
rank,
pools,
@ -508,7 +508,7 @@ fn solve(
env: saved_env,
mark,
} = solve(
&env,
env,
state,
next_rank,
next_pools,
@ -577,7 +577,7 @@ fn solve(
let mut new_env = env.clone();
for (symbol, loc_var) in local_def_vars.iter() {
// when there are duplicates, keep the one from `env`
if !new_env.vars_by_symbol.contains_key(&symbol) {
if !new_env.vars_by_symbol.contains_key(symbol) {
new_env.vars_by_symbol.insert(*symbol, loc_var.value);
}
}
@ -599,7 +599,7 @@ fn solve(
problems,
cached_aliases,
subs,
&ret_con,
ret_con,
);
for (symbol, loc_var) in local_def_vars {
@ -1047,7 +1047,7 @@ fn adjust_rank(
unsafe { &*ptr }
};
let max_rank = adjust_rank_content(subs, young_mark, visit_mark, group_rank, &content);
let max_rank = adjust_rank_content(subs, young_mark, visit_mark, group_rank, content);
subs.set_rank_mark(var, max_rank, visit_mark);

View File

@ -118,7 +118,7 @@ mod solve_expr {
subs.get(variable).content
};
let actual_str = content_to_string(content, &subs, home, &interns);
let actual_str = content_to_string(content, subs, home, &interns);
// Disregard UnusedDef problems, because those are unavoidable when
// returning a function from the test expression.

View File

@ -339,7 +339,7 @@ mod gen_num {
x
"#
),
RocDec::from_str_to_i128_unsafe(&"2.1"),
RocDec::from_str_to_i128_unsafe("2.1"),
i128
);
}
@ -576,7 +576,7 @@ mod gen_num {
z
"#
),
RocDec::from_str_to_i128_unsafe(&"5.2"),
RocDec::from_str_to_i128_unsafe("5.2"),
i128
);
}
@ -639,7 +639,7 @@ mod gen_num {
Err _ -> -1
"#
),
RocDec::from_str_to_i128_unsafe(&"3.333333333333333333"),
RocDec::from_str_to_i128_unsafe("3.333333333333333333"),
i128
);
}
@ -755,7 +755,7 @@ mod gen_num {
(x - y) - z
"#
),
RocDec::from_str_to_i128_unsafe(&"-3.9"),
RocDec::from_str_to_i128_unsafe("-3.9"),
i128
);
}
@ -803,7 +803,7 @@ mod gen_num {
x * y * z
"#
),
RocDec::from_str_to_i128_unsafe(&"48.0"),
RocDec::from_str_to_i128_unsafe("48.0"),
i128
);
}

View File

@ -60,7 +60,7 @@ pub fn helper<'a>(
let loaded = roc_load::file::load_and_monomorphize_from_str(
arena,
filename,
&module_src,
module_src,
stdlib,
src_dir,
exposed_types,
@ -211,7 +211,7 @@ pub fn helper<'a>(
// Compile and add all the Procs before adding main
let env = roc_gen_llvm::llvm::build::Env {
arena: &arena,
arena,
builder: &builder,
dibuilder: &dibuilder,
compile_unit: &compile_unit,
@ -252,7 +252,7 @@ pub fn helper<'a>(
// Uncomment this to see the module's optimized LLVM instruction output:
// env.module.print_to_stderr();
let lib = module_to_dylib(&env.module, &target, opt_level)
let lib = module_to_dylib(env.module, &target, opt_level)
.expect("Error loading compiled dylib for test");
(main_fn_name, delayed_errors.join("\n"), lib)

View File

@ -3,7 +3,7 @@
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
#![allow(clippy::large_enum_variant)]
// we actually want to compare against the literal float bits
#![allow(clippy::clippy::float_cmp)]
#![allow(clippy::float_cmp)]
#[macro_use]
extern crate pretty_assertions;
@ -100,7 +100,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
let loaded = roc_load::file::load_and_monomorphize_from_str(
arena,
filename,
&module_src,
module_src,
&stdlib,
src_dir,
exposed_types,

View File

@ -452,7 +452,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
sorted_fields.sort_by(|(a, _), (b, _)| {
a.clone()
.as_string(interns, home)
.cmp(&b.as_string(&interns, home))
.cmp(&b.as_string(interns, home))
});
let mut any_written_yet = false;
@ -464,7 +464,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
any_written_yet = true;
}
buf.push_str(&label.as_string(&interns, home));
buf.push_str(&label.as_string(interns, home));
for var in vars {
buf.push(' ');
@ -496,7 +496,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
buf.push_str("[ ");
buf.push_str(&tag_name.as_string(&interns, home));
buf.push_str(&tag_name.as_string(interns, home));
buf.push_str(" ]");
@ -539,7 +539,7 @@ fn write_flat_type(env: &Env, flat_type: FlatType, subs: &Subs, buf: &mut String
} else {
any_written_yet = true;
}
buf.push_str(&label.as_string(&interns, home));
buf.push_str(&label.as_string(interns, home));
for var in vars {
buf.push(' ');
@ -757,7 +757,7 @@ fn write_symbol(env: &Env, symbol: Symbol, buf: &mut String) {
// Don't qualify the symbol if it's in our home module,
// or if it's a builtin (since all their types are always in scope)
if module_id != env.home && !module_id.is_builtin() {
buf.push_str(module_id.to_string(&interns));
buf.push_str(module_id.to_string(interns));
buf.push('.');
}

View File

@ -572,11 +572,11 @@ pub fn to_type(
let mut new_args = Vec::with_capacity(args.len());
for arg in args {
new_args.push(to_type(&arg, free_vars, var_store));
new_args.push(to_type(arg, free_vars, var_store));
}
let new_ret = to_type(&ret, free_vars, var_store);
let new_closure = to_type(&closure, free_vars, var_store);
let new_ret = to_type(ret, free_vars, var_store);
let new_closure = to_type(closure, free_vars, var_store);
Type::Function(new_args, Box::new(new_closure), Box::new(new_ret))
}
@ -584,13 +584,13 @@ pub fn to_type(
let mut new_args = Vec::with_capacity(args.len());
for arg in args {
new_args.push(to_type(&arg, free_vars, var_store));
new_args.push(to_type(arg, free_vars, var_store));
}
Type::Apply(*symbol, new_args)
}
Rigid(lowercase) => {
if let Some(var) = free_vars.named_vars.get(&lowercase) {
if let Some(var) = free_vars.named_vars.get(lowercase) {
Type::Variable(*var)
} else {
let var = var_store.fresh();
@ -611,9 +611,9 @@ pub fn to_type(
for (label, field) in fields {
let field_val = match field {
Required(typ) => Required(to_type(&typ, free_vars, var_store)),
Optional(typ) => Optional(to_type(&typ, free_vars, var_store)),
Demanded(typ) => Demanded(to_type(&typ, free_vars, var_store)),
Required(typ) => Required(to_type(typ, free_vars, var_store)),
Optional(typ) => Optional(to_type(typ, free_vars, var_store)),
Demanded(typ) => Demanded(to_type(typ, free_vars, var_store)),
};
new_fields.insert(label.clone(), field_val);

View File

@ -431,7 +431,7 @@ impl Type {
match self {
Variable(v) => {
if let Some(replacement) = substitutions.get(&v) {
if let Some(replacement) = substitutions.get(v) {
*self = replacement.clone();
}
}
@ -810,15 +810,15 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet<Symbol>) {
match tipe {
Function(args, closure, ret) => {
symbols_help(&ret, accum);
symbols_help(&closure, accum);
symbols_help(ret, accum);
symbols_help(closure, accum);
args.iter().for_each(|arg| symbols_help(arg, accum));
}
FunctionOrTagUnion(_, _, ext) => {
symbols_help(&ext, accum);
symbols_help(ext, accum);
}
RecursiveTagUnion(_, tags, ext) | TagUnion(tags, ext) => {
symbols_help(&ext, accum);
symbols_help(ext, accum);
tags.iter()
.map(|v| v.1.iter())
.flatten()
@ -826,7 +826,7 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet<Symbol>) {
}
Record(fields, ext) => {
symbols_help(&ext, accum);
symbols_help(ext, accum);
fields.values().for_each(|field| {
use RecordField::*;
@ -843,11 +843,11 @@ fn symbols_help(tipe: &Type, accum: &mut ImSet<Symbol>) {
..
} => {
accum.insert(*alias_symbol);
symbols_help(&actual_type, accum);
symbols_help(actual_type, accum);
}
HostExposedAlias { name, actual, .. } => {
accum.insert(*name);
symbols_help(&actual, accum);
symbols_help(actual, accum);
}
Apply(symbol, args) => {
accum.insert(*symbol);

View File

@ -188,7 +188,7 @@ fn unify_alias(
// Alias wins
merge(
subs,
&ctx,
ctx,
Alias(
symbol,
args.to_owned(),
@ -220,7 +220,7 @@ fn unify_alias(
}
if problems.is_empty() {
problems.extend(merge(subs, &ctx, other_content.clone()));
problems.extend(merge(subs, ctx, other_content.clone()));
}
if problems.is_empty() {

View File

@ -145,7 +145,7 @@ fn render_main_content(
}
}
type_annotation_to_html(0, &mut content, &type_ann);
type_annotation_to_html(0, &mut content, type_ann);
buf.push_str(
html_node(
@ -541,7 +541,7 @@ fn should_be_multiline(type_ann: &TypeAnnotation) -> bool {
if is_multiline {
break;
}
is_multiline = should_be_multiline(&value);
is_multiline = should_be_multiline(value);
}
}

View File

@ -66,7 +66,7 @@ impl Lines for CodeLines {
fn get_line(&self, line_nr: usize) -> UIResult<&str> {
let line_string = slice_get(line_nr, &self.lines)?;
Ok(&line_string)
Ok(line_string)
}
fn line_len(&self, line_nr: usize) -> UIResult<usize> {
@ -85,7 +85,7 @@ impl Lines for CodeLines {
let mut lines = BumpString::with_capacity_in(self.nr_of_chars(), arena);
for line in &self.lines {
lines.push_str(&line);
lines.push_str(line);
}
lines

View File

@ -194,7 +194,7 @@ fn color_backtrace(backtrace: &snafu::Backtrace) -> String {
for line in backtrace_split {
let new_line = if line.contains("src") {
if !contains_one_of(&line, &irrelevant_src) {
if !contains_one_of(line, &irrelevant_src) {
if let Some(prev_line) = prev_line_opt {
prev_line_opt = Some(format!("{}", prev_line.truecolor(255, 30, 30)));
}

View File

@ -129,7 +129,7 @@ impl MarkupNode {
}
}
let closest_ast_child = slice_get(best_index, &children_ids)?;
let closest_ast_child = slice_get(best_index, children_ids)?;
let closest_ast_child_index =
index_of(*closest_ast_child, &child_ids_with_ast)?;
@ -259,7 +259,7 @@ pub fn expr2_to_markup<'a, 'b>(
| Expr2::I128 { text, .. }
| Expr2::U128 { text, .. }
| Expr2::Float { text, .. } => {
let num_str = get_string(env, &text);
let num_str = get_string(env, text);
new_markup_node(
num_str,
@ -275,7 +275,7 @@ pub fn expr2_to_markup<'a, 'b>(
markup_node_pool,
),
Expr2::GlobalTag { name, .. } => new_markup_node(
get_string(env, &name),
get_string(env, name),
expr2_node_id,
HighlightStyle::Type,
markup_node_pool,

View File

@ -59,7 +59,7 @@ pub fn init_model<'a>(
interns: &'a Interns,
code_arena: &'a Bump,
) -> EdResult<EdModel<'a>> {
let mut module = EdModule::new(&code_str, env, code_arena)?;
let mut module = EdModule::new(code_str, env, code_arena)?;
let ast_root_id = module.ast_root_id;
let mut markup_node_pool = SlowPool::new();
@ -175,7 +175,7 @@ impl<'a> EdModule<'a> {
let region = Region::new(0, 0, 0, 0);
let expr2_result = str_to_expr2(&ast_arena, &code_str, &mut env, &mut scope, region);
let expr2_result = str_to_expr2(ast_arena, code_str, &mut env, &mut scope, region);
match expr2_result {
Ok((expr2, _output)) => {
@ -239,7 +239,7 @@ pub mod test_ed_model {
);
ed_model::init_model(
&code_str,
code_str,
file_path,
env,
&ed_model_refs.interns,

View File

@ -221,7 +221,7 @@ impl<'a> EdModel<'a> {
if self.grid_node_map.node_exists_at_pos(caret_pos) {
let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self
.grid_node_map
.get_expr_start_end_pos(self.get_caret(), &self)?;
.get_expr_start_end_pos(self.get_caret(), self)?;
self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?;
} else if self
@ -230,7 +230,7 @@ impl<'a> EdModel<'a> {
{
let (expr_start_pos, expr_end_pos, ast_node_id, mark_node_id) = self
.grid_node_map
.get_expr_start_end_pos(self.get_caret().decrement_col(), &self)?;
.get_expr_start_end_pos(self.get_caret().decrement_col(), self)?;
self.set_selected_expr(expr_start_pos, expr_end_pos, ast_node_id, mark_node_id)?;
}
@ -247,7 +247,7 @@ impl<'a> EdModel<'a> {
let constrained = constrain_expr(
&arena,
&mut self.module.env,
&expr,
expr,
Expected::NoExpectation(Type2::Variable(var)),
Region::zero(),
);
@ -275,7 +275,7 @@ impl<'a> EdModel<'a> {
let content = subs.get(var).content;
PoolStr::new(
&content_to_string(content, &subs, self.module.env.home, self.interns),
&content_to_string(content, subs, self.module.env.home, self.interns),
self.module.env.pool,
)
}
@ -605,7 +605,7 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
}
Expr2::SmallStr(old_arr_str) => {
update_small_string(
&ch, old_arr_str, ed_model
ch, old_arr_str, ed_model
)?
}
Expr2::Str(old_pool_str) => {
@ -2043,11 +2043,11 @@ pub mod test_ed_update {
expected_tooltip: &str,
new_char: char,
) -> Result<(), String> {
assert_type_tooltips_seq(pre_lines, &vec![expected_tooltip], &new_char.to_string())
assert_type_tooltips_seq(pre_lines, &[expected_tooltip], &new_char.to_string())
}
pub fn assert_type_tooltip_clean(lines: &[&str], expected_tooltip: &str) -> Result<(), String> {
assert_type_tooltips_seq(lines, &vec![expected_tooltip], "")
assert_type_tooltips_seq(lines, &[expected_tooltip], "")
}
// When doing ctrl+shift+up multiple times we select the surrounding expression every time,

View File

@ -22,7 +22,7 @@ pub fn start_new_int(ed_model: &mut EdModel, digit_char: &char) -> EdResult<Inpu
curr_mark_node,
parent_id_opt,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
let is_blank_node = curr_mark_node.is_blank();

View File

@ -21,7 +21,7 @@ pub fn start_new_list(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
curr_mark_node,
parent_id_opt,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
let is_blank_node = curr_mark_node.is_blank();
@ -101,7 +101,7 @@ pub fn add_blank_child(
curr_mark_node: _,
parent_id_opt,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
let trip_result: EdResult<(ExprId, ExprId, MarkNodeId)> = if let Some(parent_id) = parent_id_opt
{

View File

@ -24,7 +24,7 @@ pub fn start_new_record(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
curr_mark_node,
parent_id_opt,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
let is_blank_node = curr_mark_node.is_blank();
@ -109,7 +109,7 @@ pub fn update_empty_record(
curr_mark_node,
parent_id_opt,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
if prev_mark_node.get_content()? == nodes::LEFT_ACCOLADE
&& curr_mark_node.get_content()? == nodes::RIGHT_ACCOLADE
@ -182,7 +182,7 @@ pub fn update_record_colon(
curr_mark_node,
parent_id_opt,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
if let Some(parent_id) = parent_id_opt {
let curr_ast_node = ed_model.module.env.pool.get(ast_node_id);

View File

@ -22,7 +22,7 @@ pub fn update_small_string(
curr_mark_node: _,
parent_id_opt: _,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
let new_input = &new_char.to_string();
@ -84,7 +84,7 @@ pub fn update_string(
curr_mark_node: _,
parent_id_opt: _,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
// update markup
let curr_mark_node_mut = ed_model.markup_node_pool.get_mut(curr_mark_node_id);
@ -129,7 +129,7 @@ pub fn start_new_string(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
curr_mark_node,
parent_id_opt,
ast_node_id,
} = get_node_context(&ed_model)?;
} = get_node_context(ed_model)?;
if curr_mark_node.is_blank() {
let new_expr2_node = Expr2::SmallStr(arraystring::ArrayString::new());

View File

@ -108,7 +108,7 @@ fn markup_to_wgpu_helper<'a>(
attributes: _,
parent_id_opt: _,
} => {
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, &syn_high_style)?;
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, syn_high_style)?;
let glyph_text = glyph_brush::OwnedText::new(content)
.with_color(colors::to_slice(*highlight_color))
@ -127,7 +127,7 @@ fn markup_to_wgpu_helper<'a>(
.with_color(colors::to_slice(colors::WHITE))
.with_scale(code_style.font_size);
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, &syn_high_style)?;
let highlight_color = map_get(&code_style.ed_theme.syntax_high_map, syn_high_style)?;
let char_width = code_style.glyph_dim_rect.width;
let char_height = code_style.glyph_dim_rect.height;

View File

@ -121,10 +121,10 @@ pub fn create_rect_buffers(
let num_rects = {
let mut quad_buffer_builder = QuadBufferBuilder::new();
for rect in rects {
quad_buffer_builder = quad_buffer_builder.push_rect(&rect);
quad_buffer_builder = quad_buffer_builder.push_rect(rect);
}
let (stg_vertex, stg_index, num_indices) = quad_buffer_builder.build(&gpu_device);
let (stg_vertex, stg_index, num_indices) = quad_buffer_builder.build(gpu_device);
stg_vertex.copy_to_buffer(encoder, &vertex_buffer);
stg_index.copy_to_buffer(encoder, &index_buffer);

View File

@ -19,7 +19,7 @@ pub fn make_rect_pipeline(
label: Some("Rectangle pipeline layout"),
});
let pipeline = create_render_pipeline(
&gpu_device,
gpu_device,
&pipeline_layout,
swap_chain_descr.format,
&wgpu::ShaderModuleDescriptor {
@ -42,7 +42,7 @@ pub fn create_render_pipeline(
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: Some("Render pipeline"),
layout: Some(&layout),
layout: Some(layout),
vertex: wgpu::VertexState {
module: &shader,
entry_point: "vs_main",

View File

@ -81,7 +81,7 @@ fn section_from_text<'a>(
..Section::default()
}
.add_text(
wgpu_glyph::Text::new(&text.text)
wgpu_glyph::Text::new(text.text)
.with_color(Vector4::from(text.color))
.with_scale(text.size),
)
@ -156,5 +156,5 @@ pub fn build_glyph_brush(
) -> Result<GlyphBrush<()>, InvalidFont> {
let inconsolata = FontArc::try_from_slice(include_bytes!("../../../Inconsolata-Regular.ttf"))?;
Ok(GlyphBrushBuilder::using_font(inconsolata).build(&gpu_device, render_format))
Ok(GlyphBrushBuilder::using_font(inconsolata).build(gpu_device, render_format))
}

View File

@ -472,7 +472,7 @@ fn expr2_to_string_helper(
Expr2::EmptyRecord => out_string.push_str("EmptyRecord"),
Expr2::Record { record_var, fields } => {
out_string.push_str("Record:\n");
out_string.push_str(&var_to_string(&record_var, indent_level + 1));
out_string.push_str(&var_to_string(record_var, indent_level + 1));
out_string.push_str(&format!("{}fields: [\n", get_spacing(indent_level + 1)));

View File

@ -1129,7 +1129,7 @@ pub fn constrain_pattern<'a>(
let pat_type = Type2::Variable(*var);
let expected = PExpected::NoExpectation(pat_type.shallow_clone());
if !state.headers.contains_key(&symbol) {
if !state.headers.contains_key(symbol) {
state.headers.insert(*symbol, pat_type.shallow_clone());
}

View File

@ -37,11 +37,11 @@ impl<'a> File<'a> {
let allocation = arena.alloc(bytes);
let module_parse_state = parser::State::new(allocation);
let parsed_module = roc_parse::module::parse_header(&arena, module_parse_state);
let parsed_module = roc_parse::module::parse_header(arena, module_parse_state);
match parsed_module {
Ok((module, state)) => {
let parsed_defs = module_defs().parse(&arena, state);
let parsed_defs = module_defs().parse(arena, state);
match parsed_defs {
Ok((_, defs, _)) => Ok(File {

View File

@ -44,7 +44,7 @@ impl<'a> ToolTip<'a> {
)
.into(),
color: ui_theme.tooltip_text,
text: &self.text,
text: self.text,
size: ui_theme.default_font_size,
..Default::default()
}

View File

@ -121,7 +121,7 @@ fn infer_eq(actual: &str, expected_str: &str) {
all_ident_ids: dep_idents,
};
let actual_str = content_to_string(content, &subs, mod_id, &interns);
let actual_str = content_to_string(content, subs, mod_id, &interns);
assert_eq!(actual_str, expected_str);
}

View File

@ -1612,7 +1612,7 @@ fn hash_bstr(hasher: &mut Sha256, bstr: &[u8]) {
fn hash_func_name(mod_: ModName, func: FuncName) -> FuncSpec {
let mut hasher = Sha256::new();
hash_bstr(&mut hasher, &mod_.0);
hash_bstr(&mut hasher, &func.0);
hash_bstr(&mut hasher, mod_.0);
hash_bstr(&mut hasher, func.0);
FuncSpec(hasher.finalize().into())
}

View File

@ -679,8 +679,8 @@ fn preprocess_block_expr(
values_in_scope,
continuations_in_scope,
block,
&api_node.op,
&api_node.inputs,
api_node.op,
api_node.inputs,
)
.map_err(Error::annotate_binding(BindingLocation::Value(
api_value_id,
@ -1149,7 +1149,7 @@ fn preprocess_func_def(
let (final_block, ret_val) = preprocess_block_expr(
tc,
ctx,
&api_builder,
api_builder,
body_types,
&mut graph_builder,
&mut values_in_scope,
@ -1183,7 +1183,7 @@ fn preprocess_const_def(
let (final_block, ret_val) = preprocess_block_expr(
tc,
ctx,
&api_builder,
api_builder,
body_types,
&mut graph_builder,
&mut values_in_scope,