Merge pull request #426 from Kijewski/pr-ensure_no_named_arguments

generator: fix `ensure_no_named_arguments()` test
This commit is contained in:
Guillaume Gomez 2025-05-02 11:13:29 +02:00 committed by GitHub
commit 73ba176ad5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 1 deletions

View File

@ -896,7 +896,7 @@ fn ensure_no_named_arguments(
node: Span<'_>,
) -> Result<(), CompileError> {
for arg in args {
if is_argument_placeholder(arg) {
if let Expr::NamedArgument(..) = &**arg {
return Err(ctx.generate_error(
format_args!(
"`{}` filter cannot accept named arguments",

View File

@ -0,0 +1,17 @@
use askama::Template;
mod filters {
use askama::Values;
pub fn do_nothing<'a>(s: &'a str, _: &dyn Values) -> askama::Result<&'a str> {
Ok(s)
}
}
#[derive(Template)]
#[template(source = r#"{{ a | do_nothing(absolutely = "nothing") }}"#, ext = "txt")]
struct CustomFiltersCannotTakeNamedArguments<'a> {
a: &'a str,
}
fn main() {}

View File

@ -0,0 +1,7 @@
error: `do_nothing` filter cannot accept named arguments
--> CustomFiltersCannotTakeNamedArguments.txt:1:3
"a | do_nothing(absolutely = \"nothing\") }}"
--> tests/ui/custom-filter-with-named-arg.rs:12:21
|
12 | #[template(source = r#"{{ a | do_nothing(absolutely = "nothing") }}"#, ext = "txt")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^