remove unused function

This commit is contained in:
Folkert 2020-10-30 01:53:11 +01:00
parent cba841601b
commit dd4609fe79

View file

@ -2218,109 +2218,6 @@ fn parse<'a>(arena: &'a Bump, header: ModuleHeader<'a>) -> Result<Msg<'a>, Loadi
Ok(Msg::Parsed(parsed)) Ok(Msg::Parsed(parsed))
} }
/// Parse the module, canonicalize it, and generate constraints for it.
fn parse_and_constrain<'a>(
header: ModuleHeader<'a>,
mode: Mode,
module_ids: &ModuleIds,
dep_idents: IdentIdsByModule,
exposed_symbols: MutSet<Symbol>,
) -> Result<Msg<'a>, LoadingProblem> {
let mut module_timing = header.module_timing;
let parse_start = SystemTime::now();
let arena = Bump::new();
let parse_state = parser::State::new(&header.src, Attempting::Module);
let (parsed_defs, _) = module_defs()
.parse(&arena, parse_state)
.expect("TODO gracefully handle parse error on module defs. IMPORTANT: Bail out entirely if there are any BadUtf8 problems! That means the whole source file is not valid UTF-8 and any other errors we report may get mis-reported. We rely on this for safety in an `unsafe` block later on in this function.");
// Record the parse end time once, to avoid checking the time a second time
// immediately afterward (for the beginning of canonicalization).
let parse_end = SystemTime::now();
let module_id = header.module_id;
// Generate documentation information
// TODO: store timing information
// TODO: only run this if we're doing a doc gen pass!
let module_docs = crate::docs::generate_module_docs(
header.module_name,
&header.exposed_ident_ids,
&parsed_defs,
);
let parsed_defs = parsed_defs.into_bump_slice();
let mut var_store = VarStore::default();
let canonicalized = canonicalize_module_defs(
&arena,
&parsed_defs,
module_id,
module_ids,
header.exposed_ident_ids,
dep_idents,
header.exposed_imports,
exposed_symbols,
&mut var_store,
);
let canonicalize_end = SystemTime::now();
let (module, declarations, ident_ids, constraint, problems) = match canonicalized {
Ok(module_output) => {
let constraint = constrain_module(&module_output, module_id, mode, &mut var_store);
// Now that we're done with parsing, canonicalization, and constraint gen,
// add the timings for those to module_timing
module_timing.constrain = canonicalize_end.elapsed().unwrap();
module_timing.parse_body = parse_end.duration_since(parse_start).unwrap();
module_timing.canonicalize = canonicalize_end.duration_since(parse_start).unwrap();
let module = Module {
module_id,
exposed_imports: module_output.exposed_imports,
exposed_vars_by_symbol: module_output.exposed_vars_by_symbol,
references: module_output.references,
aliases: module_output.aliases,
rigid_variables: module_output.rigid_variables,
};
(
module,
module_output.declarations,
module_output.ident_ids,
constraint,
module_output.problems,
)
}
Err(runtime_error) => {
panic!(
"TODO gracefully handle module canonicalization error {:?}",
runtime_error
);
}
};
let imported_modules = header.imported_modules;
// SAFETY: By this point we've already incrementally verified that there
// are no UTF-8 errors in these bytes. If there had been any UTF-8 errors,
// we'd have bailed out before now.
let src = unsafe { from_utf8_unchecked(header.src) };
// // Send the constraint to the main thread for processing.
// Ok(Msg::Constrained {
// module,
// src,
// declarations,
// imported_modules,
// ident_ids,
// constraint,
// problems,
// var_store,
// module_timing,
// module_docs,
// })
unreachable!()
}
fn exposed_from_import(entry: &ImportsEntry<'_>) -> (ModuleName, Vec<Ident>) { fn exposed_from_import(entry: &ImportsEntry<'_>) -> (ModuleName, Vec<Ident>) {
use roc_parse::ast::ImportsEntry::*; use roc_parse::ast::ImportsEntry::*;