git.delta.rocks / jrsonnet / refs/commits / 3302e3817ff5

difftreelog

feat better handling for missing feature errors

Yaroslav Bolyukin2023-07-26parent: #572693d.patch.diff
in: master

2 files changed

modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
181 #[error("can't import from virtual file")]181 #[error("can't import from virtual file")]
182 CantImportFromVirtualFile,182 CantImportFromVirtualFile,
183 #[error(183 #[error(
184 "syntax error: expected {}, got {:?}",184 "syntax error: {}",
185 // Peg has no fancier way to handle critical parsing errors https://github.com/kevinmehall/rust-peg/issues/225
185 .error.expected,186 {.error.expected.tokens().find(|t| t.starts_with("!!!")).map_or_else(|| {
187 format!(
188 "expected {}, got {:?}",
189 .error.expected,
186 .path.code().chars().nth(error.location.offset)190 .path.code().chars().nth(error.location.offset)
187 .map_or_else(|| "EOF".into(), |c| c.to_string())191 .map_or_else(|| "EOF".into(), |c| c.to_string())
192 )
193 }, |v| v[3..].into())}
188 )]194 )]
189 ImportSyntaxError {195 ImportSyntaxError {
190 path: Source,196 path: Source,
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/lib.rs
+++ b/crates/jrsonnet-parser/src/lib.rs
@@ -106,7 +106,7 @@
 					rest: rest.0,
 					end: rest.1,
 				});
-				#[cfg(not(feature = "exp-destruct"))] Err("experimental destructuring was not enabled")
+				#[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
 			}
 		pub rule destruct_object(s: &ParserSettings) -> expr::Destruct
 			= "{" _
@@ -120,13 +120,13 @@
 					fields,
 					rest,
 				});
-				#[cfg(not(feature = "exp-destruct"))] Err("experimental destructuring was not enabled")
+				#[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
 			}
 		pub rule destruct(s: &ParserSettings) -> expr::Destruct
 			= v:id() {expr::Destruct::Full(v)}
 			/ "?" {?
 				#[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Skip);
-				#[cfg(not(feature = "exp-destruct"))] Err("experimental destructuring was not enabled")
+				#[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")
 			}
 			/ arr:destruct_array(s) {arr}
 			/ obj:destruct_object(s) {obj}