fileset: consolidate signature of invalid arguments error constructors

For the same reason as the templater changes. These FunctionCallNode types will
be extracted as utility type.
This commit is contained in:
Yuya Nishihara 2024-05-21 12:48:22 +09:00
parent 7a230395c2
commit 2143cc3686

View file

@ -122,16 +122,13 @@ impl FilesetParseError {
}
/// Unexpected number of arguments, or invalid combination of arguments.
pub(super) fn invalid_arguments(
function: &FunctionCallNode,
message: impl Into<String>,
) -> Self {
pub(super) fn invalid_arguments(name: &str, message: String, span: pest::Span<'_>) -> Self {
FilesetParseError::new(
FilesetParseErrorKind::InvalidArguments {
name: function.name.to_owned(),
message: message.into(),
name: name.to_owned(),
message,
},
function.args_span,
span,
)
}
@ -347,12 +344,13 @@ impl<'i> FunctionCallNode<'i> {
if self.args.is_empty() {
Ok(())
} else {
Err(FilesetParseError::invalid_arguments(
self,
"Expected 0 arguments",
))
Err(self.invalid_arguments("Expected 0 arguments".to_owned()))
}
}
fn invalid_arguments(&self, message: String) -> FilesetParseError {
FilesetParseError::invalid_arguments(self.name, message, self.args_span)
}
}
#[cfg(test)]