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.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.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.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,