Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
rtfeldman committed Oct 15, 2023
1 parent 73f3250 commit f2782e9
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions crates/compiler/load_internal/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,12 +968,7 @@ pub enum LoadingProblem<'a> {

#[derive(Debug)]
pub enum ChannelProblem {
FailedToEnqueueTask {
can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
type_problems: MutMap<ModuleId, Vec<TypeError>>,
sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
interns: Interns,
},
FailedToEnqueueTask(Box<PanicReportInfo>),
FailedToSendRootMsg,
FailedToSendWorkerShutdownMsg,
ChannelDisconnected,
Expand All @@ -983,6 +978,14 @@ pub enum ChannelProblem {
FailedToSendFinishedTypeCheckingMsg,
}

#[derive(Debug)]
pub struct PanicReportInfo {
can_problems: MutMap<ModuleId, Vec<roc_problem::can::Problem>>,
type_problems: MutMap<ModuleId, Vec<TypeError>>,
sources: MutMap<ModuleId, (PathBuf, Box<str>)>,
interns: Interns,
}

pub enum Phases {
/// Parse, canonicalize, check types
TypeCheck,
Expand All @@ -1003,29 +1006,28 @@ fn enqueue_task<'a>(

for listener in listeners {
listener.send(WorkerMsg::TaskAdded).map_err(|_| {
let module_ids = { (&*state.arc_modules).lock().clone() }.into_module_ids();
let module_ids = { (*state.arc_modules).lock().clone() }.into_module_ids();

let interns = Interns {
module_ids,
all_ident_ids: state.constrained_ident_ids.clone(),
};

LoadingProblem::ChannelProblem(ChannelProblem::FailedToEnqueueTask {
can_problems: state.module_cache.can_problems.clone(),
type_problems: state.module_cache.type_problems.clone(),
interns,
sources: state
.module_cache
.sources
.iter()
.map(|(key, (path, str_ref))| {
(
key.clone(),
(path.clone(), str_ref.to_string().into_boxed_str()),
)
})
.collect(),
})
LoadingProblem::ChannelProblem(ChannelProblem::FailedToEnqueueTask(Box::new(
PanicReportInfo {
can_problems: state.module_cache.can_problems.clone(),
type_problems: state.module_cache.type_problems.clone(),
interns,
sources: state
.module_cache
.sources
.iter()
.map(|(key, (path, str_ref))| {
(*key, (path.clone(), str_ref.to_string().into_boxed_str()))
})
.collect(),
},
)))
})?;
}

Expand Down Expand Up @@ -1841,12 +1843,16 @@ fn load_multi_threaded<'a>(
state = new_state;
continue;
}
Err(LoadingProblem::ChannelProblem(ChannelProblem::FailedToEnqueueTask {
can_problems,
type_problems,
sources,
interns,
})) => {
Err(LoadingProblem::ChannelProblem(ChannelProblem::FailedToEnqueueTask(
info,
))) => {
let PanicReportInfo {
can_problems,
type_problems,
sources,
interns,
} = *info;

// Record these for later.
can_problems_recorded = can_problems;
type_problems_recorded = type_problems;
Expand All @@ -1856,15 +1862,15 @@ fn load_multi_threaded<'a>(
shut_down_worker_threads!();

return Err(LoadingProblem::ChannelProblem(
ChannelProblem::FailedToEnqueueTask {
ChannelProblem::FailedToEnqueueTask(Box::new(PanicReportInfo {
// This return value never gets used, so don't bother
// cloning these in order to be able to return them.
// Really, anything could go here.
can_problems: Default::default(),
type_problems: Default::default(),
sources: Default::default(),
interns: Default::default(),
},
})),
));
}
Err(e) => {
Expand Down Expand Up @@ -2078,7 +2084,7 @@ fn start_tasks<'a>(
let tasks = start_phase(module_id, phase, arena, state);

for task in tasks {
enqueue_task(injector, worker_listeners, task, &state)?
enqueue_task(injector, worker_listeners, task, state)?
}
}

Expand Down

0 comments on commit f2782e9

Please sign in to comment.