This commit is contained in:
Folkert 2021-05-07 11:00:15 +02:00
parent 9a5c20b7c3
commit fecb83b9c2
15 changed files with 45 additions and 41 deletions

View file

@ -211,7 +211,7 @@ pub fn build_file<'a>(
Ok(BuiltFile {
binary_path,
total_time,
outcome,
total_time,
})
}

View file

@ -48,8 +48,8 @@ pub unsafe fn jit_to_ast<'a>(
arena,
subs,
ptr_bytes,
home,
interns,
home,
};
jit_to_ast_help(&env, lib, main_fn_name, layout, content)

View file

@ -283,8 +283,8 @@ pub fn gen_from_mono_module(
let emit_o_file = emit_o_file_start.elapsed().unwrap();
CodeGenTiming {
emit_o_file,
code_gen,
emit_o_file,
}
}

View file

@ -58,7 +58,7 @@ fn new_op_call_expr<'a>(
}
};
Located { value, region }
Located { region, value }
}
fn desugar_def_helps<'a>(
@ -283,11 +283,10 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
let mut alternatives = Vec::with_capacity_in(branch.patterns.len(), arena);
alternatives.extend(branch.patterns.iter().copied());
let desugared_guard = if let Some(guard) = &branch.guard {
Some(*desugar_expr(arena, guard))
} else {
None
};
let desugared_guard = branch
.guard
.as_ref()
.map(|guard| *desugar_expr(arena, guard));
let alternatives = alternatives.into_bump_slice();

View file

@ -87,7 +87,7 @@ mod test_can {
IntErrorKind::Overflow,
Base::Decimal,
Region::zero(),
string.into(),
string.into_boxed_str(),
)),
);
}

View file

@ -1947,11 +1947,11 @@ fn update<'a>(
let typechecked = TypeCheckedModule {
module_id,
decls,
solved_subs,
ident_ids,
module_timing,
layout_cache,
module_timing,
solved_subs,
decls,
ident_ids,
};
state
@ -2000,10 +2000,10 @@ fn update<'a>(
.extend(procs.module_thunks.iter().copied());
let found_specializations_module = FoundSpecializationsModule {
layout_cache,
module_id,
procs,
ident_ids,
layout_cache,
procs,
subs,
module_timing,
};
@ -3715,13 +3715,13 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result<Msg<'a>, Loadi
module_id,
module_name,
module_path,
src,
module_timing,
deps_by_name,
imported_modules,
exposed_ident_ids,
exposed_imports,
src,
parsed_defs,
imported_modules,
module_timing,
};
Ok(Msg::Parsed(parsed))

View file

@ -1,3 +1,5 @@
#![allow(clippy::manual_map)]
use self::InProgressProc::*;
use crate::exhaustive::{Ctor, Guard, RenderAs, TagId};
use crate::layout::{

View file

@ -231,10 +231,8 @@ fn insert_jumps<'a>(
None
}
}
Refcounting(modify, cont) => match insert_jumps(arena, cont, goal_id, needle) {
Some(cont) => Some(arena.alloc(Refcounting(*modify, cont))),
None => None,
},
Refcounting(modify, cont) => insert_jumps(arena, cont, goal_id, needle)
.map(|cont| &*arena.alloc(Refcounting(*modify, cont))),
Rethrow => None,
Ret(_) => None,

View file

@ -1098,10 +1098,10 @@ macro_rules! loc {
let end_col = state.column;
let end_line = state.line;
let region = Region {
start_col,
start_line,
end_col,
end_line,
start_col,
end_col,
};
Ok((progress, Located { region, value }, state))

View file

@ -92,7 +92,7 @@ fn term<'a>(min_indent: u16) -> impl Parser<'a, Located<TypeAnnotation<'a>>, Typ
let value =
TypeAnnotation::As(arena.alloc(loc_ann), spaces, arena.alloc(loc_as));
Located { value, region }
Located { region, value }
}
None => loc_ann,

View file

@ -24,8 +24,8 @@ impl Region {
pub const fn new(start_line: u32, end_line: u32, start_col: u16, end_col: u16) -> Self {
Self {
start_line,
start_col,
end_line,
start_col,
end_col,
}
}
@ -106,10 +106,10 @@ impl Region {
end_col: u16,
) -> Self {
Region {
start_col,
start_line,
end_col,
end_line,
start_col,
end_col,
}
}
@ -177,20 +177,20 @@ impl<T> Located<T> {
) -> Located<T> {
let region = Region {
start_line,
start_col,
end_line,
start_col,
end_col,
};
Located { value, region }
Located { region, value }
}
pub fn at(region: Region, value: T) -> Located<T> {
Located { value, region }
Located { region, value }
}
pub fn at_zero(value: T) -> Located<T> {
let region = Region::zero();
Located { value, region }
Located { region, value }
}
}

View file

@ -149,8 +149,8 @@ pub fn can_problem<'b>(
let (doc, title) = crate::error::r#type::cyclic_alias(alloc, symbol, region, others);
return Report {
filename,
title,
filename,
doc,
};
}

View file

@ -40,8 +40,8 @@ pub fn type_problem<'b>(
.append(alloc.reflow("."));
Report {
filename,
title,
filename,
doc,
}
}
@ -85,8 +85,8 @@ pub fn type_problem<'b>(
};
Report {
filename,
title,
filename,
doc,
}
}
@ -94,8 +94,8 @@ pub fn type_problem<'b>(
let (doc, title) = cyclic_alias(alloc, symbol, region, others);
Report {
filename,
title,
filename,
doc,
}
}

View file

@ -226,10 +226,10 @@ impl ShallowClone for ValueDef {
fn shallow_clone(&self) -> Self {
Self {
pattern: self.pattern,
expr_type: match &self.expr_type {
Some((id, rigids)) => Some((*id, rigids.shallow_clone())),
None => None,
},
expr_type: self
.expr_type
.as_ref()
.map(|(id, rigids)| (*id, rigids.shallow_clone())),
expr_var: self.expr_var,
}
}

View file

@ -263,11 +263,16 @@ impl PoolStr {
}
}
#[allow(clippy::len_without_is_empty)]
pub fn len(&self, pool: &Pool) -> usize {
let contents = self.as_str(pool);
contents.len()
}
pub fn is_empty(&self, pool: &Pool) -> bool {
self.len(pool) == 0
}
}
impl ShallowClone for PoolStr {