Merge pull request #3357 from rtfeldman/build-cleanup

Build cleanup - Just some crate updating and deps cleanup
This commit is contained in:
Anton-4 2022-07-01 10:57:59 +02:00 committed by GitHub
commit 12ef03bb86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 599 additions and 812 deletions

1149
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -23,7 +23,7 @@ roc_reporting = { path = "../reporting" }
arrayvec = "0.7.2"
bumpalo = { version = "3.8.0", features = ["collections"] }
page_size = "0.4.2"
snafu = { version = "0.6.10", features = ["backtraces"] }
snafu = { version = "0.7.1", features = ["backtraces"] }
ven_graph = { path = "../vendor/pathfinding" }
libc = "0.2.106"

View file

@ -1,5 +1,5 @@
use crate::{
ast_error::{ASTNodeIdWithoutExprId, ASTResult},
ast_error::{ASTNodeIdWithoutExprIdSnafu, ASTResult},
mem_pool::pool::Pool,
};
@ -43,14 +43,14 @@ impl ASTNodeId {
pub fn to_expr_id(&self) -> ASTResult<ExprId> {
match self {
ASTNodeId::AExprId(expr_id) => Ok(*expr_id),
_ => ASTNodeIdWithoutExprId { ast_node_id: *self }.fail()?,
_ => ASTNodeIdWithoutExprIdSnafu { ast_node_id: *self }.fail()?,
}
}
pub fn to_def_id(&self) -> ASTResult<DefId> {
match self {
ASTNodeId::ADefId(def_id) => Ok(*def_id),
_ => ASTNodeIdWithoutExprId { ast_node_id: *self }.fail()?,
_ => ASTNodeIdWithoutExprIdSnafu { ast_node_id: *self }.fail()?,
}
}
}

View file

@ -16,7 +16,7 @@ use roc_problem::can::{MalformedPatternProblem, Problem, RuntimeError, ShadowKin
use roc_region::all::Region;
use roc_types::subs::Variable;
use crate::ast_error::{ASTResult, UnexpectedPattern2Variant};
use crate::ast_error::{ASTResult, UnexpectedPattern2VariantSnafu};
use crate::constrain::Constraint;
use crate::lang::core::expr::expr_to_expr2::to_expr_id;
use crate::lang::env::Env;
@ -517,7 +517,7 @@ pub fn symbols_from_pattern(pool: &Pool, initial: &Pattern2) -> Vec<Symbol> {
pub fn get_identifier_string(pattern: &Pattern2, interns: &Interns) -> ASTResult<String> {
match pattern {
Pattern2::Identifier(symbol) => Ok(symbol.as_str(interns).to_string()),
other => UnexpectedPattern2Variant {
other => UnexpectedPattern2VariantSnafu {
required_pattern2: "Identifier".to_string(),
encountered_pattern2: format!("{:?}", other),
}

View file

@ -3,7 +3,7 @@ use roc_module::{called_via::CalledVia, symbol::Symbol};
use roc_parse::ast::StrLiteral;
use crate::{
ast_error::{ASTResult, UnexpectedASTNode},
ast_error::{ASTResult, UnexpectedASTNodeSnafu},
lang::{
core::expr::{
expr2::{ArrString, ARR_STRING_CAPACITY},
@ -225,7 +225,7 @@ pub fn update_str_expr(
}
}
Expr2::Str(old_pool_str) => Either::OldPoolStr(*old_pool_str),
other => UnexpectedASTNode {
other => UnexpectedASTNodeSnafu {
required_node_type: "SmallStr or Str",
encountered_node_type: format!("{:?}", other),
}

View file

@ -81,7 +81,7 @@ wasmer-wasi = "2.2.1"
pretty_assertions = "1.0.0"
roc_test_utils = { path = "../test_utils" }
indoc = "1.0.3"
serial_test = "0.5.1"
serial_test = "0.8.0"
criterion = { git = "https://github.com/Anton-4/criterion.rs"}
cli_utils = { path = "../cli_utils" }
strum = "0.24.0"

View file

@ -12,6 +12,6 @@ roc_module = { path = "../compiler/module" }
roc_utils = { path = "../utils" }
serde = { version = "1.0.130", features = ["derive"] }
palette = "0.6.0"
snafu = { version = "0.6.10", features = ["backtraces"] }
snafu = { version = "0.7.1", features = ["backtraces"] }
bumpalo = { version = "3.8.0", features = ["collections"] }
itertools = "0.10.1"

View file

@ -1,7 +1,7 @@
#![allow(dead_code)]
use snafu::ensure;
use crate::markup_error::{CaretNotFound, MarkResult};
use crate::markup_error::{CaretNotFoundSnafu, MarkResult};
#[derive(Debug, Copy, Clone)]
pub struct Caret {
@ -117,7 +117,7 @@ impl Attributes {
let new_len = self.all.len();
ensure!(old_len != new_len, CaretNotFound { node_id });
ensure!(old_len != new_len, CaretNotFoundSnafu { node_id });
Ok(())
}

View file

@ -2,7 +2,7 @@ use std::collections::HashMap;
use roc_ast::lang::core::ast::ASTNodeId;
use crate::markup_error::MarkNodeIdWithoutCorrespondingASTNodeId;
use crate::markup_error::MarkNodeIdWithoutCorrespondingASTNodeIdSnafu;
use crate::{markup_error::MarkResult, slow_pool::MarkNodeId};
/// A hashmap is wrapped to allow for an easy swap out with more performant alternatives
@ -19,7 +19,7 @@ impl MarkIdAstIdMap {
pub fn get(&self, mn_id: MarkNodeId) -> MarkResult<ASTNodeId> {
match self.map.get(&mn_id) {
Some(ast_node_id) => Ok(*ast_node_id),
None => MarkNodeIdWithoutCorrespondingASTNodeId {
None => MarkNodeIdWithoutCorrespondingASTNodeIdSnafu {
node_id: mn_id,
keys_str: format!("{:?}", self.map.keys()),
}

View file

@ -9,7 +9,9 @@ use super::{
mark_id_ast_id_map::MarkIdAstIdMap,
};
use crate::markup_error::{ExpectedTextNode, NestedNodeMissingChild, NestedNodeRequired};
use crate::markup_error::{
ExpectedTextNodeSnafu, NestedNodeMissingChildSnafu, NestedNodeRequiredSnafu,
};
use itertools::Itertools;
use roc_ast::{
lang::{core::ast::ASTNodeId, env::Env},
@ -134,14 +136,14 @@ impl MarkupNode {
Ok((child_index, closest_ast_child_index + 1))
}
} else {
NestedNodeMissingChild {
NestedNodeMissingChildSnafu {
node_id: mark_node_id,
children_ids: children_ids.clone(),
}
.fail()
}
}
_ => NestedNodeRequired {
_ => NestedNodeRequiredSnafu {
node_type: self.node_type_as_string(),
}
.fail(),
@ -171,7 +173,7 @@ impl MarkupNode {
pub fn get_content_mut(&mut self) -> MarkResult<&mut String> {
match self {
MarkupNode::Text { content, .. } => Ok(content),
_ => ExpectedTextNode {
_ => ExpectedTextNodeSnafu {
function_name: "set_content".to_owned(),
node_type: self.node_type_as_string(),
}
@ -189,7 +191,7 @@ impl MarkupNode {
if let MarkupNode::Nested { children_ids, .. } = self {
children_ids.splice(index..index, vec![child_id]);
} else {
NestedNodeRequired {
NestedNodeRequiredSnafu {
node_type: self.node_type_as_string(),
}
.fail()?;

View file

@ -60,6 +60,8 @@ impl From<UtilError> for MarkError {
// hack to handle MarkError derive
let dummy_res: Result<(), NoneError> = Err(NoneError {});
dummy_res.context(UtilErrorBacktrace { msg }).unwrap_err()
dummy_res
.context(UtilErrorBacktraceSnafu { msg })
.unwrap_err()
}
}

View file

@ -10,5 +10,5 @@ im = "15.0.0"
im-rc = "15.0.0"
wyhash = "0.5.0"
bumpalo = { version = "3.8.0", features = ["collections"] }
hashbrown = { version = "0.11.2", features = [ "bumpalo" ] }
hashbrown = { version = "0.12.1", features = [ "bumpalo" ] }
bitvec = "1"

View file

@ -11,7 +11,6 @@ roc_error_macros = { path = "../../error_macros" }
roc_region = { path = "../region" }
roc_module = { path = "../module" }
roc_types = { path = "../types" }
roc_can = { path = "../can" }
[features]
default = []

View file

@ -9,4 +9,3 @@ edition = "2021"
roc_collections = { path = "../collections" }
roc_region = { path = "../region" }
roc_module = { path = "../module" }
roc_std = { path = "../../roc_std", default-features = false }

View file

@ -24,7 +24,7 @@ target-lexicon = "0.12.3"
# It looks like it breaks linking the generated objects.
# Probably just need to specify an extra field that used to be implicit or something.
# When fixed also update the version of object in the linker.
object = { version = "0.26.2", features = ["write"] }
object = { version = "0.29.0", features = ["write"] }
packed_struct = "0.10.0"
[dev-dependencies]

View file

@ -27,7 +27,7 @@ pub fn build_module<'a>(
interns: &'a mut Interns,
target: &Triple,
procedures: MutMap<(symbol::Symbol, ProcLayout<'a>), Proc<'a>>,
) -> Object {
) -> Object<'a> {
match target {
Triple {
architecture: TargetArch::X86_64,
@ -165,8 +165,8 @@ fn generate_wrapper<'a, B: Backend<'a>>(
fn build_object<'a, B: Backend<'a>>(
procedures: MutMap<(symbol::Symbol, ProcLayout<'a>), Proc<'a>>,
mut backend: B,
mut output: Object,
) -> Object {
mut output: Object<'a>,
) -> Object<'a> {
let data_section = output.section_id(StandardSection::Data);
let arena = backend.env().arena;
@ -318,7 +318,7 @@ fn build_object<'a, B: Backend<'a>>(
}
fn build_proc_symbol<'a, B: Backend<'a>>(
output: &mut Object,
output: &mut Object<'a>,
layout_ids: &mut LayoutIds<'a>,
procs: &mut Vec<'a, (String, SectionId, SymbolId, Proc<'a>)>,
backend: &B,

View file

@ -13,7 +13,7 @@ roc_error_macros = {path = "../../error_macros"}
bumpalo = { version = "3.8.0", features = ["collections"] }
lazy_static = "1.4.0"
static_assertions = "1.1.0"
snafu = { version = "0.6.10", features = ["backtraces"] }
snafu = { version = "0.7.1", features = ["backtraces"] }
[features]
default = []

View file

@ -1,5 +1,5 @@
use crate::ident::{Ident, ModuleName};
use crate::module_err::{IdentIdNotFound, ModuleIdNotFound, ModuleResult};
use crate::module_err::{IdentIdNotFoundSnafu, ModuleIdNotFoundSnafu, ModuleResult};
use roc_collections::{SmallStringInterner, VecMap};
use roc_ident::IdentStr;
use roc_region::all::Region;
@ -295,7 +295,7 @@ pub fn get_module_ident_ids<'a>(
) -> ModuleResult<&'a IdentIds> {
all_ident_ids
.get(module_id)
.with_context(|| ModuleIdNotFound {
.with_context(|| ModuleIdNotFoundSnafu {
module_id: format!("{:?}", module_id),
all_ident_ids: format!("{:?}", all_ident_ids),
})
@ -307,7 +307,7 @@ pub fn get_module_ident_ids_mut<'a>(
) -> ModuleResult<&'a mut IdentIds> {
all_ident_ids
.get_mut(module_id)
.with_context(|| ModuleIdNotFound {
.with_context(|| ModuleIdNotFoundSnafu {
module_id: format!("{:?}", module_id),
all_ident_ids: "I could not return all_ident_ids here because of borrowing issues.",
})
@ -643,10 +643,11 @@ impl IdentIds {
}
pub fn get_name_str_res(&self, ident_id: IdentId) -> ModuleResult<&str> {
self.get_name(ident_id).with_context(|| IdentIdNotFound {
ident_id,
ident_ids_str: format!("{:?}", self),
})
self.get_name(ident_id)
.with_context(|| IdentIdNotFoundSnafu {
ident_id,
ident_ids_str: format!("{:?}", self),
})
}
pub fn len(&self) -> usize {

View file

@ -22,5 +22,5 @@ roc_error_macros = {path="../../error_macros"}
roc_debug_flags = {path="../debug_flags"}
ven_pretty = { path = "../../vendor/pretty" }
bumpalo = { version = "3.8.0", features = ["collections"] }
hashbrown = { version = "0.11.2", features = [ "bumpalo" ] }
hashbrown = { version = "0.12.1", features = [ "bumpalo" ] }
static_assertions = "1.1.0"

View file

@ -6,7 +6,7 @@ authors = ["The Roc Contributors"]
edition = "2021"
[dependencies]
pulldown-cmark = { version = "0.8.0", default-features = false }
pulldown-cmark = { version = "0.9.1", default-features = false }
roc_ast = { path = "../ast" }
roc_load = { path = "../compiler/load" }
roc_builtins = { path = "../compiler/builtins" }
@ -21,7 +21,7 @@ roc_collections = { path = "../compiler/collections" }
roc_highlight = { path = "../highlight"}
roc_reporting = { path = "../reporting"}
bumpalo = { version = "3.8.0", features = ["collections"] }
snafu = { version = "0.6.10", features = ["backtraces"] }
snafu = { version = "0.7.1", features = ["backtraces"] }
peg = "0.8.0"
[dev-dependencies]

View file

@ -37,19 +37,19 @@ arrayvec = "0.7.2"
libc = "0.2.106"
page_size = "0.4.2"
# once winit 0.26 is out, check if copypasta can be updated simultaneously so they use the same versions for their dependencies. This will save build time.
winit = "0.25.0"
wgpu = "0.11.0"
wgpu_glyph = "0.15.1"
winit = "0.26.0"
wgpu = "0.12.0"
wgpu_glyph = "0.16.0"
glyph_brush = "0.7.2"
log = "0.4.14"
env_logger = "0.9.0"
futures = "0.3.17"
cgmath = "0.18.0"
snafu = { version = "0.6.10", features = ["backtraces"] }
snafu = { version = "0.7.1", features = ["backtraces"] }
colored = "2.0.0"
pest = "2.1.3"
pest_derive = "2.1.0"
copypasta = "0.7.1"
copypasta = "0.8.1"
palette = "0.6.0"
confy = { git = 'https://github.com/rust-cli/confy', features = [
"yaml_conf"
@ -57,7 +57,7 @@ confy = { git = 'https://github.com/rust-cli/confy', features = [
serde = { version = "1.0.130", features = ["derive"] }
nonempty = "0.7.0"
fs_extra = "1.2.0"
rodio = { version = "0.14.0", optional = true } # to play sounds
rodio = { version = "0.15.0", optional = true } # to play sounds
threadpool = "1.8.1"
[dependencies.bytemuck]
@ -67,4 +67,4 @@ features = ["derive"]
[dev-dependencies]
rand = "0.8.4"
tempfile = "3.2.0"
uuid = { version = "0.8.2", features = ["v4"] }
uuid = { version = "1.1.2", features = ["v4"] }

View file

@ -1,12 +1,12 @@
use crate::editor::ed_error::EdResult;
use crate::editor::ed_error::NestedNodeWithoutChildren;
use crate::editor::ed_error::{NoDefMarkNodeBeforeLineNr, NodeIdNotInGridNodeMap};
use crate::editor::ed_error::NestedNodeWithoutChildrenSnafu;
use crate::editor::ed_error::{NoDefMarkNodeBeforeLineNrSnafu, NodeIdNotInGridNodeMapSnafu};
use crate::editor::mvc::ed_model::EdModel;
use crate::editor::util::first_last_index_of;
use crate::editor::util::index_of;
use crate::ui::text::selection::Selection;
use crate::ui::text::text_pos::TextPos;
use crate::ui::ui_error::{LineInsertionFailed, OutOfBounds, UIResult};
use crate::ui::ui_error::{LineInsertionFailedSnafu, OutOfBoundsSnafu, UIResult};
use crate::ui::util::{slice_get, slice_get_mut};
use roc_ast::lang::core::ast::ASTNodeId;
use roc_code_markup::markup::mark_id_ast_id_map::MarkIdAstIdMap;
@ -44,7 +44,7 @@ impl GridNodeMap {
self.insert_between_line(line_nr, index, len, node_id)?;
} else {
LineInsertionFailed {
LineInsertionFailedSnafu {
line_nr,
nr_of_lines,
}
@ -60,7 +60,7 @@ impl GridNodeMap {
Ok(())
} else {
OutOfBounds {
OutOfBoundsSnafu {
index: line_nr,
collection_name: "code_lines.lines".to_owned(),
len: self.lines.len(),
@ -92,7 +92,7 @@ impl GridNodeMap {
Ok(())
}
Ordering::Equal => self.insert_empty_line(line_nr + 1),
Ordering::Greater => OutOfBounds {
Ordering::Greater => OutOfBoundsSnafu {
index: line_nr,
collection_name: "grid_node_map.lines".to_owned(),
len: self.lines.len(),
@ -200,7 +200,7 @@ impl GridNodeMap {
if let Some(last_pos) = last_pos_opt {
Ok(last_pos)
} else {
NodeIdNotInGridNodeMap { node_id }.fail()
NodeIdNotInGridNodeMapSnafu { node_id }.fail()
}
}
@ -343,11 +343,12 @@ impl GridNodeMap {
let mut first_child_id = 0;
while !children_ids.is_empty() {
first_child_id = *children_ids
.first()
.with_context(|| NestedNodeWithoutChildren {
node_id: nested_node_id,
})?;
first_child_id =
*children_ids
.first()
.with_context(|| NestedNodeWithoutChildrenSnafu {
node_id: nested_node_id,
})?;
children_ids = ed_model
.mark_node_pool
@ -370,11 +371,12 @@ impl GridNodeMap {
let mut last_child_id = 0;
while !children_ids.is_empty() {
last_child_id = *children_ids
.last()
.with_context(|| NestedNodeWithoutChildren {
node_id: nested_node_id,
})?;
last_child_id =
*children_ids
.last()
.with_context(|| NestedNodeWithoutChildrenSnafu {
node_id: nested_node_id,
})?;
children_ids = ed_model
.mark_node_pool
@ -410,7 +412,7 @@ impl GridNodeMap {
}
}
NoDefMarkNodeBeforeLineNr { line_nr }.fail()
NoDefMarkNodeBeforeLineNrSnafu { line_nr }.fail()
}
}

View file

@ -1,8 +1,8 @@
use crate::editor::code_lines::CodeLines;
use crate::editor::grid_node_map::GridNodeMap;
use crate::editor::{
ed_error::SrcParseError,
ed_error::{EdResult, EmptyCodeString, MissingParent, NoNodeAtCaretPosition},
ed_error::SrcParseSnafu,
ed_error::{EdResult, EmptyCodeStringSnafu, MissingParentSnafu, NoNodeAtCaretPositionSnafu},
};
use crate::graphics::primitives::rect::Rect;
use crate::ui::text::caret_w_select::{CaretPos, CaretWSelect};
@ -67,7 +67,7 @@ pub fn init_model<'a>(
let mut mark_node_pool = SlowPool::default();
let (markup_ids, mark_id_ast_id_map) = if code_str.is_empty() {
EmptyCodeString {}.fail()
EmptyCodeStringSnafu {}.fail()
} else {
Ok(ast_to_mark_nodes(
&mut module.env,
@ -170,13 +170,13 @@ impl<'a> EdModel<'a> {
&self.mark_id_ast_id_map,
)?)
} else {
MissingParent {
MissingParentSnafu {
node_id: curr_mark_node_id,
}
.fail()
}
} else {
NoNodeAtCaretPosition {
NoNodeAtCaretPositionSnafu {
caret_pos: self.get_caret(),
}
.fail()
@ -205,13 +205,13 @@ impl<'a> EdModule<'a> {
match parse_res {
Ok(ast) => Ok(EdModule { env, ast }),
Err(err) => SrcParseError {
Err(err) => SrcParseSnafu {
syntax_err: format!("{:?}", err),
}
.fail(),
}
} else {
EmptyCodeString {}.fail()
EmptyCodeStringSnafu {}.fail()
}
}
}

View file

@ -5,7 +5,7 @@ use std::process::Stdio;
use crate::editor::code_lines::CodeLines;
use crate::editor::ed_error::EdResult;
use crate::editor::ed_error::{MissingSelection, RocCheckFailed};
use crate::editor::ed_error::{MissingSelectionSnafu, RocCheckFailedSnafu};
use crate::editor::grid_node_map::GridNodeMap;
use crate::editor::mvc::app_update::InputOutcome;
use crate::editor::mvc::ed_model::EdModel;
@ -574,7 +574,7 @@ impl<'a> EdModel<'a> {
self.mark_node_pool
.replace_node(sel_block.mark_node_id, blank_replacement);
let active_selection = self.get_selection().context(MissingSelection {})?;
let active_selection = self.get_selection().context(MissingSelectionSnafu {})?;
self.grid_node_map.del_selection(active_selection)?;
@ -630,7 +630,7 @@ impl<'a> EdModel<'a> {
.output()?;
if !cmd_out.status.success() {
RocCheckFailed.fail()?
RocCheckFailedSnafu.fail()?
}
Ok(())

View file

@ -12,7 +12,7 @@ use crate::ui::text::caret_w_select::make_selection_rect;
use crate::ui::text::caret_w_select::CaretWSelect;
use crate::ui::text::selection::Selection;
use crate::ui::tooltip::ToolTip;
use crate::ui::ui_error::MissingGlyphDims;
use crate::ui::ui_error::MissingGlyphDimsSnafu;
use cgmath::Vector2;
use roc_ast::mem_pool::pool::Pool;
use snafu::OptionExt;
@ -73,7 +73,9 @@ pub fn model_to_wgpu<'a>(
txt_coords: Vector2<f32>,
config: &Config,
) -> EdResult<RenderedWgpu> {
let glyph_dim_rect = ed_model.glyph_dim_rect_opt.context(MissingGlyphDims {})?;
let glyph_dim_rect = ed_model
.glyph_dim_rect_opt
.context(MissingGlyphDimsSnafu {})?;
let mut all_rendered = RenderedWgpu::new();

View file

@ -5,7 +5,7 @@ use roc_ast::mem_pool::pool_str::PoolStr;
use roc_code_markup::slow_pool::MarkNodeId;
use crate::editor::ed_error::EdResult;
use crate::editor::ed_error::StringParseError;
use crate::editor::ed_error::StringParseSnafu;
use crate::editor::mvc::app_update::InputOutcome;
use crate::editor::mvc::ed_model::EdModel;
use crate::editor::mvc::ed_update::get_node_context;
@ -125,7 +125,7 @@ fn update_small_int_num(number: &mut IntVal, updated_str: &str) -> EdResult<()>
fn check_parse_res<T, E: std::fmt::Debug>(parse_res: Result<T, E>) -> EdResult<T> {
match parse_res {
Ok(some_type) => Ok(some_type),
Err(parse_err) => StringParseError {
Err(parse_err) => StringParseSnafu {
msg: format!("{:?}", parse_err),
}
.fail(),

View file

@ -5,7 +5,7 @@ use roc_code_markup::markup::nodes::{self};
use roc_code_markup::slow_pool::MarkNodeId;
use crate::editor::ed_error::EdResult;
use crate::editor::ed_error::{MissingParent, UnexpectedASTNode};
use crate::editor::ed_error::{MissingParentSnafu, UnexpectedASTNodeSnafu};
use crate::editor::mvc::app_update::InputOutcome;
use crate::editor::mvc::ed_model::EdModel;
use crate::editor::mvc::ed_update::get_node_context;
@ -71,14 +71,14 @@ pub fn add_blank_child(
Ok((blank_elt_id, list_ast_node_id.to_expr_id()?, parent_id))
}
_ => UnexpectedASTNode {
_ => UnexpectedASTNodeSnafu {
required_node_type: "List".to_string(),
encountered_node_type: ast_node_to_string(ast_node_id, ed_model.module.env.pool),
}
.fail(),
}
} else {
MissingParent {
MissingParentSnafu {
node_id: curr_mark_node_id,
}
.fail()
@ -108,7 +108,7 @@ pub fn add_blank_child(
Ok(())
}
_ => UnexpectedASTNode {
_ => UnexpectedASTNodeSnafu {
required_node_type: "List".to_string(),
encountered_node_type: ast_node_to_string(ast_node_id, ed_model.module.env.pool),
}

View file

@ -1,6 +1,6 @@
use crate::editor::ed_error::EdResult;
use crate::editor::ed_error::MissingParent;
use crate::editor::ed_error::RecordWithoutFields;
use crate::editor::ed_error::MissingParentSnafu;
use crate::editor::ed_error::RecordWithoutFieldsSnafu;
use crate::editor::mvc::app_update::InputOutcome;
use crate::editor::mvc::ed_model::EdModel;
use crate::editor::mvc::ed_update::get_node_context;
@ -106,7 +106,7 @@ pub fn update_empty_record(
parent.add_child_at_index(new_child_index, record_field_node_id)?;
} else {
MissingParent {
MissingParentSnafu {
node_id: curr_mark_node_id,
}
.fail()?
@ -179,7 +179,7 @@ pub fn update_record_colon(
let first_field_mut = fields
.iter_mut(ed_model.module.env.pool)
.next()
.with_context(|| RecordWithoutFields {})?;
.with_context(|| RecordWithoutFieldsSnafu {})?;
*first_field_mut = RecordField::LabeledValue(
*first_field_mut.get_record_field_pool_str(),
@ -243,7 +243,7 @@ pub fn update_record_field(
let first_field = record_fields
.iter(ed_model.module.env.pool)
.next()
.with_context(|| RecordWithoutFields {})?;
.with_context(|| RecordWithoutFieldsSnafu {})?;
let field_pool_str = first_field
.get_record_field_pool_str()
@ -259,7 +259,7 @@ pub fn update_record_field(
let first_field_mut = record_fields
.iter_mut(ed_model.module.env.pool)
.next()
.with_context(|| RecordWithoutFields {})?;
.with_context(|| RecordWithoutFieldsSnafu {})?;
let field_pool_str_mut = first_field_mut.get_record_field_pool_str_mut();
*field_pool_str_mut = new_field_pool_str;
@ -268,7 +268,7 @@ pub fn update_record_field(
let first_field_b = record_fields
.iter(ed_model.module.env.pool)
.next()
.with_context(|| RecordWithoutFields {})?;
.with_context(|| RecordWithoutFieldsSnafu {})?;
match first_field_b {
RecordField::InvalidLabelOnly(_, _) => {

View file

@ -2,7 +2,7 @@ use roc_ast::lang::core::{def::def2::Def2, expr::expr2::Expr2};
use roc_code_markup::slow_pool::MarkNodeId;
use crate::{
editor::ed_error::{EdResult, FailedToUpdateIdentIdName, KeyNotFound},
editor::ed_error::{EdResult, FailedToUpdateIdentIdNameSnafu, KeyNotFoundSnafu},
ui::text::text_pos::TextPos,
};
@ -39,7 +39,7 @@ pub fn start_new_tld_value(ed_model: &mut EdModel, new_char: &char) -> EdResult<
// this might create different IdentId for interns and env.ident_ids which may be a problem
module_ident_ids_ref.add_str(&ident_str);
} else {
KeyNotFound {
KeyNotFoundSnafu {
key_str: format!("{:?}", ed_model.module.env.home),
}
.fail()?
@ -89,7 +89,7 @@ pub fn update_tld_val_name(
.update_key(&old_val_name, &val_name_str);
if let Err(err_str) = update_val_name_res {
FailedToUpdateIdentIdName { err_str }.fail()?;
FailedToUpdateIdentIdNameSnafu { err_str }.fail()?;
}
ed_model.simple_move_caret_right(old_caret_pos, 1);

View file

@ -1,5 +1,5 @@
use super::ed_error::{EdResult, KeyNotFound};
use crate::editor::ed_error::IndexOfFailed;
use super::ed_error::{EdResult, KeyNotFoundSnafu};
use crate::editor::ed_error::IndexOfFailedSnafu;
use snafu::OptionExt;
use std::collections::HashMap;
@ -8,7 +8,7 @@ pub fn map_get<'a, K: ::std::fmt::Debug + std::hash::Hash + std::cmp::Eq, V>(
hash_map: &'a HashMap<K, V>,
key: &K,
) -> EdResult<&'a V> {
let value = hash_map.get(key).context(KeyNotFound {
let value = hash_map.get(key).context(KeyNotFoundSnafu {
key_str: format!("{:?}", key),
})?;
@ -23,7 +23,7 @@ pub fn index_of<T: ::std::fmt::Debug + std::cmp::Eq>(elt: T, slice: &[T]) -> EdR
let elt_str = format!("{:?}", elt);
let collection_str = format!("{:?}", slice);
IndexOfFailed {
IndexOfFailedSnafu {
elt_str,
collection_str,
}
@ -59,7 +59,7 @@ pub fn first_last_index_of<T: ::std::fmt::Debug + std::cmp::Eq>(
let elt_str = format!("{:?}", elt);
let collection_str = format!("{:?}", slice);
IndexOfFailed {
IndexOfFailedSnafu {
elt_str,
collection_str,
}

View file

@ -66,5 +66,6 @@ pub fn create_render_pipeline(
primitive: wgpu::PrimitiveState::default(),
depth_stencil: None,
multisample: wgpu::MultisampleState::default(),
multiview: None,
})
}

View file

@ -9,7 +9,7 @@ use crate::ui::text::{
selection::{validate_raw_sel, RawSelection, Selection},
text_pos::TextPos,
};
use crate::ui::ui_error::{OutOfBounds, UIResult};
use crate::ui::ui_error::{OutOfBoundsSnafu, UIResult};
use crate::ui::util::is_newline;
use crate::window::keyboard_input::{no_mods, Modifiers};
use bumpalo::Bump;
@ -30,7 +30,7 @@ impl BigTextArea {
fn check_bounds(&self, char_indx: usize) -> UIResult<()> {
ensure!(
char_indx <= self.text_buffer.nr_of_chars(),
OutOfBounds {
OutOfBoundsSnafu {
index: char_indx,
collection_name: "TextBuffer",
len: self.text_buffer.nr_of_chars()
@ -344,7 +344,7 @@ pub mod test_big_sel_text {
lines::{Lines, MutSelectableLines, SelectableLines},
text_pos::TextPos,
};
use crate::ui::ui_error::{OutOfBounds, UIResult};
use crate::ui::ui_error::{OutOfBoundsSnafu, UIResult};
use crate::window::keyboard_input::{no_mods, Modifiers};
use snafu::OptionExt;
use std::slice::SliceIndex;
@ -372,7 +372,7 @@ pub mod test_big_sel_text {
) -> UIResult<&mut <usize as SliceIndex<[T]>>::Output> {
let vec_len = vec.len();
let elt_ref = vec.get_mut(index).context(OutOfBounds {
let elt_ref = vec.get_mut(index).context(OutOfBoundsSnafu {
index,
collection_name: "Slice",
len: vec_len,

View file

@ -138,7 +138,7 @@ pub mod test_caret_w_select {
use crate::ui::text::caret_w_select::CaretWSelect;
use crate::ui::text::selection::validate_selection;
use crate::ui::text::text_pos::TextPos;
use crate::ui::ui_error::OutOfBounds;
use crate::ui::ui_error::OutOfBoundsSnafu;
use crate::ui::ui_error::UIResult;
use crate::ui::util::slice_get;
use core::cmp::Ordering;
@ -314,7 +314,7 @@ pub mod test_caret_w_select {
) -> UIResult<&mut <usize as SliceIndex<[T]>>::Output> {
let vec_len = vec.len();
let elt_ref = vec.get_mut(index).context(OutOfBounds {
let elt_ref = vec.get_mut(index).context(OutOfBoundsSnafu {
index,
collection_name: "Slice",
len: vec_len,

View file

@ -3,7 +3,7 @@
use super::lines::Lines;
use super::text_pos::TextPos;
use crate::ui::theme::UITheme;
use crate::ui::ui_error::{InvalidSelection, UIResult};
use crate::ui::ui_error::{InvalidSelectionSnafu, UIResult};
use bumpalo::collections::Vec as BumpVec;
use snafu::ensure;
use std::fmt;
@ -47,7 +47,7 @@ pub fn validate_sel_opt(start_pos: TextPos, end_pos: TextPos) -> UIResult<Option
pub fn validate_selection(start_pos: TextPos, end_pos: TextPos) -> UIResult<Selection> {
ensure!(
start_pos.line <= end_pos.line,
InvalidSelection {
InvalidSelectionSnafu {
err_msg: format!(
"start_pos.line ({}) should be smaller than or equal to end_pos.line ({})",
start_pos.line, end_pos.line
@ -57,7 +57,7 @@ pub fn validate_selection(start_pos: TextPos, end_pos: TextPos) -> UIResult<Sele
ensure!(
!(start_pos.line == end_pos.line && start_pos.column >= end_pos.column),
InvalidSelection {
InvalidSelectionSnafu {
err_msg: format!(
"start_pos.column ({}) should be smaller than end_pos.column ({}) when start_pos.line equals end_pos.line",
start_pos.column,

View file

@ -1,7 +1,7 @@
use std::path::Path;
use crate::ui::{
ui_error::{OutOfBounds, TextBufReadFailed, UIResult},
ui_error::{OutOfBoundsSnafu, TextBufReadFailedSnafu, UIResult},
util::{path_to_string, reader_from_path},
};
use snafu::ensure;
@ -25,7 +25,7 @@ impl TextBuffer {
match line {
Ok(line_str) => lines.push(line_str),
Err(e) => {
TextBufReadFailed {
TextBufReadFailedSnafu {
path_str: path_to_string(path),
err_msg: e.to_string(),
}
@ -64,7 +64,7 @@ impl TextBuffer {
fn ensure_bounds(&self, line_nr: usize) -> UIResult<()> {
ensure!(
line_nr < self.nr_of_lines(),
OutOfBounds {
OutOfBoundsSnafu {
index: line_nr,
collection_name: "TextBuffer",
len: self.nr_of_lines(),
@ -77,7 +77,7 @@ impl TextBuffer {
fn ensure_bounds_txt_pos(&self, txt_pos: TextPos) -> UIResult<()> {
ensure!(
txt_pos.line < self.nr_of_lines(),
OutOfBounds {
OutOfBoundsSnafu {
index: txt_pos.line,
collection_name: "TextBuffer",
len: self.nr_of_lines(),
@ -89,7 +89,7 @@ impl TextBuffer {
ensure!(
txt_pos.column <= line_len,
OutOfBounds {
OutOfBoundsSnafu {
index: txt_pos.column,
collection_name: format!("Line in TextBuffer: {}", line_ref),
len: line_len,

View file

@ -1,4 +1,4 @@
use super::ui_error::{FileOpenFailed, FileWriteFailed, OutOfBounds, UIResult};
use super::ui_error::{FileOpenFailedSnafu, FileWriteFailedSnafu, OutOfBoundsSnafu, UIResult};
use snafu::{OptionExt, ResultExt};
use std::{fs::File, io::BufReader, path::Path, slice::SliceIndex};
@ -10,7 +10,7 @@ pub fn is_newline(char_ref: &char) -> bool {
// replace slice method that return Option with one that return Result and proper Error
pub fn slice_get<T>(index: usize, slice: &[T]) -> UIResult<&<usize as SliceIndex<[T]>>::Output> {
let elt_ref = slice.get(index).context(OutOfBounds {
let elt_ref = slice.get(index).context(OutOfBoundsSnafu {
index,
collection_name: "Slice",
len: slice.len(),
@ -25,7 +25,7 @@ pub fn slice_get_mut<T>(
) -> UIResult<&mut <usize as SliceIndex<[T]>>::Output> {
let slice_len = slice.len();
let elt_ref = slice.get_mut(index).context(OutOfBounds {
let elt_ref = slice.get_mut(index).context(OutOfBoundsSnafu {
index,
collection_name: "Slice",
len: slice_len,
@ -37,7 +37,7 @@ pub fn slice_get_mut<T>(
pub fn reader_from_path(path: &Path) -> UIResult<BufReader<File>> {
match File::open(path) {
Ok(file) => Ok(BufReader::new(file)),
Err(e) => FileOpenFailed {
Err(e) => FileOpenFailedSnafu {
path_str: path_to_string(path),
err_msg: e.to_string(),
}
@ -53,7 +53,7 @@ pub fn path_to_string(path: &Path) -> String {
}
pub fn write_to_file(path: &Path, content: &str) -> UIResult<()> {
std::fs::write(path, content).with_context(|| FileWriteFailed {
std::fs::write(path, content).with_context(|_| FileWriteFailedSnafu {
path_str: path_to_string(path),
})
}

View file

@ -25,7 +25,7 @@ bumpalo = { version = "3.8.0", features = ["collections"] }
clap = { version = "3.1.15", default-features = false, features = ["std", "color", "suggestions"] }
iced-x86 = { version = "1.15.0", default-features = false, features = ["std", "decoder", "op_code_info", "instr_info"] }
memmap2 = "0.5.3"
object = { version = "0.26.2", features = ["read", "write"] }
object = { version = "0.29.0", features = ["read", "write"] }
serde = { version = "1.0.130", features = ["derive"] }
bincode = "1.3.3"
target-lexicon = "0.12.3"

View file

@ -9,7 +9,7 @@ repository = "https://github.com/rtfeldman/roc"
version = "0.1.0"
[dependencies]
static_assertions = "0.1"
static_assertions = "1.1.0"
arrayvec = "0.7.2"
[dev-dependencies]

View file

@ -381,7 +381,7 @@ impl RocDec {
// The :019 in the following write! is computed as Self::DECIMAL_PLACES + 1. If you change
// Self::DECIMAL_PLACES, this assert should remind you to change that format string as well.
static_assertions::const_assert!(Self::DECIMAL_PLACES + 1 == 19);
static_assertions::const_assert!(RocDec::DECIMAL_PLACES + 1 == 19);
// By using the :019 format, we're guaranteeing that numbers less than 1, say 0.01234
// get their leading zeros placed in bytes for us. i.e. `string = b"0012340000000000000"`

View file

@ -7,6 +7,6 @@ edition = "2021"
description = "Utility functions used all over the code base."
[dependencies]
snafu = { version = "0.6.10", features = ["backtraces"] }
snafu = { version = "0.7.1", features = ["backtraces"] }
[dev-dependencies]

View file

@ -1,6 +1,6 @@
use snafu::OptionExt;
use std::{collections::HashMap, slice::SliceIndex};
use util_error::{IndexOfFailed, KeyNotFound, OutOfBounds, UtilResult};
use util_error::{IndexOfFailedSnafu, KeyNotFoundSnafu, OutOfBoundsSnafu, UtilResult};
pub mod util_error;
@ -9,7 +9,7 @@ pub fn map_get<'a, K: ::std::fmt::Debug + std::hash::Hash + std::cmp::Eq, V>(
hash_map: &'a HashMap<K, V>,
key: &K,
) -> UtilResult<&'a V> {
let value = hash_map.get(key).context(KeyNotFound {
let value = hash_map.get(key).context(KeyNotFoundSnafu {
key_str: format!("{:?}", key),
})?;
@ -24,7 +24,7 @@ pub fn index_of<T: ::std::fmt::Debug + std::cmp::Eq>(elt: T, slice: &[T]) -> Uti
let elt_str = format!("{:?}", elt);
let collection_str = format!("{:?}", slice);
IndexOfFailed {
IndexOfFailedSnafu {
elt_str,
collection_str,
}
@ -35,7 +35,7 @@ pub fn index_of<T: ::std::fmt::Debug + std::cmp::Eq>(elt: T, slice: &[T]) -> Uti
// replaces slice method that return Option with one that return Result and proper Error
pub fn slice_get<T>(index: usize, slice: &[T]) -> UtilResult<&<usize as SliceIndex<[T]>>::Output> {
let elt_ref = slice.get(index).context(OutOfBounds {
let elt_ref = slice.get(index).context(OutOfBoundsSnafu {
index,
collection_name: "Slice",
len: slice.len(),
@ -50,7 +50,7 @@ pub fn slice_get_mut<T>(
) -> UtilResult<&mut <usize as SliceIndex<[T]>>::Output> {
let slice_len = slice.len();
let elt_ref = slice.get_mut(index).context(OutOfBounds {
let elt_ref = slice.get_mut(index).context(OutOfBoundsSnafu {
index,
collection_name: "Slice",
len: slice_len,
@ -86,7 +86,7 @@ pub fn first_last_index_of<T: ::std::fmt::Debug + std::cmp::Eq>(
let elt_str = format!("{:?}", elt);
let collection_str = format!("{:?}", slice);
IndexOfFailed {
IndexOfFailedSnafu {
elt_str,
collection_str,
}

View file

@ -6,6 +6,6 @@ edition = "2018"
[dependencies]
thiserror = "1.0.30"
sha2 = "0.9.8"
sha2 = "0.10.2"
smallvec = "1.7.0"
typed-arena = "2.0.1"