difftreelog
feat enable friendly-errors by default
in: master
4 files changed
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth8edition = "2021"8edition = "2021"9910[features]10[features]11default = ["explaining-traces", "friendly-errors"]11default = ["explaining-traces"]12# Rustc-like trace visualization12# Rustc-like trace visualization13explaining-traces = ["annotate-snippets"]13explaining-traces = ["annotate-snippets"]14# Allows library authors to throw custom errors14# Allows library authors to throw custom errors15anyhow-error = ["anyhow"]15anyhow-error = ["anyhow"]16# Provides helpful explaintations to errors, at cost of adding17# more dependencies and slowing down error path18friendly-errors = ["strsim"]19# Adds ability to build import closure in async16# Adds ability to build import closure in async20async-import = ["async-trait"]17async-import = ["async-trait"]211845rustc-hash = "1.1"42rustc-hash = "1.1"464347thiserror = "1.0"44thiserror = "1.0"45# Friendly errors46strsim = { version = "0.10.0" }484749serde = "1.0"48serde = "1.0"504951anyhow = { version = "1.0", optional = true }50anyhow = { version = "1.0", optional = true }52# Friendly errors53strsim = { version = "0.10.0", optional = true }54# Serialized stdlib51# Serialized stdlib55bincode = { version = "1.3", optional = true }52bincode = { version = "1.3", optional = true }56# Explaining traces53# Explaining tracescrates/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.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,