mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
clippy + fmt
This commit is contained in:
parent
fb7fa99b2c
commit
05a61e2210
11 changed files with 55 additions and 65 deletions
|
@ -22,7 +22,6 @@ use std::ffi::OsStr;
|
|||
use std::ops::Deref;
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
thread::JoinHandle,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
|
@ -915,11 +914,6 @@ fn build_loaded_file<'a>(
|
|||
let problems = report_problems_monomorphized(&mut loaded);
|
||||
let loaded = loaded;
|
||||
|
||||
enum HostRebuildTiming {
|
||||
BeforeApp(u128),
|
||||
ConcurrentWithApp(JoinHandle<u128>),
|
||||
}
|
||||
|
||||
let opt_rebuild_timing = if let Some(rebuild_thread) = rebuild_thread {
|
||||
if linking_strategy == LinkingStrategy::Additive {
|
||||
let rebuild_duration = rebuild_thread
|
||||
|
@ -930,9 +924,9 @@ fn build_loaded_file<'a>(
|
|||
println!("Finished rebuilding the platform in {rebuild_duration} ms\n");
|
||||
}
|
||||
|
||||
Some(HostRebuildTiming::BeforeApp(rebuild_duration))
|
||||
None
|
||||
} else {
|
||||
Some(HostRebuildTiming::ConcurrentWithApp(rebuild_thread))
|
||||
Some(rebuild_thread)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
@ -977,7 +971,7 @@ fn build_loaded_file<'a>(
|
|||
);
|
||||
}
|
||||
|
||||
if let Some(HostRebuildTiming::ConcurrentWithApp(thread)) = opt_rebuild_timing {
|
||||
if let Some(thread) = opt_rebuild_timing {
|
||||
let rebuild_duration = thread.join().expect("Failed to (re)build platform.");
|
||||
|
||||
if emit_timings && !is_platform_prebuilt {
|
||||
|
|
|
@ -150,11 +150,7 @@ impl ExpectsOrDbgs {
|
|||
#[derive(Debug, Clone)]
|
||||
enum PendingValueDef<'a> {
|
||||
/// A standalone annotation with no body
|
||||
AnnotationOnly(
|
||||
&'a Loc<ast::Pattern<'a>>,
|
||||
Loc<Pattern>,
|
||||
&'a Loc<ast::TypeAnnotation<'a>>,
|
||||
),
|
||||
AnnotationOnly(Loc<Pattern>, &'a Loc<ast::TypeAnnotation<'a>>),
|
||||
/// A body with no type annotation
|
||||
Body(Loc<Pattern>, &'a Loc<ast::Expr<'a>>),
|
||||
/// A body with a type annotation
|
||||
|
@ -175,7 +171,7 @@ enum PendingValueDef<'a> {
|
|||
impl PendingValueDef<'_> {
|
||||
fn loc_pattern(&self) -> &Loc<Pattern> {
|
||||
match self {
|
||||
PendingValueDef::AnnotationOnly(_, loc_pattern, _) => loc_pattern,
|
||||
PendingValueDef::AnnotationOnly(loc_pattern, _) => loc_pattern,
|
||||
PendingValueDef::Body(loc_pattern, _) => loc_pattern,
|
||||
PendingValueDef::TypedBody(_, loc_pattern, _, _) => loc_pattern,
|
||||
PendingValueDef::IngestedFile(loc_pattern, _, _) => loc_pattern,
|
||||
|
@ -2208,7 +2204,7 @@ fn canonicalize_pending_value_def<'a>(
|
|||
let pending_abilities_in_scope = &Default::default();
|
||||
|
||||
let output = match pending_def {
|
||||
AnnotationOnly(_, loc_can_pattern, loc_ann) => {
|
||||
AnnotationOnly(loc_can_pattern, loc_ann) => {
|
||||
// Make types for the body expr, even if we won't end up having a body.
|
||||
let expr_var = var_store.fresh();
|
||||
let mut vars_by_symbol = SendMap::default();
|
||||
|
@ -2950,7 +2946,6 @@ fn to_pending_value_def<'a>(
|
|||
);
|
||||
|
||||
PendingValue::Def(PendingValueDef::AnnotationOnly(
|
||||
loc_pattern,
|
||||
loc_can_pattern,
|
||||
loc_ann,
|
||||
))
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::cell::Cell;
|
|||
|
||||
thread_local! {
|
||||
// we use a thread_local here so that tests consistently give the same pattern
|
||||
static SUFFIXED_ANSWER_COUNTER: Cell<usize> = Cell::new(0);
|
||||
static SUFFIXED_ANSWER_COUNTER: Cell<usize> = const { Cell::new(0) };
|
||||
}
|
||||
|
||||
/// Provide an intermediate answer expression and pattern when unwrapping a
|
||||
|
|
|
@ -131,6 +131,8 @@ enum PatternBindingIter<'r, 'a> {
|
|||
|
||||
enum PatternBindingWork<'r, 'a> {
|
||||
Pat(&'r Pattern<'a>),
|
||||
#[allow(dead_code)]
|
||||
// Field will be used once todo is immplemented in next in impl<'r, 'a> Iterator for PatternBindingIter
|
||||
RecordDestruct(&'r DestructType<'a>),
|
||||
}
|
||||
|
||||
|
|
|
@ -960,13 +960,13 @@ fn write_integer<'a>(
|
|||
}
|
||||
}
|
||||
|
||||
enum ExtContent<'a> {
|
||||
enum ExtContent {
|
||||
Empty,
|
||||
Content(Variable, &'a Content),
|
||||
Content(Variable),
|
||||
}
|
||||
|
||||
impl<'a> ExtContent<'a> {
|
||||
fn for_tag(subs: &'a Subs, ext: Variable, pol: Polarity, debug_flags: &DebugPrint) -> Self {
|
||||
impl ExtContent {
|
||||
fn for_tag(subs: &Subs, ext: Variable, pol: Polarity, debug_flags: &DebugPrint) -> Self {
|
||||
let content = subs.get_content_without_compacting(ext);
|
||||
match content {
|
||||
Content::Structure(FlatType::EmptyTagUnion) => ExtContent::Empty,
|
||||
|
@ -983,7 +983,7 @@ impl<'a> ExtContent<'a> {
|
|||
Content::FlexVar(_)
|
||||
| Content::FlexAbleVar(..)
|
||||
| Content::RigidVar(_)
|
||||
| Content::RigidAbleVar(..) => ExtContent::Content(ext, content),
|
||||
| Content::RigidAbleVar(..) => ExtContent::Content(ext),
|
||||
|
||||
other => unreachable!("something weird ended up in an ext var: {:?}", other),
|
||||
}
|
||||
|
@ -995,11 +995,11 @@ fn write_ext_content<'a>(
|
|||
ctx: &mut Context<'a>,
|
||||
subs: &'a Subs,
|
||||
buf: &mut String,
|
||||
ext_content: ExtContent<'a>,
|
||||
ext_content: ExtContent,
|
||||
parens: Parens,
|
||||
pol: Polarity,
|
||||
) {
|
||||
if let ExtContent::Content(var, _) = ext_content {
|
||||
if let ExtContent::Content(var) = ext_content {
|
||||
// This is an open record or tag union, so print the variable
|
||||
// right after the '}' or ']'
|
||||
//
|
||||
|
@ -1050,7 +1050,7 @@ fn write_sorted_tags<'a>(
|
|||
tags: &MutMap<TagName, Vec<Variable>>,
|
||||
ext_var: Variable,
|
||||
pol: Polarity,
|
||||
) -> ExtContent<'a> {
|
||||
) -> ExtContent {
|
||||
// Sort the fields so they always end up in the same order.
|
||||
let mut sorted_fields = Vec::with_capacity(tags.len());
|
||||
|
||||
|
|
|
@ -2533,7 +2533,7 @@ enum Rec {
|
|||
None,
|
||||
Left(Variable),
|
||||
Right(Variable),
|
||||
Both(Variable, Variable),
|
||||
Both(Variable),
|
||||
}
|
||||
|
||||
/// Checks if an extension type `ext1` should be permitted to grow by the `candidate_type`, if it
|
||||
|
@ -2995,8 +2995,8 @@ fn find_union_rec(subs: &Subs, ctx: &Context) -> Rec {
|
|||
subs.get_content_without_compacting(ctx.second),
|
||||
) {
|
||||
(Structure(s1), Structure(s2)) => match (s1, s2) {
|
||||
(FlatType::RecursiveTagUnion(l, _, _), FlatType::RecursiveTagUnion(r, _, _)) => {
|
||||
Rec::Both(*l, *r)
|
||||
(FlatType::RecursiveTagUnion(l, _, _), FlatType::RecursiveTagUnion(_r, _, _)) => {
|
||||
Rec::Both(*l)
|
||||
}
|
||||
(FlatType::RecursiveTagUnion(l, _, _), _) => Rec::Left(*l),
|
||||
(_, FlatType::RecursiveTagUnion(r, _, _)) => Rec::Right(*r),
|
||||
|
@ -3160,7 +3160,7 @@ fn unify_shared_tags_merge<M: MetaCollector>(
|
|||
|
||||
let flat_type = match recursion_var {
|
||||
Rec::None => FlatType::TagUnion(new_tags, new_ext),
|
||||
Rec::Left(rec) | Rec::Right(rec) | Rec::Both(rec, _) => {
|
||||
Rec::Left(rec) | Rec::Right(rec) | Rec::Both(rec) => {
|
||||
debug_assert!(is_recursion_var(env, rec), "{:?}", env.dbg(rec));
|
||||
FlatType::RecursiveTagUnion(rec, new_tags, new_ext)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue