difftreelog
feat better handling for missing feature errors
in: master
2 files changed
crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth181 #[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/225185 .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,crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth106 rest: rest.0,106 rest: rest.0,107 end: rest.1,107 end: rest.1,108 });108 });109 #[cfg(not(feature = "exp-destruct"))] Err("experimental destructuring was not enabled")109 #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")110 }110 }111 pub rule destruct_object(s: &ParserSettings) -> expr::Destruct111 pub rule destruct_object(s: &ParserSettings) -> expr::Destruct112 = "{" _112 = "{" _120 fields,120 fields,121 rest,121 rest,122 });122 });123 #[cfg(not(feature = "exp-destruct"))] Err("experimental destructuring was not enabled")123 #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")124 }124 }125 pub rule destruct(s: &ParserSettings) -> expr::Destruct125 pub rule destruct(s: &ParserSettings) -> expr::Destruct126 = v:id() {expr::Destruct::Full(v)}126 = v:id() {expr::Destruct::Full(v)}127 / "?" {?127 / "?" {?128 #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Skip);128 #[cfg(feature = "exp-destruct")] return Ok(expr::Destruct::Skip);129 #[cfg(not(feature = "exp-destruct"))] Err("experimental destructuring was not enabled")129 #[cfg(not(feature = "exp-destruct"))] Err("!!!experimental destructuring was not enabled")130 }130 }131 / arr:destruct_array(s) {arr}131 / arr:destruct_array(s) {arr}132 / obj:destruct_object(s) {obj}132 / obj:destruct_object(s) {obj}