From dd2dcc63d1e5a5cedd88f706f0aa1c6fc00a79e4 Mon Sep 17 00:00:00 2001 From: Chadtech Date: Mon, 18 Jan 2021 21:25:10 -0500 Subject: [PATCH] Pass in builtin look up function parameter --- compiler/can/src/module.rs | 10 +++++++--- compiler/load/src/file.rs | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/can/src/module.rs b/compiler/can/src/module.rs index 3c59d13f7b..b8a00ed780 100644 --- a/compiler/can/src/module.rs +++ b/compiler/can/src/module.rs @@ -41,7 +41,7 @@ pub struct ModuleOutput { // TODO trim these down #[allow(clippy::too_many_arguments)] -pub fn canonicalize_module_defs<'a>( +pub fn canonicalize_module_defs<'a, F>( arena: &Bump, loc_defs: &'a [Located>], home: ModuleId, @@ -52,7 +52,11 @@ pub fn canonicalize_module_defs<'a>( exposed_imports: MutMap, exposed_symbols: &MutSet, var_store: &mut VarStore, -) -> Result { + look_up_builtin: F, +) -> Result +where + F: Fn(Symbol, &mut VarStore) -> Option, +{ let mut can_exposed_imports = MutMap::default(); let mut scope = Scope::new(home, var_store); let num_deps = dep_idents.len(); @@ -284,7 +288,7 @@ pub fn canonicalize_module_defs<'a>( for symbol in references.iter() { if symbol.is_builtin() { // this can fail when the symbol is for builtin types, or has no implementation yet - if let Some(def) = builtins::builtin_defs_map(*symbol, var_store) { + if let Some(def) = look_up_builtin(*symbol, var_store) { declarations.push(Declaration::Builtin(def)); } } diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index a114ade91b..ba3c1f5ad3 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -5,6 +5,7 @@ use crossbeam::deque::{Injector, Stealer, Worker}; use crossbeam::thread; use parking_lot::Mutex; use roc_builtins::std::{Mode, StdLib}; +use roc_can::builtins::builtin_defs_map; use roc_can::constraint::Constraint; use roc_can::def::Declaration; use roc_can::module::{canonicalize_module_defs, Module}; @@ -3202,6 +3203,7 @@ fn canonicalize_and_constrain<'a>( exposed_imports, &exposed_symbols, &mut var_store, + builtin_defs_map, ); let canonicalize_end = SystemTime::now();