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.rsdiffbeforeafterboth51 self.0.sup.as_ref()51 self.0.sup.as_ref()52 }52 }535354 #[cfg(not(feature = "friendly-errors"))]55 pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {56 Ok(self57 .058 .bindings59 .get(&name)60 .cloned()61 .ok_or(VariableIsNotDefined(name, vec![]))?)62 }6364 #[cfg(feature = "friendly-errors")]65 pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {54 pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {66 use std::cmp::Ordering;55 use std::cmp::Ordering;6756crates/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.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -1,4 +1,4 @@
-use std::{cmp::Ordering, rc::Rc};
+use std::rc::Rc;
use jrsonnet_gcmodule::{Cc, Trace};
use jrsonnet_interner::IStr;
@@ -12,7 +12,7 @@
use crate::{
arr::ArrValue,
destructure::evaluate_dest,
- error::{ErrorKind::*, suggest_object_fields},
+ error::{suggest_object_fields, ErrorKind::*},
evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},
function::{CallLocation, FuncDesc, FuncVal},
throw,