diff --git a/cli/src/main.rs b/cli/src/main.rs index 0a2b94ebc..eaa429c70 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -2,7 +2,7 @@ use std::cell::{RefCell, RefMut}; use std::collections::HashMap; use std::fs::{self, File}; use std::hash::Hash; -use std::io::{self, Read, Write}; +use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::process; @@ -559,11 +559,8 @@ impl PathHash { /// Read a file. fn read(path: &Path) -> FileResult> { let f = |e| FileError::from_io(e, path); - let mut file = File::open(path).map_err(f)?; - if file.metadata().map_err(f)?.is_file() { - let mut data = vec![]; - file.read_to_end(&mut data).map_err(f)?; - Ok(data) + if fs::metadata(&path).map_err(f)?.is_file() { + fs::read(&path).map_err(f) } else { Err(FileError::IsDirectory) } diff --git a/docs/src/general/changelog.md b/docs/src/general/changelog.md index ab12344e6..45de2dd69 100644 --- a/docs/src/general/changelog.md +++ b/docs/src/general/changelog.md @@ -5,6 +5,9 @@ description: | --- # Changelog +## Unreleased +- Reduced maximum function call depth from 256 to 64. + ## March 28, 2023 - **Breaking:** Enumerations now require a space after their marker, that is, `[1.ok]` must now be written as `[1. ok]` diff --git a/src/eval/mod.rs b/src/eval/mod.rs index 8790bc189..e278d787b 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -60,7 +60,7 @@ use crate::util::PathExt; use crate::World; const MAX_ITERATIONS: usize = 10_000; -const MAX_CALL_DEPTH: usize = 256; +const MAX_CALL_DEPTH: usize = 64; /// Evaluate a source file and return the resulting module. #[comemo::memoize] diff --git a/tests/src/tests.rs b/tests/src/tests.rs index 12f1ecdc1..66eb532f1 100644 --- a/tests/src/tests.rs +++ b/tests/src/tests.rs @@ -2,8 +2,7 @@ use std::cell::{RefCell, RefMut}; use std::collections::HashMap; use std::env; use std::ffi::OsStr; -use std::fs::{self, File}; -use std::io::Read; +use std::fs; use std::ops::Range; use std::path::{Path, PathBuf}; @@ -325,11 +324,8 @@ fn read(path: &Path) -> FileResult> { .unwrap_or_else(|_| path.into()); let f = |e| FileError::from_io(e, &suffix); - let mut file = File::open(&path).map_err(f)?; - if file.metadata().map_err(f)?.is_file() { - let mut data = vec![]; - file.read_to_end(&mut data).map_err(f)?; - Ok(data) + if fs::metadata(&path).map_err(f)?.is_file() { + fs::read(&path).map_err(f) } else { Err(FileError::IsDirectory) } @@ -472,7 +468,7 @@ fn test_part( let mut errors: Vec<_> = errors .into_iter() .filter(|error| error.span.source() == id) - .map(|error| (error.range(world), error.message.to_string())) + .map(|error| (error.range(world), error.message.replace('\\', "/"))) .collect(); errors.sort_by_key(|error| error.0.start);