mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Switch to PathBuf to avoid Path turning into a fat pointer. Avoids growing Constraints
This commit is contained in:
parent
9a87675368
commit
c440b2ca05
4 changed files with 17 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
use std::cell::Cell;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::abilities::SpecializationId;
|
||||
|
@ -680,15 +680,15 @@ impl Constraints {
|
|||
pub fn ingested_file(
|
||||
&mut self,
|
||||
type_index: TypeOrVar,
|
||||
file_path: Box<Path>,
|
||||
file_path: Box<PathBuf>,
|
||||
bytes: Arc<Vec<u8>>,
|
||||
) -> Constraint {
|
||||
Constraint::IngestedFile(type_index, file_path, bytes)
|
||||
}
|
||||
}
|
||||
|
||||
roc_error_macros::assert_sizeof_default!(Constraint, 4 * 8);
|
||||
roc_error_macros::assert_sizeof_aarch64!(Constraint, 4 * 8);
|
||||
roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8);
|
||||
roc_error_macros::assert_sizeof_aarch64!(Constraint, 3 * 8);
|
||||
|
||||
impl std::ops::Index<ExpectedTypeIndex> for Constraints {
|
||||
type Output = Expected<TypeOrVar>;
|
||||
|
@ -786,7 +786,7 @@ pub enum Constraint {
|
|||
Resolve(OpportunisticResolve),
|
||||
CheckCycle(Index<Cycle>, IllegalCycleMark),
|
||||
|
||||
IngestedFile(TypeOrVar, Box<Path>, Arc<Vec<u8>>),
|
||||
IngestedFile(TypeOrVar, Box<PathBuf>, Arc<Vec<u8>>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default)]
|
||||
|
|
|
@ -29,7 +29,7 @@ use roc_types::types::{Alias, Category, IndexOrField, LambdaSet, OptAbleVar, Typ
|
|||
use std::fmt::{Debug, Display};
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::{char, u32};
|
||||
|
||||
|
@ -105,7 +105,7 @@ pub enum Expr {
|
|||
},
|
||||
|
||||
// An ingested files, it's bytes, and the type variable.
|
||||
IngestedFile(Box<Path>, Arc<Vec<u8>>, Variable),
|
||||
IngestedFile(Box<PathBuf>, Arc<Vec<u8>>, Variable),
|
||||
|
||||
// Lookups
|
||||
Var(Symbol, Variable),
|
||||
|
@ -742,7 +742,11 @@ pub fn canonicalize_expr<'a>(
|
|||
let mut bytes = vec![];
|
||||
match file.read_to_end(&mut bytes) {
|
||||
Ok(_) => (
|
||||
Expr::IngestedFile((*file_path).into(), Arc::new(bytes), var_store.fresh()),
|
||||
Expr::IngestedFile(
|
||||
file_path.to_path_buf().into(),
|
||||
Arc::new(bytes),
|
||||
var_store.fresh(),
|
||||
),
|
||||
Output::default(),
|
||||
),
|
||||
Err(e) => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//! Provides types to describe problems that can occur during solving.
|
||||
use std::{path::Path, str::Utf8Error};
|
||||
use std::{path::PathBuf, str::Utf8Error};
|
||||
|
||||
use roc_can::expected::{Expected, PExpected};
|
||||
use roc_module::{ident::Lowercase, symbol::Symbol};
|
||||
|
@ -31,8 +31,8 @@ pub enum TypeError {
|
|||
expected_opaque: Symbol,
|
||||
found_opaque: Symbol,
|
||||
},
|
||||
IngestedFileBadUtf8(Box<Path>, Utf8Error),
|
||||
IngestedFileUnsupportedType(Box<Path>, ErrorType),
|
||||
IngestedFileBadUtf8(Box<PathBuf>, Utf8Error),
|
||||
IngestedFileUnsupportedType(Box<PathBuf>, ErrorType),
|
||||
}
|
||||
|
||||
impl TypeError {
|
||||
|
|
|
@ -15,7 +15,7 @@ use roc_module::symbol::{Interns, Symbol};
|
|||
use roc_region::all::{Loc, Region};
|
||||
use std::fmt;
|
||||
use std::fmt::Write;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub const TYPE_NUM: &str = "Num";
|
||||
pub const TYPE_INTEGER: &str = "Integer";
|
||||
|
@ -3782,7 +3782,7 @@ pub enum Category {
|
|||
List,
|
||||
Str,
|
||||
Character,
|
||||
IngestedFile(Box<Path>),
|
||||
IngestedFile(Box<PathBuf>),
|
||||
|
||||
// records
|
||||
Record,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue