Merge branch 'main' of github.com:roc-lang/roc into rust_version_upgrade

This commit is contained in:
Anton-4 2023-04-22 17:14:01 +02:00
commit 937722c462
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
36 changed files with 217 additions and 198 deletions

18
FAQ.md
View file

@ -188,23 +188,19 @@ would be unable to infer a type—and you'd have to write a type annotation. Thi
situations where the editor would not be able to reliably tell you the type of part of your program, unlike today
where it can accurately tell you the type of anything, even if you have no type annotations in your entire code base.
### Arbitrary-rank types
assuming that's right, here is a proposed new FAQ entry:
Unlike arbitrary-rank (aka "Rank-N") types, both Rank-1 and Rank-2 type systems are compatible with principal
type inference. Roc currently uses Rank-1 types, and the benefits of Rank-N over Rank-2 don't seem worth
sacrificing principal type inference to attain, so let's focus on the trade-offs between Rank-1 and Rank-2.
Supporting Rank-2 types in Roc has been discussed before, but it has several important downsides:
### Higher-rank types
Roc uses a Rank-1 type system. Other languages, like Haskell, support Rank-2 or even arbitrary-rank (aka "Rank-N") types. Supporting higher-rank types in Roc has been discussed before, but it has several important downsides:
- It would remove principal decidable type inference. (Only Rank-1 types are compatible with principal decidable type inference; Rank-2 types are decidable but the inferred types are not principal, and Rank 3+ types are not even fully decidable.)
- It would increase the complexity of the language.
- It would make some compiler error messages more confusing (e.g. they might mention `forall` because that was the most general type that could be inferred, even if that wasn't helpful or related to the actual problem).
- It would substantially increase the complexity of the type checker, which would necessarily slow it down.
- Most significantly, it would make the runtime slower, because Roc compiles programs by fully specializing all function calls to their type instances (this is sometimes called monomorphization). It's unclear how we could fully specialize programs containing Rank-2 types, which means compiling programs that included Rank-2 types (or higher) would require losing specialization in general—which would substantially degrade runtime performance.
No implementation of Rank-2 types can remove any of these downsides. Thus far, we've been able to come up
with sufficiently nice APIs that only require Rank-1 types, and we haven't seen a really compelling use case
where the gap between the Rank-2 and Rank-1 designs was big enough to justify switching to Rank-2.
As such, the plan is for Roc to stick with Rank-1 types indefinitely. In Roc's case, the benefits of Rank-1's faster compilation with nicer error messages and a simpler type system outweigh Rank-2's benefits of expanded API options.
As such, the plan is for Roc to stick with Rank-1 types indefinitely.
### Higher-kinded polymorphism

View file

@ -1959,8 +1959,8 @@ pub mod test_constrain {
};
use indoc::indoc;
fn run_solve<'a>(
arena: &'a Bump,
fn run_solve(
arena: &Bump,
mempool: &mut Pool,
aliases: MutMap<Symbol, roc_types::types::Alias>,
rigid_variables: MutMap<Variable, Lowercase>,

View file

@ -183,7 +183,7 @@ impl Pool {
}
}
pub fn get<'a, 'b, T>(&'a self, node_id: NodeId<T>) -> &'b T {
pub fn get<'b, T>(&self, node_id: NodeId<T>) -> &'b T {
unsafe {
let node_ptr = self.get_ptr(node_id) as *const T;

View file

@ -100,11 +100,11 @@ pub fn format(files: std::vec::Vec<PathBuf>, mode: FormatMode) -> Result<(), Str
let mut before_file = file.clone();
before_file.set_extension("roc-format-failed-ast-before");
std::fs::write(&before_file, &format!("{:#?}\n", ast_normalized)).unwrap();
std::fs::write(&before_file, format!("{:#?}\n", ast_normalized)).unwrap();
let mut after_file = file.clone();
after_file.set_extension("roc-format-failed-ast-after");
std::fs::write(&after_file, &format!("{:#?}\n", reparsed_ast_normalized)).unwrap();
std::fs::write(&after_file, format!("{:#?}\n", reparsed_ast_normalized)).unwrap();
internal_error!(
"Formatting bug; formatting didn't reparse as the same tree\n\n\

View file

@ -1234,9 +1234,10 @@ fn run_wasm<I: Iterator<Item = S>, S: AsRef<[u8]>>(_wasm_path: &std::path::Path,
println!("Running wasm files is not supported on this target.");
}
#[derive(Debug, Copy, Clone, EnumIter, IntoStaticStr, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, EnumIter, IntoStaticStr, PartialEq, Eq, Default)]
pub enum Target {
#[strum(serialize = "system")]
#[default]
System,
#[strum(serialize = "linux32")]
Linux32,
@ -1248,12 +1249,6 @@ pub enum Target {
Wasm32,
}
impl Default for Target {
fn default() -> Self {
Target::System
}
}
impl Target {
pub fn to_triple(self) -> Triple {
use Target::*;

View file

@ -13,8 +13,8 @@ use crate::{
slow_pool::{MarkNodeId, SlowPool},
};
pub fn ast_to_mark_nodes<'a>(
env: &mut Env<'a>,
pub fn ast_to_mark_nodes(
env: &mut Env<'_>,
ast: &AST,
mark_node_pool: &mut SlowPool,
interns: &Interns,

View file

@ -35,8 +35,8 @@ pub fn add_node(
mark_node_id
}
pub fn def2_to_markup<'a>(
env: &mut Env<'a>,
pub fn def2_to_markup(
env: &mut Env<'_>,
def2: &Def2,
def2_node_id: DefId,
mark_node_pool: &mut SlowPool,

View file

@ -35,8 +35,8 @@ use roc_module::{module_err::ModuleResult, symbol::Interns};
use super::from_def2::add_node;
// make Markup Nodes: generate String representation, assign Highlighting Style
pub fn expr2_to_markup<'a>(
env: &Env<'a>,
pub fn expr2_to_markup(
env: &Env<'_>,
expr2: &Expr2,
expr2_node_id: ExprId,
mark_node_pool: &mut SlowPool,

View file

@ -258,7 +258,7 @@ pub fn make_nested_mn(children_ids: Vec<MarkNodeId>, newlines_at_end: usize) ->
}
}
pub fn get_string<'a>(env: &Env<'a>, pool_str: &PoolStr) -> String {
pub fn get_string(env: &Env<'_>, pool_str: &PoolStr) -> String {
pool_str.as_str(env.pool).to_owned()
}

View file

@ -19,13 +19,13 @@ use super::{
};
// represents for example: `main = "Hello, World!"`
pub fn assignment_mark_node<'a>(
pub fn assignment_mark_node(
identifier_id: IdentId,
expr_mark_node_id: MarkNodeId,
ast_node_id: ASTNodeId,
mark_node_pool: &mut SlowPool,
mark_id_ast_id_map: &mut MarkIdAstIdMap,
env: &Env<'a>,
env: &Env<'_>,
) -> ASTResult<MarkupNode> {
let val_name = env.ident_ids.get_name_str_res(identifier_id)?;

View file

@ -487,9 +487,9 @@ impl<'a> Env<'a> {
}
}
fn apply_refcount_operation<'a>(
fn apply_refcount_operation(
builder: &mut FuncDefBuilder,
env: &mut Env<'a>,
env: &mut Env<'_>,
block: BlockId,
modify_rc: &ModifyRc,
) -> Result<()> {

View file

@ -719,7 +719,7 @@ pub fn rebuild_host(
if matches!(opt_level, OptLevel::Optimize) {
rustc_cmd.arg("-O");
} else if matches!(opt_level, OptLevel::Size) {
rustc_cmd.arg("-C opt-level=s");
rustc_cmd.args(["-C", "opt-level=s"]);
}
run_build_command(rustc_cmd, "host.rs", 0);
@ -1100,7 +1100,7 @@ fn link_linux(
// Keep NIX_ env vars
.envs(
env::vars()
.filter(|&(ref k, _)| k.starts_with("NIX_"))
.filter(|(k, _)| k.starts_with("NIX_"))
.collect::<HashMap<String, String>>(),
)
.args([

View file

@ -1142,7 +1142,11 @@ fn can_extension_type(
introduced_variables: &mut IntroducedVariables,
local_aliases: &mut VecMap<Symbol, Alias>,
references: &mut VecSet<Symbol>,
<<<<<<< HEAD
opt_ext: &Option<&Loc<TypeAnnotation>>,
=======
opt_ext: &Option<&Loc<TypeAnnotation<'_>>>,
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
ext_problem_kind: roc_problem::can::ExtensionTypeKind,
) -> (Type, ExtImplicitOpenness) {
fn valid_record_ext_type(typ: &Type) -> bool {
@ -1454,7 +1458,11 @@ fn can_assigned_fields<'a>(
fn can_assigned_tuple_elems(
env: &mut Env,
pol: CanPolarity,
<<<<<<< HEAD
elems: &&[Loc<TypeAnnotation>],
=======
elems: &&[Loc<TypeAnnotation<'_>>],
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
scope: &mut Scope,
var_store: &mut VarStore,
introduced_variables: &mut IntroducedVariables,

View file

@ -1050,8 +1050,12 @@ fn canonicalize_value_defs<'a>(
let mut symbol_to_index: Vec<(IdentId, u32)> = Vec::with_capacity(pending_value_defs.len());
for (def_index, pending_def) in pending_value_defs.iter().enumerate() {
<<<<<<< HEAD
let mut new_bindings = BindingsFromPattern::new(pending_def.loc_pattern())
.peekable();
=======
let mut new_bindings = BindingsFromPattern::new(pending_def.loc_pattern()).peekable();
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
if new_bindings.peek().is_none() {
env.problem(Problem::NoIdentifiersIntroduced(
@ -1339,7 +1343,11 @@ fn canonicalize_type_defs<'a>(
/// Resolve all pending abilities, to add them to scope.
#[allow(clippy::too_many_arguments)]
fn resolve_abilities(
<<<<<<< HEAD
env: &mut Env,
=======
env: &mut Env<'_>,
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
output: &mut Output,
var_store: &mut VarStore,
scope: &mut Scope,
@ -2813,7 +2821,11 @@ fn to_pending_value_def<'a>(
/// Make aliases recursive
fn correct_mutual_recursive_type_alias(
<<<<<<< HEAD
env: &mut Env,
=======
env: &mut Env<'_>,
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
original_aliases: VecMap<Symbol, Alias>,
var_store: &mut VarStore,
) -> VecMap<Symbol, Alias> {
@ -3022,7 +3034,11 @@ fn correct_mutual_recursive_type_alias(
}
fn make_tag_union_of_alias_recursive(
<<<<<<< HEAD
env: &mut Env,
=======
env: &mut Env<'_>,
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
alias_name: Symbol,
alias: &mut Alias,
others: Vec<Symbol>,
@ -3215,7 +3231,11 @@ fn make_tag_union_recursive_help<'a, 'b>(
}
fn mark_cyclic_alias(
<<<<<<< HEAD
env: &mut Env,
=======
env: &mut Env<'_>,
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
typ: &mut Type,
symbol: Symbol,
alias_kind: AliasKind,

View file

@ -199,7 +199,11 @@ impl GeneratedInfo {
env: &mut Env,
scope: &mut Scope,
var_store: &mut VarStore,
<<<<<<< HEAD
header_type: &HeaderType,
=======
header_type: &HeaderType<'_>,
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
) -> Self {
match header_type {
HeaderType::Hosted {

View file

@ -322,7 +322,11 @@ pub fn canonicalize_def_header_pattern<'a>(
pub struct PermitShadows(pub bool);
fn canonicalize_pattern_symbol(
<<<<<<< HEAD
env: &mut Env,
=======
env: &mut Env<'_>,
>>>>>>> 28146c939f11c8b65504c9d35c69fdef31b976e8
scope: &mut Scope,
output: &mut Output,
region: Region,

View file

@ -466,7 +466,7 @@ fn is_multiline_assigned_field_help<T: Formattable>(afield: &AssignedField<'_, T
}
}
fn format_assigned_field_help< T>(
fn format_assigned_field_help<T>(
zelf: &AssignedField<T>,
buf: &mut Buf,
indent: u16,

View file

@ -44,9 +44,9 @@ macro_rules! keywords {
false
}
fn format_with_options<'buf>(
fn format_with_options(
&self,
buf: &mut Buf<'buf>,
buf: &mut Buf<'_>,
_parens: crate::annotation::Parens,
_newlines: Newlines,
indent: u16,

View file

@ -385,11 +385,11 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg, AArch64Assembler> for AArch64C
}
#[inline(always)]
fn load_args<'a, 'r>(
fn load_args<'a>(
_buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<
'a,
'r,
'_,
AArch64GeneralReg,
AArch64FloatReg,
AArch64Assembler,
@ -403,11 +403,11 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg, AArch64Assembler> for AArch64C
}
#[inline(always)]
fn store_args<'a, 'r>(
fn store_args<'a>(
_buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<
'a,
'r,
'_,
AArch64GeneralReg,
AArch64FloatReg,
AArch64Assembler,
@ -422,11 +422,11 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg, AArch64Assembler> for AArch64C
todo!("Storing args for AArch64");
}
fn return_complex_symbol<'a, 'r>(
fn return_complex_symbol<'a>(
_buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<
'a,
'r,
'_,
AArch64GeneralReg,
AArch64FloatReg,
AArch64Assembler,
@ -439,11 +439,11 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg, AArch64Assembler> for AArch64C
todo!("Returning complex symbols for AArch64");
}
fn load_returned_complex_symbol<'a, 'r>(
fn load_returned_complex_symbol<'a>(
_buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<
'a,
'r,
'_,
AArch64GeneralReg,
AArch64FloatReg,
AArch64Assembler,
@ -532,9 +532,9 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
mul_reg64_reg64_reg64(buf, dst, src1, src2);
}
fn umul_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn umul_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<'a, 'r, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
_storage_manager: &mut StorageManager<'a, '_, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
dst: AArch64GeneralReg,
src1: AArch64GeneralReg,
src2: AArch64GeneralReg,
@ -545,9 +545,9 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
mul_reg64_reg64_reg64(buf, dst, src1, src2);
}
fn idiv_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn idiv_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<'a, 'r, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
_storage_manager: &mut StorageManager<'a, '_, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
dst: AArch64GeneralReg,
src1: AArch64GeneralReg,
src2: AArch64GeneralReg,
@ -558,9 +558,9 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
sdiv_reg64_reg64_reg64(buf, dst, src1, src2);
}
fn udiv_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn udiv_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<'a, 'r, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
_storage_manager: &mut StorageManager<'a, '_, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
dst: AArch64GeneralReg,
src1: AArch64GeneralReg,
src2: AArch64GeneralReg,
@ -1096,9 +1096,9 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
eor_reg64_reg64_reg64(buf, dst, src1, src2);
}
fn shl_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn shl_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<'a, 'r, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
_storage_manager: &mut StorageManager<'a, '_, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
dst: AArch64GeneralReg,
src1: AArch64GeneralReg,
src2: AArch64GeneralReg,
@ -1109,9 +1109,9 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
lsl_reg64_reg64_reg64(buf, dst, src1, src2);
}
fn shr_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn shr_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<'a, 'r, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
_storage_manager: &mut StorageManager<'a, '_, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
dst: AArch64GeneralReg,
src1: AArch64GeneralReg,
src2: AArch64GeneralReg,
@ -1122,9 +1122,9 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
lsr_reg64_reg64_reg64(buf, dst, src1, src2);
}
fn sar_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn sar_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<'a, 'r, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
_storage_manager: &mut StorageManager<'a, '_, AArch64GeneralReg, AArch64FloatReg, ASM, CC>,
dst: AArch64GeneralReg,
src1: AArch64GeneralReg,
src2: AArch64GeneralReg,

View file

@ -62,15 +62,15 @@ pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait, ASM: Assembler<Gene
!Self::float_callee_saved(reg)
}
fn setup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn setup_stack(
buf: &mut Vec<'_, u8>,
general_saved_regs: &[GeneralReg],
float_saved_regs: &[FloatReg],
requested_stack_size: i32,
fn_call_stack_size: i32,
) -> i32;
fn cleanup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn cleanup_stack(
buf: &mut Vec<'_, u8>,
general_saved_regs: &[GeneralReg],
float_saved_regs: &[FloatReg],
aligned_stack_size: i32,
@ -78,9 +78,9 @@ pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait, ASM: Assembler<Gene
);
/// load_args updates the storage manager to know where every arg is stored.
fn load_args<'a, 'r>(
fn load_args<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, Self>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, Self>,
layout_interner: &mut STLayoutInterner<'a>,
args: &'a [(InLayout<'a>, Symbol)],
// ret_layout is needed because if it is a complex type, we pass a pointer as the first arg.
@ -89,9 +89,9 @@ pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait, ASM: Assembler<Gene
/// store_args stores the args in registers and on the stack for function calling.
/// It also updates the amount of temporary stack space needed in the storage manager.
fn store_args<'a, 'r>(
fn store_args<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, Self>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, Self>,
layout_interner: &mut STLayoutInterner<'a>,
dst: &Symbol,
args: &[Symbol],
@ -102,9 +102,9 @@ pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait, ASM: Assembler<Gene
/// return_complex_symbol returns the specified complex/non-primative symbol.
/// It uses the layout to determine how the data should be returned.
fn return_complex_symbol<'a, 'r>(
fn return_complex_symbol<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, Self>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, Self>,
layout_interner: &mut STLayoutInterner<'a>,
sym: &Symbol,
layout: &InLayout<'a>,
@ -112,9 +112,9 @@ pub trait CallConv<GeneralReg: RegTrait, FloatReg: RegTrait, ASM: Assembler<Gene
/// load_returned_complex_symbol loads a complex symbol that was returned from a function call.
/// It uses the layout to determine how the data should be loaded into the symbol.
fn load_returned_complex_symbol<'a, 'r>(
fn load_returned_complex_symbol<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, Self>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, Self>,
layout_interner: &mut STLayoutInterner<'a>,
sym: &Symbol,
layout: &InLayout<'a>,
@ -184,9 +184,9 @@ pub trait Assembler<GeneralReg: RegTrait, FloatReg: RegTrait>: Sized + Copy {
src2: GeneralReg,
);
fn shl_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn shl_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, CC>,
dst: GeneralReg,
src1: GeneralReg,
src2: GeneralReg,
@ -194,9 +194,9 @@ pub trait Assembler<GeneralReg: RegTrait, FloatReg: RegTrait>: Sized + Copy {
ASM: Assembler<GeneralReg, FloatReg>,
CC: CallConv<GeneralReg, FloatReg, ASM>;
fn shr_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn shr_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, CC>,
dst: GeneralReg,
src1: GeneralReg,
src2: GeneralReg,
@ -204,9 +204,9 @@ pub trait Assembler<GeneralReg: RegTrait, FloatReg: RegTrait>: Sized + Copy {
ASM: Assembler<GeneralReg, FloatReg>,
CC: CallConv<GeneralReg, FloatReg, ASM>;
fn sar_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn sar_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, CC>,
dst: GeneralReg,
src1: GeneralReg,
src2: GeneralReg,
@ -359,9 +359,9 @@ pub trait Assembler<GeneralReg: RegTrait, FloatReg: RegTrait>: Sized + Copy {
src1: GeneralReg,
src2: GeneralReg,
);
fn umul_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn umul_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, CC>,
dst: GeneralReg,
src1: GeneralReg,
src2: GeneralReg,
@ -369,18 +369,18 @@ pub trait Assembler<GeneralReg: RegTrait, FloatReg: RegTrait>: Sized + Copy {
ASM: Assembler<GeneralReg, FloatReg>,
CC: CallConv<GeneralReg, FloatReg, ASM>;
fn idiv_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn idiv_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, CC>,
dst: GeneralReg,
src1: GeneralReg,
src2: GeneralReg,
) where
ASM: Assembler<GeneralReg, FloatReg>,
CC: CallConv<GeneralReg, FloatReg, ASM>;
fn udiv_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn udiv_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, GeneralReg, FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, GeneralReg, FloatReg, ASM, CC>,
dst: GeneralReg,
src1: GeneralReg,
src2: GeneralReg,
@ -1776,7 +1776,7 @@ impl<
self.storage_manager.with_tmp_general_reg(
&mut self.buf,
|storage_manager, buf, list_ptr| {
ASM::mov_reg64_base32(buf, list_ptr, base_offset as i32);
ASM::mov_reg64_base32(buf, list_ptr, base_offset);
storage_manager.with_tmp_general_reg(buf, |storage_manager, buf, tmp| {
// calculate `element_width * index`
ASM::mov_reg64_imm64(buf, tmp, ret_stack_size as i64);

View file

@ -216,8 +216,8 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
}
#[inline(always)]
fn setup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn setup_stack(
buf: &mut Vec<'_, u8>,
saved_general_regs: &[X86_64GeneralReg],
saved_float_regs: &[X86_64FloatReg],
requested_stack_size: i32,
@ -233,8 +233,8 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
}
#[inline(always)]
fn cleanup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn cleanup_stack(
buf: &mut Vec<'_, u8>,
saved_general_regs: &[X86_64GeneralReg],
saved_float_regs: &[X86_64FloatReg],
aligned_stack_size: i32,
@ -250,11 +250,11 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
}
#[inline(always)]
fn load_args<'a, 'r>(
fn load_args<'a>(
_buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<
'a,
'r,
'_,
X86_64GeneralReg,
X86_64FloatReg,
X86_64Assembler,
@ -284,11 +284,11 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
}
#[inline(always)]
fn store_args<'a, 'r>(
fn store_args<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<
'a,
'r,
'_,
X86_64GeneralReg,
X86_64FloatReg,
X86_64Assembler,
@ -330,11 +330,11 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
storage_manager.update_fn_call_stack_size(state.tmp_stack_offset as u32);
}
fn return_complex_symbol<'a, 'r>(
fn return_complex_symbol<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<
'a,
'r,
'_,
X86_64GeneralReg,
X86_64FloatReg,
X86_64Assembler,
@ -388,11 +388,11 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Syste
}
}
fn load_returned_complex_symbol<'a, 'r>(
fn load_returned_complex_symbol<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<
'a,
'r,
'_,
X86_64GeneralReg,
X86_64FloatReg,
X86_64Assembler,
@ -447,10 +447,10 @@ impl X64_64SystemVStoreArgs {
const FLOAT_PARAM_REGS: &'static [X86_64FloatReg] = X86_64SystemV::FLOAT_PARAM_REGS;
const FLOAT_RETURN_REGS: &'static [X86_64FloatReg] = X86_64SystemV::FLOAT_RETURN_REGS;
fn store_arg<'a, 'r>(
fn store_arg<'a>(
&mut self,
buf: &mut Vec<'a, u8>,
storage_manager: &mut X86_64StorageManager<'a, 'r, X86_64SystemV>,
storage_manager: &mut X86_64StorageManager<'a, '_, X86_64SystemV>,
layout_interner: &mut STLayoutInterner<'a>,
sym: Symbol,
in_layout: InLayout<'a>,
@ -537,10 +537,10 @@ impl X64_64SystemVStoreArgs {
}
}
fn store_arg_general<'a, 'r>(
fn store_arg_general<'a>(
&mut self,
buf: &mut Vec<'a, u8>,
storage_manager: &mut X86_64StorageManager<'a, 'r, X86_64SystemV>,
storage_manager: &mut X86_64StorageManager<'a, '_, X86_64SystemV>,
sym: Symbol,
) {
if self.general_i < Self::GENERAL_PARAM_REGS.len() {
@ -562,10 +562,10 @@ impl X64_64SystemVStoreArgs {
}
}
fn store_arg_float<'a, 'r>(
fn store_arg_float<'a>(
&mut self,
buf: &mut Vec<'a, u8>,
storage_manager: &mut X86_64StorageManager<'a, 'r, X86_64SystemV>,
storage_manager: &mut X86_64StorageManager<'a, '_, X86_64SystemV>,
sym: Symbol,
) {
if self.float_i < Self::FLOAT_PARAM_REGS.len() {
@ -598,9 +598,9 @@ type X86_64StorageManager<'a, 'r, CallConv> =
StorageManager<'a, 'r, X86_64GeneralReg, X86_64FloatReg, X86_64Assembler, CallConv>;
impl X64_64SystemVLoadArgs {
fn load_arg<'a, 'r>(
fn load_arg<'a>(
&mut self,
storage_manager: &mut X86_64StorageManager<'a, 'r, X86_64SystemV>,
storage_manager: &mut X86_64StorageManager<'a, '_, X86_64SystemV>,
layout_interner: &mut STLayoutInterner<'a>,
sym: Symbol,
in_layout: InLayout<'a>,
@ -645,9 +645,9 @@ impl X64_64SystemVLoadArgs {
}
}
fn load_arg_general<'a, 'r>(
fn load_arg_general(
&mut self,
storage_manager: &mut X86_64StorageManager<'a, 'r, X86_64SystemV>,
storage_manager: &mut X86_64StorageManager<'_, '_, X86_64SystemV>,
sym: Symbol,
) {
if self.general_i < X86_64SystemV::GENERAL_PARAM_REGS.len() {
@ -660,9 +660,9 @@ impl X64_64SystemVLoadArgs {
}
}
fn load_arg_float<'a, 'r>(
fn load_arg_float(
&mut self,
storage_manager: &mut X86_64StorageManager<'a, 'r, X86_64SystemV>,
storage_manager: &mut X86_64StorageManager<'_, '_, X86_64SystemV>,
sym: Symbol,
) {
if self.general_i < X86_64SystemV::GENERAL_PARAM_REGS.len() {
@ -783,8 +783,8 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Windo
}
#[inline(always)]
fn setup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn setup_stack(
buf: &mut Vec<'_, u8>,
saved_general_regs: &[X86_64GeneralReg],
saved_float_regs: &[X86_64FloatReg],
requested_stack_size: i32,
@ -800,8 +800,8 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Windo
}
#[inline(always)]
fn cleanup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn cleanup_stack(
buf: &mut Vec<'_, u8>,
saved_general_regs: &[X86_64GeneralReg],
saved_float_regs: &[X86_64FloatReg],
aligned_stack_size: i32,
@ -817,9 +817,9 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Windo
}
#[inline(always)]
fn load_args<'a, 'r>(
fn load_args<'a>(
_buf: &mut Vec<'a, u8>,
storage_manager: &mut X86_64StorageManager<'a, 'r, X86_64WindowsFastcall>,
storage_manager: &mut X86_64StorageManager<'a, '_, X86_64WindowsFastcall>,
layout_interner: &mut STLayoutInterner<'a>,
args: &'a [(InLayout<'a>, Symbol)],
ret_layout: &InLayout<'a>,
@ -861,11 +861,11 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Windo
}
#[inline(always)]
fn store_args<'a, 'r>(
fn store_args<'a>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<
'a,
'r,
'_,
X86_64GeneralReg,
X86_64FloatReg,
X86_64Assembler,
@ -938,11 +938,11 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Windo
storage_manager.update_fn_call_stack_size(tmp_stack_offset as u32);
}
fn return_complex_symbol<'a, 'r>(
fn return_complex_symbol<'a>(
_buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<
'a,
'r,
'_,
X86_64GeneralReg,
X86_64FloatReg,
X86_64Assembler,
@ -955,11 +955,11 @@ impl CallConv<X86_64GeneralReg, X86_64FloatReg, X86_64Assembler> for X86_64Windo
todo!("Returning complex symbols for X86_64");
}
fn load_returned_complex_symbol<'a, 'r>(
fn load_returned_complex_symbol<'a>(
_buf: &mut Vec<'a, u8>,
_storage_manager: &mut StorageManager<
'a,
'r,
'_,
X86_64GeneralReg,
X86_64FloatReg,
X86_64Assembler,
@ -985,8 +985,8 @@ impl X86_64WindowsFastcall {
}
#[inline(always)]
fn x86_64_generic_setup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn x86_64_generic_setup_stack(
buf: &mut Vec<'_, u8>,
saved_general_regs: &[X86_64GeneralReg],
saved_float_regs: &[X86_64FloatReg],
requested_stack_size: i32,
@ -1042,8 +1042,8 @@ fn x86_64_generic_setup_stack<'a>(
#[inline(always)]
#[allow(clippy::unnecessary_wraps)]
fn x86_64_generic_cleanup_stack<'a>(
buf: &mut Vec<'a, u8>,
fn x86_64_generic_cleanup_stack(
buf: &mut Vec<'_, u8>,
saved_general_regs: &[X86_64GeneralReg],
saved_float_regs: &[X86_64FloatReg],
aligned_stack_size: i32,
@ -1183,9 +1183,9 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
imul_reg64_reg64(buf, dst, src2);
}
fn umul_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn umul_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
dst: X86_64GeneralReg,
src1: X86_64GeneralReg,
src2: X86_64GeneralReg,
@ -1267,9 +1267,9 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
}
}
fn idiv_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn idiv_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
dst: X86_64GeneralReg,
src1: X86_64GeneralReg,
src2: X86_64GeneralReg,
@ -1287,9 +1287,9 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
mov_reg64_reg64(buf, dst, X86_64GeneralReg::RAX);
}
fn udiv_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn udiv_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
dst: X86_64GeneralReg,
src1: X86_64GeneralReg,
src2: X86_64GeneralReg,
@ -1734,9 +1734,9 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
binop_move_src_to_dst_reg64(buf, xor_reg64_reg64, dst, src1, src2)
}
fn shl_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn shl_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
dst: X86_64GeneralReg,
src1: X86_64GeneralReg,
src2: X86_64GeneralReg,
@ -1747,9 +1747,9 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
shift_reg64_reg64_reg64(buf, storage_manager, shl_reg64_reg64, dst, src1, src2)
}
fn shr_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn shr_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
dst: X86_64GeneralReg,
src1: X86_64GeneralReg,
src2: X86_64GeneralReg,
@ -1760,9 +1760,9 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
shift_reg64_reg64_reg64(buf, storage_manager, shr_reg64_reg64, dst, src1, src2)
}
fn sar_reg64_reg64_reg64<'a, 'r, ASM, CC>(
fn sar_reg64_reg64_reg64<'a, ASM, CC>(
buf: &mut Vec<'a, u8>,
storage_manager: &mut StorageManager<'a, 'r, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
storage_manager: &mut StorageManager<'a, '_, X86_64GeneralReg, X86_64FloatReg, ASM, CC>,
dst: X86_64GeneralReg,
src1: X86_64GeneralReg,
src2: X86_64GeneralReg,

View file

@ -885,7 +885,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
self.code_builder.f32_eq();
}
ValueType::F64 => {
self.code_builder.f64_const(f64::from_bits(*value as u64));
self.code_builder.f64_const(f64::from_bits(*value));
self.code_builder.f64_eq();
}
}
@ -1114,7 +1114,7 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
match storage {
StoredValue::VirtualMachineStack { value_type, .. } => {
match (lit, value_type) {
(Literal::Float(x), ValueType::F64) => self.code_builder.f64_const(*x as f64),
(Literal::Float(x), ValueType::F64) => self.code_builder.f64_const(*x),
(Literal::Float(x), ValueType::F32) => self.code_builder.f32_const(*x as f32),
(Literal::Int(x), ValueType::I64) => {
self.code_builder.i64_const(i128::from_ne_bytes(*x) as i64)

View file

@ -506,7 +506,7 @@ impl<'a> CodeBuilder<'a> {
stack_size
);
let new_len = stack_size - pops as usize;
let new_len = stack_size - pops;
current_stack.truncate(new_len);
if push {
current_stack.push(Symbol::WASM_TMP);

View file

@ -2347,8 +2347,8 @@ macro_rules! debug_check_ir {
}
/// Report modules that are imported, but from which nothing is used
fn report_unused_imported_modules<'a>(
state: &mut State<'a>,
fn report_unused_imported_modules(
state: &mut State<'_>,
module_id: ModuleId,
constrained_module: &ConstrainedModule,
) {

View file

@ -23,7 +23,7 @@ macro_rules! cache_interned_layouts {
)*
}
fn fill_reserved_layouts<'a>(interner: &mut STLayoutInterner<'a>) {
fn fill_reserved_layouts(interner: &mut STLayoutInterner<'_>) {
assert!(interner.is_empty());
$(
interner.insert($layout);

View file

@ -183,7 +183,7 @@ fn parse_queries(src: &str, line_info: &LineInfo) -> Vec<TypeQuery> {
}
};
let mut queries_on_line = RE_TYPE_QUERY.captures_iter(line).into_iter().peekable();
let mut queries_on_line = RE_TYPE_QUERY.captures_iter(line).peekable();
if queries_on_line.peek().is_none() || line.contains(MUTLILINE_MARKER) {
consecutive_query_lines = 0;

View file

@ -67,8 +67,8 @@ impl RenderedWgpu {
}
// create text and rectangles based on EdModel's markup_root
pub fn model_to_wgpu<'a>(
ed_model: &'a mut EdModel,
pub fn model_to_wgpu(
ed_model: &mut EdModel,
size: &PhysicalSize<u32>,
txt_coords: Vector2<f32>,
config: &Config,

View file

@ -16,13 +16,13 @@ use winit::dpi::PhysicalSize;
use crate::{editor::config::Config, graphics::colors};
pub fn build_code_graphics<'a>(
pub fn build_code_graphics(
markup_ids: &[MarkNodeId],
size: &PhysicalSize<u32>,
txt_coords: Vector2<f32>,
config: &Config,
glyph_dim_rect: Rect,
mark_node_pool: &'a SlowPool,
mark_node_pool: &SlowPool,
) -> EdResult<RenderedWgpu> {
let area_bounds = (size.width as f32, size.height as f32);
let layout = wgpu_glyph::Layout::default().h_align(wgpu_glyph::HorizontalAlign::Left);

View file

@ -196,12 +196,7 @@ pub mod test_caret_w_select {
}
}
Rule::text => {
let split_str = elt
.as_span()
.as_str()
.split('\n')
.into_iter()
.collect::<Vec<&str>>();
let split_str = elt.as_span().as_str().split('\n').collect::<Vec<&str>>();
if split_str.len() > 1 {
line_nr += split_str.len() - 1;

View file

@ -68,7 +68,7 @@ fn collect_roc_definitions<'a>(object: &object::File<'a, &'a [u8]>) -> MutMap<St
.next()
.unwrap();
let address = sym.address() as u64;
let address = sym.address();
// special exceptions for roc_ functions that map to libc symbols
let direct_mapping = match name {
@ -972,7 +972,7 @@ fn scan_elf_dynamic_deps(
dyn_lib_index += 1;
}
let dynamic_lib_count = dyn_lib_index as usize;
let dynamic_lib_count = dyn_lib_index;
if shared_lib_index.is_none() {
panic!("Shared lib not found as a dependency of the executable");
@ -1374,8 +1374,8 @@ fn surgery_elf_help(
};
if let Some(target_offset) = target_offset {
let virt_base = section_virtual_offset as usize + rel.0 as usize;
let base = section_offset as usize + rel.0 as usize;
let virt_base = section_virtual_offset + rel.0 as usize;
let base = section_offset + rel.0 as usize;
let target: i64 = match rel.1.kind() {
RelocationKind::Relative | RelocationKind::PltRelative => {
target_offset - virt_base as i64 + rel.1.addend()
@ -1449,14 +1449,14 @@ fn surgery_elf_help(
offset += new_section_count * sh_ent_size as usize;
let section_headers = load_structs_inplace_mut::<elf::SectionHeader64<LE>>(
exec_mmap,
new_sh_offset as usize,
new_sh_offset,
sh_num as usize + new_section_count,
);
let new_rodata_section_size = new_text_section_offset as u64 - new_rodata_section_offset as u64;
let new_rodata_section_virtual_size =
new_text_section_vaddr as u64 - new_rodata_section_vaddr as u64;
let new_text_section_vaddr = new_rodata_section_vaddr as u64 + new_rodata_section_size as u64;
let new_text_section_vaddr = new_rodata_section_vaddr as u64 + new_rodata_section_size;
let new_text_section_size = new_sh_offset as u64 - new_text_section_offset as u64;
// set the new rodata section header
@ -1610,7 +1610,7 @@ fn surgery_elf_help(
dynsym_offset as usize + *i as usize * mem::size_of::<elf::Sym64<LE>>(),
);
sym.st_shndx = endian::U16::new(LE, new_text_section_index as u16);
sym.st_value = endian::U64::new(LE, func_virt_offset as u64);
sym.st_value = endian::U64::new(LE, func_virt_offset);
sym.st_size = endian::U64::new(
LE,
match app_func_size_map.get(func_name) {
@ -1627,7 +1627,7 @@ fn surgery_elf_help(
symtab_offset as usize + *i as usize * mem::size_of::<elf::Sym64<LE>>(),
);
sym.st_shndx = endian::U16::new(LE, new_text_section_index as u16);
sym.st_value = endian::U64::new(LE, func_virt_offset as u64);
sym.st_value = endian::U64::new(LE, func_virt_offset);
sym.st_size = endian::U64::new(
LE,
match app_func_size_map.get(func_name) {
@ -1812,7 +1812,7 @@ mod tests {
false,
);
std::fs::copy(&preprocessed_host_filename, &dir.join("final")).unwrap();
std::fs::copy(&preprocessed_host_filename, dir.join("final")).unwrap();
surgery_elf(
&roc_app,
@ -1833,7 +1833,7 @@ mod tests {
zig_host_app_help(dir, &Triple::from_str("x86_64-unknown-linux-musl").unwrap());
let output = std::process::Command::new(&dir.join("final"))
let output = std::process::Command::new(dir.join("final"))
.current_dir(dir)
.output()
.unwrap();

View file

@ -255,7 +255,7 @@ fn generate_dynamic_lib(target: &Triple, stub_dll_symbols: &[String], stub_lib_p
let bytes = crate::generate_dylib::generate(target, stub_dll_symbols)
.unwrap_or_else(|e| internal_error!("{e}"));
if let Err(e) = std::fs::write(stub_lib_path, &bytes) {
if let Err(e) = std::fs::write(stub_lib_path, bytes) {
internal_error!("failed to write stub lib to {:?}: {e}", stub_lib_path)
}
@ -290,7 +290,7 @@ fn generate_import_library(stub_lib_path: &Path, custom_names: &[String]) {
// For when we want to do this in-memory in the future. We can also consider using
//
// > https://github.com/messense/implib-rs
let output = std::process::Command::new(&zig)
let output = std::process::Command::new(zig)
.current_dir(stub_lib_path.parent().unwrap())
.args([
"dlltool",

View file

@ -67,7 +67,7 @@ fn collect_roc_definitions<'a>(object: &object::File<'a, &'a [u8]>) -> MutMap<St
.next()
.unwrap();
let address = sym.address() as u64;
let address = sym.address();
// special exceptions for memcpy and memset.
if name == "roc_memcpy" {
@ -705,19 +705,19 @@ fn gen_macho_le(
// Instead, its file size should be increased.
if old_file_offest > 0 {
cmd.fileoff
.set(LittleEndian, old_file_offest + md.added_byte_count as u64);
.set(LittleEndian, old_file_offest + md.added_byte_count);
cmd.vmaddr.set(
LittleEndian,
cmd.vmaddr.get(NativeEndian) + md.added_byte_count as u64,
cmd.vmaddr.get(NativeEndian) + md.added_byte_count,
);
} else {
cmd.filesize.set(
LittleEndian,
cmd.filesize.get(NativeEndian) + md.added_byte_count as u64,
cmd.filesize.get(NativeEndian) + md.added_byte_count,
);
cmd.vmsize.set(
LittleEndian,
cmd.vmsize.get(NativeEndian) + md.added_byte_count as u64,
cmd.vmsize.get(NativeEndian) + md.added_byte_count,
);
}
@ -831,7 +831,7 @@ fn gen_macho_le(
if entry_type == macho::N_ABS || entry_type == macho::N_SECT {
entry.n_value.set(
LittleEndian,
entry.n_value.get(NativeEndian) + md.added_byte_count as u64,
entry.n_value.get(NativeEndian) + md.added_byte_count,
);
}
}
@ -1046,7 +1046,7 @@ fn gen_macho_le(
cmd.entryoff.set(
LittleEndian,
cmd.entryoff.get(NativeEndian) + md.added_byte_count as u64,
cmd.entryoff.get(NativeEndian) + md.added_byte_count,
);
}
macho::LC_NOTE => {
@ -1058,7 +1058,7 @@ fn gen_macho_le(
if cmd.size.get(NativeEndian) > 0 {
cmd.offset.set(
LittleEndian,
cmd.offset.get(NativeEndian) + md.added_byte_count as u64,
cmd.offset.get(NativeEndian) + md.added_byte_count,
);
}
}
@ -1397,8 +1397,8 @@ fn surgery_macho_help(
};
if let Some(target_offset) = target_offset {
let virt_base = section_virtual_offset as usize + rel.0 as usize;
let base = section_offset as usize + rel.0 as usize;
let virt_base = section_virtual_offset + rel.0 as usize;
let base = section_offset + rel.0 as usize;
let target: i64 = match rel.1.kind() {
RelocationKind::Relative | RelocationKind::PltRelative => {
target_offset - virt_base as i64 + rel.1.addend()

View file

@ -305,10 +305,7 @@ pub(crate) fn surgery_pe(executable_path: &Path, metadata_path: &Path, roc_app_b
let executable = &mut open_mmap_mut(executable_path, md.dynhost_file_size + app_sections_size);
let app_code_section_va = md.last_host_section_address
+ next_multiple_of(
md.last_host_section_size as usize,
section_alignment as usize,
) as u64;
+ next_multiple_of(md.last_host_section_size as usize, section_alignment) as u64;
let mut section_file_offset = md.dynhost_file_size;
let mut section_virtual_address = (app_code_section_va - image_base) as u32;
@ -470,9 +467,9 @@ pub(crate) fn surgery_pe(executable_path: &Path, metadata_path: &Path, roc_app_b
update_optional_header(
executable,
md.optional_header_offset,
code_bytes_added as u32,
file_bytes_added as u32,
data_bytes_added as u32,
code_bytes_added,
file_bytes_added,
data_bytes_added,
);
let symbols: Vec<_> = symbols
@ -707,7 +704,7 @@ impl Preprocessor {
Self {
extra_sections_start: section_table_offset as usize
+ sections.len() as usize * Self::SECTION_HEADER_WIDTH,
+ sections.len() * Self::SECTION_HEADER_WIDTH,
extra_sections_width,
additional_header_space,
additional_reloc_space,
@ -1724,7 +1721,7 @@ mod test {
)
.unwrap();
std::fs::copy(&preprocessed_host_filename, &dir.join("app.exe")).unwrap();
std::fs::copy(&preprocessed_host_filename, dir.join("app.exe")).unwrap();
surgery_pe(&dir.join("app.exe"), &dir.join("metadata"), &roc_app);
}
@ -1739,7 +1736,7 @@ mod test {
runner(dir);
let output = std::process::Command::new(&dir.join("app.exe"))
let output = std::process::Command::new(dir.join("app.exe"))
.current_dir(dir)
.output()
.unwrap();
@ -1908,7 +1905,7 @@ mod test {
std::fs::write(dir.join("host.zig"), host_zig.as_bytes()).unwrap();
let mut command = std::process::Command::new(&zig);
let mut command = std::process::Command::new(zig);
command.current_dir(dir).args([
"build-exe",
"host.zig",

View file

@ -596,7 +596,7 @@ fn format_output(
let term_width = match dimensions {
Some((width, _)) => width.min(VAR_NAME_COLUMN_MAX),
None => VAR_NAME_COLUMN_MAX as usize,
None => VAR_NAME_COLUMN_MAX,
};
let expr_with_type = format!("{expr}{EXPR_TYPE_SEPARATOR}{expr_type}");

View file

@ -265,8 +265,8 @@ fn get_tags_vars_and_variant<'a>(
(vars_of_tag, union_variant)
}
fn expr_of_tag<'a, 'env, M: ReplAppMemory>(
env: &mut Env<'a, 'env>,
fn expr_of_tag<'a, M: ReplAppMemory>(
env: &mut Env<'a, '_>,
mem: &'a M,
data_addr: usize,
tag_name: &TagName,
@ -289,8 +289,8 @@ fn expr_of_tag<'a, 'env, M: ReplAppMemory>(
/// Gets the tag ID of a union variant, assuming that the tag ID is stored alongside (after) the
/// tag data. The caller is expected to check that the tag ID is indeed stored this way.
fn tag_id_from_data<'a, 'env, M: ReplAppMemory>(
env: &Env<'a, 'env>,
fn tag_id_from_data<'a, M: ReplAppMemory>(
env: &Env<'a, '_>,
mem: &M,
union_layout: UnionLayout<'a>,
data_addr: usize,
@ -947,8 +947,8 @@ fn list_to_ast<'a, M: ReplAppMemory>(
Expr::List(Collection::with_items(output))
}
fn single_tag_union_to_ast<'a, 'env, M: ReplAppMemory>(
env: &mut Env<'a, 'env>,
fn single_tag_union_to_ast<'a, M: ReplAppMemory>(
env: &mut Env<'a, '_>,
mem: &'a M,
addr: usize,
field_layouts: &'a [InLayout<'a>],
@ -1004,8 +1004,8 @@ where
output
}
fn struct_to_ast<'a, 'env, M: ReplAppMemory>(
env: &mut Env<'a, 'env>,
fn struct_to_ast<'a, M: ReplAppMemory>(
env: &mut Env<'a, '_>,
mem: &'a M,
addr: usize,
record_fields: RecordFields,
@ -1130,8 +1130,8 @@ fn struct_to_ast<'a, 'env, M: ReplAppMemory>(
}
}
fn struct_to_ast_tuple<'a, 'env, M: ReplAppMemory>(
env: &mut Env<'a, 'env>,
fn struct_to_ast_tuple<'a, M: ReplAppMemory>(
env: &mut Env<'a, '_>,
mem: &'a M,
addr: usize,
tuple_elems: TupleElems,

View file

@ -15,7 +15,7 @@ macro_rules! bytes_id {
$owned_vis struct $owned($owned_vis ::smallvec::SmallVec<[u8; 23]>);
impl $owned {
fn borrowed<'a>(&'a self) -> $borrowed<'a> {
fn borrowed(&self) -> $borrowed<'_> {
$borrowed(&self.0)
}
}