difftreelog
feat enable friendly-errors by default
in: master
4 files changed
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -8,14 +8,11 @@
edition = "2021"
[features]
-default = ["explaining-traces", "friendly-errors"]
+default = ["explaining-traces"]
# Rustc-like trace visualization
explaining-traces = ["annotate-snippets"]
# Allows library authors to throw custom errors
anyhow-error = ["anyhow"]
-# Provides helpful explaintations to errors, at cost of adding
-# more dependencies and slowing down error path
-friendly-errors = ["strsim"]
# Adds ability to build import closure in async
async-import = ["async-trait"]
@@ -45,12 +42,12 @@
rustc-hash = "1.1"
thiserror = "1.0"
+# Friendly errors
+strsim = { version = "0.10.0" }
serde = "1.0"
anyhow = { version = "1.0", optional = true }
-# Friendly errors
-strsim = { version = "0.10.0", optional = true }
# Serialized stdlib
bincode = { version = "1.3", optional = true }
# Explaining traces
crates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -51,17 +51,6 @@
self.0.sup.as_ref()
}
- #[cfg(not(feature = "friendly-errors"))]
- pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {
- Ok(self
- .0
- .bindings
- .get(&name)
- .cloned()
- .ok_or(VariableIsNotDefined(name, vec![]))?)
- }
-
- #[cfg(feature = "friendly-errors")]
pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {
use std::cmp::Ordering;
crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -1,6 +1,7 @@
use std::{
+ cmp::Ordering,
fmt::{Debug, Display},
- path::PathBuf, cmp::Ordering,
+ path::PathBuf,
};
use jrsonnet_gcmodule::Trace;
@@ -79,9 +80,8 @@
if conf < 0.8 {
continue;
}
- if field.as_str() == key.as_str() {
- panic!("looks like string pooling failure, please write any info regarding this crash to https://github.com/CertainLach/jrsonnet/issues/113, thanks!");
- }
+ assert!(field.as_str() != key.as_str(), "looks like string pooling failure, please write any info regarding this crash to https://github.com/CertainLach/jrsonnet/issues/113, thanks!");
+
heap.push((conf, field));
}
heap.sort_by(|a, b| b.0.partial_cmp(&a.0).unwrap_or(Ordering::Equal));
crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth1use std::{cmp::Ordering, rc::Rc};1use std::rc::Rc;223use jrsonnet_gcmodule::{Cc, Trace};3use jrsonnet_gcmodule::{Cc, Trace};4use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;12use crate::{12use crate::{13 arr::ArrValue,13 arr::ArrValue,14 destructure::evaluate_dest,14 destructure::evaluate_dest,15 error::{ErrorKind::*, suggest_object_fields},15 error::{suggest_object_fields, ErrorKind::*},16 evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},16 evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},17 function::{CallLocation, FuncDesc, FuncVal},17 function::{CallLocation, FuncDesc, FuncVal},18 throw,18 throw,