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.rsdiffbeforeafterboth1use std::{1use std::{2 cmp::Ordering,2 fmt::{Debug, Display},3 fmt::{Debug, Display},3 path::PathBuf, cmp::Ordering,4 path::PathBuf,4};5};566use jrsonnet_gcmodule::Trace;7use jrsonnet_gcmodule::Trace;79 if conf < 0.8 {80 if conf < 0.8 {80 continue;81 continue;81 }82 }82 if field.as_str() == key.as_str() {83 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!");83 panic!("looks like string pooling failure, please write any info regarding this crash to https://github.com/CertainLach/jrsonnet/issues/113, thanks!");8484 }85 heap.push((conf, field));85 heap.push((conf, field));86 }86 }87 heap.sort_by(|a, b| b.0.partial_cmp(&a.0).unwrap_or(Ordering::Equal));87 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,