Since the latest published version of rnix-parser on crates.io, the crate has undergone major changes which are only available in the git repository at the moment. This commit updates the compiler to this newer version of rnix. Most notably, the entire AST provided by rnix is now wrapped in the AST type system. As a result of this traversal is much nicer in many places, especially for things like nested attribute selection. There are a handful of smaller features missing for full feature parity with the previous version, especially handling of path literals, but PRs for these already exist in rnix-parser. Change-Id: Icde6d393067976549492b7d89c4cc49e5e575fc7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6231 Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
46 lines
961 B
Rust
46 lines
961 B
Rust
use std::fmt::Display;
|
|
|
|
#[derive(Debug)]
|
|
pub enum Error {
|
|
DuplicateAttrsKey {
|
|
key: String,
|
|
},
|
|
|
|
AttributeNotFound {
|
|
name: String,
|
|
},
|
|
|
|
TypeError {
|
|
expected: &'static str,
|
|
actual: &'static str,
|
|
},
|
|
|
|
Incomparable {
|
|
lhs: &'static str,
|
|
rhs: &'static str,
|
|
},
|
|
|
|
// Resolving a user-supplied path literal failed in some way.
|
|
PathResolution(String),
|
|
|
|
// Dynamic keys are not allowed in let.
|
|
DynamicKeyInLet(rnix::SyntaxNode),
|
|
|
|
// Unknown variable in statically known scope.
|
|
UnknownStaticVariable(rnix::ast::Ident),
|
|
|
|
// Unknown variable in dynamic scope (with, rec, ...).
|
|
UnknownDynamicVariable(String),
|
|
|
|
ParseErrors(Vec<rnix::parser::ParseError>),
|
|
|
|
AssertionFailed,
|
|
}
|
|
|
|
impl Display for Error {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
writeln!(f, "{:?}", self)
|
|
}
|
|
}
|
|
|
|
pub type EvalResult<T> = Result<T, Error>;
|