Merge pull request #2765 from rtfeldman/simplify-stdlib-use

Simplify stdlib use
This commit is contained in:
Richard Feldman 2022-03-22 20:14:38 -04:00 committed by GitHub
commit 381acbf734
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 14 additions and 93 deletions

View file

@ -1016,10 +1016,6 @@ pub fn canonicalize_expr<'a>(
}
};
if cfg!(debug_assertions) {
env.home.register_debug_idents(&env.ident_ids);
}
// At the end, diff used_idents and defined_idents to see which were unused.
// Add warnings for those!

View file

@ -4,7 +4,7 @@ use crossbeam::channel::{bounded, Sender};
use crossbeam::deque::{Injector, Stealer, Worker};
use crossbeam::thread;
use parking_lot::Mutex;
use roc_builtins::std::{borrow_stdlib, StdLib};
use roc_builtins::std::borrow_stdlib;
use roc_can::constraint::{Constraint as ConstraintSoa, Constraints};
use roc_can::def::Declaration;
use roc_can::module::{canonicalize_module_defs, Module};
@ -811,7 +811,6 @@ fn enqueue_task<'a>(
pub fn load_and_typecheck<'a>(
arena: &'a Bump,
filename: PathBuf,
stdlib: &'a StdLib,
src_dir: &Path,
exposed_types: ExposedByModule,
target_info: TargetInfo,
@ -823,7 +822,6 @@ pub fn load_and_typecheck<'a>(
match load(
arena,
load_start,
stdlib,
src_dir,
exposed_types,
Phase::SolveTypes,
@ -838,7 +836,6 @@ pub fn load_and_typecheck<'a>(
pub fn load_and_monomorphize<'a>(
arena: &'a Bump,
filename: PathBuf,
stdlib: &'a StdLib,
src_dir: &Path,
exposed_types: ExposedByModule,
target_info: TargetInfo,
@ -850,7 +847,6 @@ pub fn load_and_monomorphize<'a>(
match load(
arena,
load_start,
stdlib,
src_dir,
exposed_types,
Phase::MakeSpecializations,
@ -866,7 +862,6 @@ pub fn load_and_monomorphize_from_str<'a>(
arena: &'a Bump,
filename: PathBuf,
src: &'a str,
stdlib: &'a StdLib,
src_dir: &Path,
exposed_types: ExposedByModule,
target_info: TargetInfo,
@ -878,7 +873,6 @@ pub fn load_and_monomorphize_from_str<'a>(
match load(
arena,
load_start,
stdlib,
src_dir,
exposed_types,
Phase::MakeSpecializations,
@ -1032,7 +1026,6 @@ enum LoadResult<'a> {
fn load<'a>(
arena: &'a Bump,
load_start: LoadStart<'a>,
_stdlib: &'a StdLib,
src_dir: &Path,
exposed_types: ExposedByModule,
goal_phase: Phase,

View file

@ -107,8 +107,6 @@ mod test_load {
use std::io::Write;
use tempfile::tempdir;
let stdlib = roc_builtins::std::standard_stdlib();
let mut file_handles: Vec<_> = Vec::new();
// create a temporary directory
@ -142,7 +140,6 @@ mod test_load {
roc_load::file::load_and_typecheck(
arena,
full_file_path,
arena.alloc(stdlib),
dir.path(),
Default::default(),
TARGET_INFO,
@ -165,7 +162,6 @@ mod test_load {
let loaded = roc_load::file::load_and_typecheck(
&arena,
filename,
arena.alloc(roc_builtins::std::standard_stdlib()),
src_dir.as_path(),
subs_by_module,
TARGET_INFO,
@ -330,7 +326,6 @@ mod test_load {
let loaded = roc_load::file::load_and_typecheck(
&arena,
filename,
arena.alloc(roc_builtins::std::standard_stdlib()),
src_dir.as_path(),
subs_by_module,
TARGET_INFO,

View file

@ -32,9 +32,6 @@ mod solve_expr {
let arena = &Bump::new();
// let stdlib = roc_builtins::unique::uniq_stdlib();
let stdlib = roc_builtins::std::standard_stdlib();
let module_src;
let temp;
if src.starts_with("app") {
@ -58,7 +55,6 @@ mod solve_expr {
let result = roc_load::file::load_and_typecheck(
arena,
full_file_path,
&stdlib,
dir.path(),
exposed_types,
roc_target::TargetInfo::default_x86_64(),

View file

@ -26,7 +26,6 @@ fn promote_expr_to_module(src: &str) -> String {
pub fn helper(
arena: &bumpalo::Bump,
src: &str,
stdlib: roc_builtins::std::StdLib,
_leak: bool,
lazy_literals: bool,
) -> (String, Vec<roc_problem::can::Problem>, Library) {
@ -52,7 +51,6 @@ pub fn helper(
arena,
filename,
module_src,
&stdlib,
src_dir,
Default::default(),
roc_target::TargetInfo::default_x86_64(),
@ -239,11 +237,10 @@ macro_rules! assert_evals_to {
($src:expr, $expected:expr, $ty:ty, $transform:expr, $leak:expr, $lazy_literals:expr) => {
use bumpalo::Bump;
use roc_gen_dev::run_jit_function_raw;
let stdlib = roc_builtins::std::standard_stdlib();
let arena = Bump::new();
let (main_fn_name, errors, lib) =
$crate::helpers::dev::helper(&arena, $src, stdlib, $leak, $lazy_literals);
$crate::helpers::dev::helper(&arena, $src, $leak, $lazy_literals);
let transform = |success| {
let expected = $expected;

View file

@ -26,7 +26,6 @@ fn promote_expr_to_module(src: &str) -> String {
fn create_llvm_module<'a>(
arena: &'a bumpalo::Bump,
src: &str,
stdlib: &'a roc_builtins::std::StdLib,
is_gen_test: bool,
ignore_problems: bool,
context: &'a inkwell::context::Context,
@ -55,7 +54,6 @@ fn create_llvm_module<'a>(
arena,
filename,
module_src,
stdlib,
src_dir,
Default::default(),
target_info,
@ -260,7 +258,6 @@ fn create_llvm_module<'a>(
pub fn helper<'a>(
arena: &'a bumpalo::Bump,
src: &str,
stdlib: &'a roc_builtins::std::StdLib,
is_gen_test: bool,
ignore_problems: bool,
context: &'a inkwell::context::Context,
@ -276,7 +273,6 @@ pub fn helper<'a>(
let (main_fn_name, delayed_errors, module) = create_llvm_module(
arena,
src,
stdlib,
is_gen_test,
ignore_problems,
context,
@ -305,7 +301,6 @@ fn wasm32_target_tripple() -> Triple {
pub fn helper_wasm<'a>(
arena: &'a bumpalo::Bump,
src: &str,
stdlib: &'a roc_builtins::std::StdLib,
_is_gen_test: bool,
ignore_problems: bool,
context: &'a inkwell::context::Context,
@ -322,7 +317,6 @@ pub fn helper_wasm<'a>(
let (_main_fn_name, _delayed_errors, llvm_module) = create_llvm_module(
arena,
src,
stdlib,
is_gen_test,
ignore_problems,
context,
@ -464,18 +458,9 @@ where
let arena = bumpalo::Bump::new();
let context = inkwell::context::Context::create();
// NOTE the stdlib must be in the arena; just taking a reference will segfault
let stdlib = arena.alloc(roc_builtins::std::standard_stdlib());
let is_gen_test = true;
let instance = crate::helpers::llvm::helper_wasm(
&arena,
src,
stdlib,
is_gen_test,
ignore_problems,
&context,
);
let instance =
crate::helpers::llvm::helper_wasm(&arena, src, is_gen_test, ignore_problems, &context);
let memory = instance.exports.get_memory("memory").unwrap();
@ -538,18 +523,9 @@ macro_rules! assert_llvm_evals_to {
let arena = Bump::new();
let context = Context::create();
// NOTE the stdlib must be in the arena; just taking a reference will segfault
let stdlib = arena.alloc(roc_builtins::std::standard_stdlib());
let is_gen_test = true;
let (main_fn_name, errors, lib) = $crate::helpers::llvm::helper(
&arena,
$src,
stdlib,
is_gen_test,
$ignore_problems,
&context,
);
let (main_fn_name, errors, lib) =
$crate::helpers::llvm::helper(&arena, $src, is_gen_test, $ignore_problems, &context);
let transform = |success| {
let expected = $expected;
@ -615,12 +591,9 @@ macro_rules! assert_expect_failed {
let arena = Bump::new();
let context = Context::create();
// NOTE the stdlib must be in the arena; just taking a reference will segfault
let stdlib = arena.alloc(roc_builtins::std::standard_stdlib());
let is_gen_test = true;
let (main_fn_name, errors, lib) =
$crate::helpers::llvm::helper(&arena, $src, stdlib, is_gen_test, false, &context);
$crate::helpers::llvm::helper(&arena, $src, is_gen_test, false, &context);
let transform = |success| {
let expected = $expected;

View file

@ -37,13 +37,12 @@ fn promote_expr_to_module(src: &str) -> String {
pub fn compile_and_load<'a, T: Wasm32Result>(
arena: &'a bumpalo::Bump,
src: &str,
stdlib: &'a roc_builtins::std::StdLib,
_test_wrapper_type_info: PhantomData<T>,
) -> wasmer::Instance {
let platform_bytes = load_platform_and_builtins();
let compiled_bytes =
compile_roc_to_wasm_bytes(arena, stdlib, &platform_bytes, src, _test_wrapper_type_info);
compile_roc_to_wasm_bytes(arena, &platform_bytes, src, _test_wrapper_type_info);
if DEBUG_LOG_SETTINGS.keep_test_binary {
let build_dir_hash = src_hash(src);
@ -67,7 +66,6 @@ fn src_hash(src: &str) -> u64 {
fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
arena: &'a bumpalo::Bump,
stdlib: &'a roc_builtins::std::StdLib,
preload_bytes: &[u8],
src: &str,
_test_wrapper_type_info: PhantomData<T>,
@ -90,7 +88,6 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
arena,
filename,
module_src,
stdlib,
src_dir,
Default::default(),
roc_target::TargetInfo::default_wasm32(),
@ -183,10 +180,7 @@ where
{
let arena = bumpalo::Bump::new();
// NOTE the stdlib must be in the arena; just taking a reference will segfault
let stdlib = arena.alloc(roc_builtins::std::standard_stdlib());
let instance = crate::helpers::wasm::compile_and_load(&arena, src, stdlib, phantom);
let instance = crate::helpers::wasm::compile_and_load(&arena, src, phantom);
let memory = instance.exports.get_memory(MEMORY_NAME).unwrap();
@ -256,10 +250,7 @@ where
{
let arena = bumpalo::Bump::new();
// NOTE the stdlib must be in the arena; just taking a reference will segfault
let stdlib = arena.alloc(roc_builtins::std::standard_stdlib());
let instance = crate::helpers::wasm::compile_and_load(&arena, src, stdlib, phantom);
let instance = crate::helpers::wasm::compile_and_load(&arena, src, phantom);
let memory = instance.exports.get_memory(MEMORY_NAME).unwrap();

View file

@ -80,8 +80,6 @@ fn compiles_to_ir(test_name: &str, src: &str) {
let arena = &Bump::new();
// let stdlib = roc_builtins::unique::uniq_stdlib();
let stdlib = roc_builtins::std::standard_stdlib();
let filename = PathBuf::from("Test.roc");
let src_dir = Path::new("fake/test/path");
@ -100,7 +98,6 @@ fn compiles_to_ir(test_name: &str, src: &str) {
arena,
filename,
module_src,
&stdlib,
src_dir,
Default::default(),
TARGET_INFO,