diff --git a/rinja_derive/src/config.rs b/rinja_derive/src/config.rs index 4272495de..da775e41a 100644 --- a/rinja_derive/src/config.rs +++ b/rinja_derive/src/config.rs @@ -213,10 +213,13 @@ impl Config { } } - Err(CompileError::no_file_info(format!( - "template {:?} not found in directories {:?}", - path, self.dirs - ))) + Err(CompileError::no_file_info( + format!( + "template {:?} not found in directories {:?}", + path, self.dirs + ), + None, + )) } } @@ -319,13 +322,15 @@ impl<'a> TryInto> for RawSyntax<'a> { syntax.comment_end, ] { if s.len() < 2 { - return Err(CompileError::no_file_info(format!( - "delimiters must be at least two characters long: {s:?}" - ))); + return Err(CompileError::no_file_info( + format!("delimiters must be at least two characters long: {s:?}"), + None, + )); } else if s.chars().any(|c| c.is_whitespace()) { - return Err(CompileError::no_file_info(format!( - "delimiters may not contain white spaces: {s:?}" - ))); + return Err(CompileError::no_file_info( + format!("delimiters may not contain white spaces: {s:?}"), + None, + )); } } @@ -335,9 +340,12 @@ impl<'a> TryInto> for RawSyntax<'a> { (syntax.expr_start, syntax.comment_start), ] { if s1.starts_with(s2) || s2.starts_with(s1) { - return Err(CompileError::no_file_info(format!( - "a delimiter may not be the prefix of another delimiter: {s1:?} vs {s2:?}", - ))); + return Err(CompileError::no_file_info( + format!( + "a delimiter may not be the prefix of another delimiter: {s1:?} vs {s2:?}", + ), + None, + )); } } @@ -358,7 +366,7 @@ impl RawConfig<'_> { #[cfg(feature = "config")] fn from_toml_str(s: &str) -> Result, CompileError> { basic_toml::from_str(s).map_err(|e| { - CompileError::no_file_info(format!("invalid TOML in {CONFIG_FILE_NAME}: {e}")) + CompileError::no_file_info(format!("invalid TOML in {CONFIG_FILE_NAME}: {e}"), None) }) } @@ -428,13 +436,13 @@ pub(crate) fn read_config_file(config_path: Option<&str>) -> Result { (&Source::Source(_), None) => { return Err(CompileError::no_file_info( "must include 'ext' attribute when using 'source' attribute", + None, )); } }; @@ -70,7 +70,7 @@ impl TemplateInput<'_> { || Ok(config.syntaxes.get(config.default_syntax).unwrap()), |s| { config.syntaxes.get(s).ok_or_else(|| { - CompileError::no_file_info(format!("attribute syntax {s} not exist")) + CompileError::no_file_info(format!("syntax `{s}` is undefined"), None) }) }, )?; @@ -90,10 +90,13 @@ impl TemplateInput<'_> { .then_some(path.as_ref()) }) .ok_or_else(|| { - CompileError::no_file_info(format!( - "no escaper defined for extension '{escaping}'. {}", - MsgValidEscapers(&config.escapers), - )) + CompileError::no_file_info( + format!( + "no escaper defined for extension '{escaping}'. {}", + MsgValidEscapers(&config.escapers), + ), + None, + ) })?; let mime_type = @@ -265,48 +268,55 @@ pub(crate) struct TemplateArgs { syntax: Option, config: Option, pub(crate) whitespace: Option, + pub(crate) span: Option, } impl TemplateArgs { pub(crate) fn new(ast: &'_ syn::DeriveInput) -> Result { // Check that an attribute called `template()` exists once and that it is // the proper type (list). + let mut span = None; let mut template_args = None; for attr in &ast.attrs { - if !attr.path().is_ident("template") { + let path = &attr.path(); + if !path.is_ident("template") { continue; } + span = Some(path.span()); match attr.parse_args_with(Punctuated::::parse_terminated) { Ok(args) if template_args.is_none() => template_args = Some(args), Ok(_) => { return Err(CompileError::no_file_info( "duplicated 'template' attribute", + span, )); } Err(e) => { - return Err(CompileError::no_file_info(format!( - "unable to parse template arguments: {e}" - ))); + return Err(CompileError::no_file_info( + format!("unable to parse template arguments: {e}"), + span, + )); } }; } let template_args = template_args - .ok_or_else(|| CompileError::no_file_info("no attribute 'template' found"))?; + .ok_or_else(|| CompileError::no_file_info("no attribute 'template' found", None))?; let mut args = Self::default(); + args.span = span; // Loop over the meta attributes and find everything that we // understand. Return a CompileError if something is not right. // `source` contains an enum that can represent `path` or `source`. - for item in template_args { + for item in &template_args { let pair = match item { syn::Meta::NameValue(pair) => pair, - _ => { - return Err(CompileError::no_file_info(format!( - "unsupported attribute argument {:?}", - item.to_token_stream() - ))); + v => { + return Err(CompileError::no_file_info( + "unsupported attribute argument", + Some(v.span()), + )); } }; @@ -315,109 +325,66 @@ impl TemplateArgs { None => unreachable!("not possible in syn::Meta::NameValue(…)"), }; - let value = match pair.value { + let value = match &pair.value { syn::Expr::Lit(lit) => lit, - syn::Expr::Group(group) => match *group.expr { + syn::Expr::Group(group) => match &*group.expr { syn::Expr::Lit(lit) => lit, - _ => { - return Err(CompileError::no_file_info(format!( - "unsupported argument value type for {ident:?}" - ))); - } - }, - _ => { - return Err(CompileError::no_file_info(format!( - "unsupported argument value type for {ident:?}" - ))); - } - }; - - if ident == "path" { - if let syn::Lit::Str(s) = value.lit { - if args.source.is_some() { + v => { return Err(CompileError::no_file_info( - "must specify 'source' or 'path', not both", + format!("unsupported argument value type for `{ident}`"), + Some(v.span()), )); } - args.source = Some(Source::Path(s.value())); - } else { + }, + v => { return Err(CompileError::no_file_info( - "template path must be string literal", + format!("unsupported argument value type for `{ident}`"), + Some(v.span()), )); } + }; + + if ident == "path" { + source_or_path(ident, value, &mut args.source, Source::Path)?; } else if ident == "source" { - if let syn::Lit::Str(s) = value.lit { - if args.source.is_some() { - return Err(CompileError::no_file_info( - "must specify 'source' or 'path', not both", - )); - } - args.source = Some(Source::Source(s.value().into())); - } else { - return Err(CompileError::no_file_info( - "template source must be string literal", - )); - } + source_or_path(ident, value, &mut args.source, |s| Source::Source(s.into()))?; } else if ident == "block" { - if let syn::Lit::Str(s) = value.lit { - args.block = Some(s.value()); - } else { - return Err(CompileError::no_file_info( - "block value must be string literal", - )); - } + set_template_str_attr(ident, value, &mut args.block)?; } else if ident == "print" { - if let syn::Lit::Str(s) = value.lit { - args.print = s.value().parse()?; + if let syn::Lit::Str(s) = &value.lit { + args.print = match s.value().as_str() { + "all" => Print::All, + "ast" => Print::Ast, + "code" => Print::Code, + "none" => Print::None, + v => { + return Err(CompileError::no_file_info( + format!("invalid value for `print` option: {v}"), + Some(s.span()), + )); + } + }; } else { return Err(CompileError::no_file_info( - "print value must be string literal", + "`print` value must be string literal", + Some(value.lit.span()), )); } } else if ident == "escape" { - if let syn::Lit::Str(s) = value.lit { - args.escaping = Some(s.value()); - } else { - return Err(CompileError::no_file_info( - "escape value must be string literal", - )); - } + set_template_str_attr(ident, value, &mut args.escaping)?; } else if ident == "ext" { - if let syn::Lit::Str(s) = value.lit { - args.ext = Some(s.value()); - } else { - return Err(CompileError::no_file_info( - "ext value must be string literal", - )); - } + set_template_str_attr(ident, value, &mut args.ext)?; } else if ident == "syntax" { - if let syn::Lit::Str(s) = value.lit { - args.syntax = Some(s.value()) - } else { - return Err(CompileError::no_file_info( - "syntax value must be string literal", - )); - } + set_template_str_attr(ident, value, &mut args.syntax)?; } else if ident == "config" { - if let syn::Lit::Str(s) = value.lit { - args.config = Some(s.value()); - } else { - return Err(CompileError::no_file_info( - "config value must be string literal", - )); - } + set_template_str_attr(ident, value, &mut args.config)?; } else if ident == "whitespace" { - if let syn::Lit::Str(s) = value.lit { - args.whitespace = Some(s.value()) - } else { - return Err(CompileError::no_file_info( - "whitespace value must be string literal", - )); - } + set_template_str_attr(ident, value, &mut args.whitespace)?; } else { - return Err(CompileError::no_file_info(format!( - "unsupported attribute key {ident:?} found" - ))); + return Err(CompileError::no_file_info( + format!("unsupported attribute key `{ident}` found"), + Some(ident.span()), + )); } } @@ -437,6 +404,49 @@ impl TemplateArgs { } } +fn source_or_path( + name: &syn::Ident, + value: &syn::ExprLit, + dest: &mut Option, + ctor: fn(String) -> Source, +) -> Result<(), CompileError> { + if dest.is_some() { + Err(CompileError::no_file_info( + "must specify `source` OR `path` exactly once", + Some(name.span()), + )) + } else if let syn::Lit::Str(s) = &value.lit { + *dest = Some(ctor(s.value())); + Ok(()) + } else { + Err(CompileError::no_file_info( + format!("`{name}` value must be string literal"), + Some(value.lit.span()), + )) + } +} + +fn set_template_str_attr( + name: &syn::Ident, + value: &syn::ExprLit, + dest: &mut Option, +) -> Result<(), CompileError> { + if dest.is_some() { + Err(CompileError::no_file_info( + format!("attribute `{name}` already set"), + Some(name.span()), + )) + } else if let syn::Lit::Str(s) = &value.lit { + *dest = Some(s.value()); + Ok(()) + } else { + Err(CompileError::no_file_info( + format!("`{name}` value must be string literal"), + Some(value.lit.span()), + )) + } +} + #[inline] fn ext_default_to_path<'a>(ext: Option<&'a str>, path: &'a Path) -> Option<&'a str> { ext.or_else(|| extension(path)) @@ -470,24 +480,6 @@ pub(crate) enum Print { None, } -impl FromStr for Print { - type Err = CompileError; - - fn from_str(s: &str) -> Result { - Ok(match s { - "all" => Print::All, - "ast" => Print::Ast, - "code" => Print::Code, - "none" => Print::None, - v => { - return Err(CompileError::no_file_info(format!( - "invalid value for print option: {v}" - ))); - } - }) - } -} - impl Default for Print { fn default() -> Self { Self::None @@ -521,13 +513,16 @@ const TEXT_TYPES: [(Mime, Mime); 7] = [ ]; fn cyclic_graph_error(dependency_graph: &[(Arc, Arc)]) -> Result<(), CompileError> { - Err(CompileError::no_file_info(format!( - "cyclic dependency in graph {:#?}", - dependency_graph - .iter() - .map(|e| format!("{:#?} --> {:#?}", e.0, e.1)) - .collect::>() - ))) + Err(CompileError::no_file_info( + format!( + "cyclic dependency in graph {:#?}", + dependency_graph + .iter() + .map(|e| format!("{:#?} --> {:#?}", e.0, e.1)) + .collect::>() + ), + None, + )) } pub(crate) fn get_template_source( diff --git a/rinja_derive/src/lib.rs b/rinja_derive/src/lib.rs index b56c89c46..0ffa14dc7 100644 --- a/rinja_derive/src/lib.rs +++ b/rinja_derive/src/lib.rs @@ -93,7 +93,10 @@ pub fn derive_template(input: TokenStream12) -> TokenStream12 { let ast = syn::parse2(input.into()).unwrap(); match build_template(&ast) { Ok(source) => source.parse().unwrap(), - Err(e) => { + Err(mut e) => { + if e.span.is_none() { + e.span = Some(ast.ident.span()); + } let mut e = e.into_compile_error(); if let Ok(source) = build_skeleton(&ast) { let source: TokenStream = source.parse().unwrap(); @@ -131,6 +134,19 @@ fn build_skeleton(ast: &syn::DeriveInput) -> Result { /// value as passed to the `template()` attribute. pub(crate) fn build_template(ast: &syn::DeriveInput) -> Result { let template_args = TemplateArgs::new(ast)?; + let mut result = build_template_inner(ast, &template_args); + if let Err(err) = &mut result { + if err.span.is_none() { + err.span = template_args.span; + } + } + result +} + +fn build_template_inner( + ast: &syn::DeriveInput, + template_args: &TemplateArgs, +) -> Result { let config_path = template_args.config_path(); let s = read_config_file(config_path)?; let config = Config::new(&s, config_path, template_args.whitespace.as_deref())?; @@ -150,10 +166,10 @@ pub(crate) fn build_template(ast: &syn::DeriveInput) -> Result Result, } impl CompileError { fn new(msg: S, file_info: Option>) -> Self { - let span = Span::call_site(); + let span = None; if let Some(FileInfo { path, @@ -231,15 +247,15 @@ impl CompileError { Self { msg, span } } - fn no_file_info(msg: S) -> Self { + fn no_file_info(msg: S, span: Option) -> Self { Self { msg: msg.to_string(), - span: Span::call_site(), + span, } } fn into_compile_error(self) -> TokenStream { - syn::Error::new(self.span, self.msg).to_compile_error() + syn::Error::new(self.span.unwrap_or_else(|| Span::call_site()), self.msg).to_compile_error() } } diff --git a/testing/tests/ui/as-primitive-type.stderr b/testing/tests/ui/as-primitive-type.stderr index 2faf9c4b5..ff7451094 100644 --- a/testing/tests/ui/as-primitive-type.stderr +++ b/testing/tests/ui/as-primitive-type.stderr @@ -4,12 +4,10 @@ error: `as` operator expects the name of a primitive type on its right-hand side 1 | {{ 1234 as 4567 }} | ^ close to this token | - --> tests/ui/as-primitive-type.rs:3:10 + --> tests/ui/as-primitive-type.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = r#"{{ 1234 as 4567 }}"#, ext = "html")] + | ^^^^^^^^ error: `as` operator expects the name of a primitive type on its right-hand side --> :1:9 @@ -17,12 +15,10 @@ error: `as` operator expects the name of a primitive type on its right-hand side 1 | {{ 1234 as ? }} | ^ close to this token | - --> tests/ui/as-primitive-type.rs:7:10 - | -7 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/as-primitive-type.rs:8:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +8 | #[template(source = r#"{{ 1234 as ? }}"#, ext = "html")] + | ^^^^^^^^ error: `as` operator expects the name of a primitive type on its right-hand side, found `u1234` --> :1:9 @@ -30,12 +26,10 @@ error: `as` operator expects the name of a primitive type on its right-hand side 1 | {{ 1234 as u1234 }} | ^ close to this token | - --> tests/ui/as-primitive-type.rs:11:10 - | -11 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/as-primitive-type.rs:12:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template(source = r#"{{ 1234 as u1234 }}"#, ext = "html")] + | ^^^^^^^^ error: `as` operator expects the name of a primitive type on its right-hand side, found `core` --> :1:9 @@ -43,12 +37,10 @@ error: `as` operator expects the name of a primitive type on its right-hand side 1 | {{ 1234 as core::primitive::u32 }} | ^ close to this token | - --> tests/ui/as-primitive-type.rs:15:10 + --> tests/ui/as-primitive-type.rs:16:3 | -15 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +16 | #[template(source = r#"{{ 1234 as core::primitive::u32 }}"#, ext = "html")] + | ^^^^^^^^ error: `as` operator expects the name of a primitive type on its right-hand side, found `int32_t` --> :1:9 @@ -56,12 +48,10 @@ error: `as` operator expects the name of a primitive type on its right-hand side 1 | {{ 1234 as int32_t }} | ^ close to this token | - --> tests/ui/as-primitive-type.rs:19:10 - | -19 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/as-primitive-type.rs:20:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +20 | #[template(source = r#"{{ 1234 as int32_t }}"#, ext = "html")] + | ^^^^^^^^ error: `as` operator expects the name of a primitive type on its right-hand side, found `int32_t` --> :1:36 @@ -69,9 +59,7 @@ error: `as` operator expects the name of a primitive type on its right-hand side 1 | {{ (1234 + 4 * 12 / 45675445 - 13) as int32_t }} | ^ close to this token | - --> tests/ui/as-primitive-type.rs:23:10 - | -23 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/as-primitive-type.rs:24:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +24 | #[template(source = r#"{{ (1234 + 4 * 12 / 45675445 - 13) as int32_t }}"#, ext = "html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/block_in_filter_block.stderr b/testing/tests/ui/block_in_filter_block.stderr index 0224aa150..b791e1a2c 100644 --- a/testing/tests/ui/block_in_filter_block.stderr +++ b/testing/tests/ui/block_in_filter_block.stderr @@ -4,9 +4,7 @@ error: cannot have a block inside a filter block 7 | {% block title %}New title{% endblock %} | ^ close to this token | - --> tests/ui/block_in_filter_block.rs:3:10 + --> tests/ui/block_in_filter_block.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/blocks_below_top_level.stderr b/testing/tests/ui/blocks_below_top_level.stderr index 138978ac1..fe201e20a 100644 --- a/testing/tests/ui/blocks_below_top_level.stderr +++ b/testing/tests/ui/blocks_below_top_level.stderr @@ -4,12 +4,10 @@ error: `extends` blocks are not allowed below top level 3 | {% extends "bla.txt" %} | ^ close to this token | - --> tests/ui/blocks_below_top_level.rs:3:10 + --> tests/ui/blocks_below_top_level.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = r#" + | ^^^^^^^^ error: `macro` blocks are not allowed below top level --> MyTemplate2.txt:3:3 @@ -17,12 +15,10 @@ error: `macro` blocks are not allowed below top level 3 | {% macro bla() %} | ^ close to this token | - --> tests/ui/blocks_below_top_level.rs:11:10 - | -11 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/blocks_below_top_level.rs:12:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template(source = r#" + | ^^^^^^^^ error: `import` blocks are not allowed below top level --> MyTemplate3.txt:3:3 @@ -30,9 +26,7 @@ error: `import` blocks are not allowed below top level 3 | {% import "bla.txt" as blue %} | ^ close to this token | - --> tests/ui/blocks_below_top_level.rs:20:10 - | -20 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/blocks_below_top_level.rs:21:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +21 | #[template(source = r#" + | ^^^^^^^^ diff --git a/testing/tests/ui/break_outside_of_loop.stderr b/testing/tests/ui/break_outside_of_loop.stderr index 6419e40ce..df9e12b6a 100644 --- a/testing/tests/ui/break_outside_of_loop.stderr +++ b/testing/tests/ui/break_outside_of_loop.stderr @@ -4,9 +4,7 @@ error: you can only `break` inside a `for` loop 1 | Have a {%break%}, have a parsing error! | ^ close to this token | - --> tests/ui/break_outside_of_loop.rs:3:10 + --> tests/ui/break_outside_of_loop.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/char_literal.stderr b/testing/tests/ui/char_literal.stderr index 83b9f640f..cdc957703 100644 --- a/testing/tests/ui/char_literal.stderr +++ b/testing/tests/ui/char_literal.stderr @@ -4,12 +4,10 @@ error: invalid character 1 | {% let s = '\a' %} | ^ close to this token | - --> tests/ui/char_literal.rs:3:10 + --> tests/ui/char_literal.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(path = "char-literals/char-literal-1.txt")] + | ^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-2.txt:1:12 @@ -17,12 +15,10 @@ error: invalid character 1 | {% let s = '\x' %} | ^ close to this token | - --> tests/ui/char_literal.rs:7:10 - | -7 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/char_literal.rs:8:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +8 | #[template(path = "char-literals/char-literal-2.txt")] + | ^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-3.txt:1:12 @@ -30,12 +26,10 @@ error: invalid character 1 | {% let s = '\x1' %} | ^ close to this token | - --> tests/ui/char_literal.rs:11:10 + --> tests/ui/char_literal.rs:12:3 | -11 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template(path = "char-literals/char-literal-3.txt")] + | ^^^^^^^^ error: must be a character in the range [\x00-\x7f] --> testing/templates/char-literals/char-literal-4.txt:1:12 @@ -43,12 +37,10 @@ error: must be a character in the range [\x00-\x7f] 1 | {% let s = '\x80' %} | ^ close to this token | - --> tests/ui/char_literal.rs:15:10 - | -15 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/char_literal.rs:16:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +16 | #[template(path = "char-literals/char-literal-4.txt")] + | ^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-5.txt:1:12 @@ -56,12 +48,10 @@ error: invalid character 1 | {% let s = '\u' %} | ^ close to this token | - --> tests/ui/char_literal.rs:19:10 + --> tests/ui/char_literal.rs:20:3 | -19 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +20 | #[template(path = "char-literals/char-literal-5.txt")] + | ^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-6.txt:1:12 @@ -69,12 +59,10 @@ error: invalid character 1 | {% let s = '\u{}' %} | ^ close to this token | - --> tests/ui/char_literal.rs:23:10 - | -23 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/char_literal.rs:24:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +24 | #[template(path = "char-literals/char-literal-6.txt")] + | ^^^^^^^^ error: unicode escape must be at most 10FFFF --> testing/templates/char-literals/char-literal-7.txt:1:12 @@ -82,12 +70,10 @@ error: unicode escape must be at most 10FFFF 1 | {% let s = '\u{110000}' %} | ^ close to this token | - --> tests/ui/char_literal.rs:27:10 + --> tests/ui/char_literal.rs:28:3 | -27 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +28 | #[template(path = "char-literals/char-literal-7.txt")] + | ^^^^^^^^ error: invalid character --> :1:12 @@ -95,9 +81,7 @@ error: invalid character 1 | {% let s = 'aaa' %} | ^ close to this token | - --> tests/ui/char_literal.rs:31:10 - | -31 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/char_literal.rs:32:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +32 | #[template(source = "{% let s = 'aaa' %}", ext = "html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/cycle.stderr b/testing/tests/ui/cycle.stderr index 67f69434b..415a5ad07 100644 --- a/testing/tests/ui/cycle.stderr +++ b/testing/tests/ui/cycle.stderr @@ -2,9 +2,7 @@ error: cyclic dependency in graph [ "\"$WORKSPACE/target/tests/trybuild/rinja_testing/templates/cycle2.html/" --> \"$WORKSPACE/target/tests/trybuild/rinja_testing/templates/cycle1.html/"", "\"$WORKSPACE/target/tests/trybuild/rinja_testing/templates/cycle1.html/" --> \"$WORKSPACE/target/tests/trybuild/rinja_testing/templates/cycle1.html/"", ] - --> tests/ui/cycle.rs:3:10 + --> tests/ui/cycle.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(path = "cycle2.html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/cycle2.stderr b/testing/tests/ui/cycle2.stderr index c0be52786..176cfea95 100644 --- a/testing/tests/ui/cycle2.stderr +++ b/testing/tests/ui/cycle2.stderr @@ -1,9 +1,7 @@ error: cyclic dependency in graph [ "\"$WORKSPACE/target/tests/trybuild/rinja_testing/templates/cycle1.html/" --> \"$WORKSPACE/target/tests/trybuild/rinja_testing/templates/cycle1.html/"", ] - --> tests/ui/cycle2.rs:3:10 + --> tests/ui/cycle2.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(path = "cycle1.html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/duplicated_template_attribute.stderr b/testing/tests/ui/duplicated_template_attribute.stderr index 4e6828c7a..c7362973a 100644 --- a/testing/tests/ui/duplicated_template_attribute.stderr +++ b/testing/tests/ui/duplicated_template_attribute.stderr @@ -1,7 +1,5 @@ error: duplicated 'template' attribute - --> tests/ui/duplicated_template_attribute.rs:3:10 + --> tests/ui/duplicated_template_attribute.rs:8:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +8 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/error_file_path.stderr b/testing/tests/ui/error_file_path.stderr index f1cdc14da..ec947b8df 100644 --- a/testing/tests/ui/error_file_path.stderr +++ b/testing/tests/ui/error_file_path.stderr @@ -4,12 +4,10 @@ error: failed to parse template source 1 | {% let 12 = 0 } | ^ close to this token | - --> tests/ui/error_file_path.rs:3:10 + --> tests/ui/error_file_path.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(path = "invalid_syntax.html")] + | ^^^^^^^^ error: failed to parse template source --> testing/templates/invalid_syntax.html:1:15 @@ -17,12 +15,10 @@ error: failed to parse template source 1 | {% let 12 = 0 } | ^ close to this token | - --> tests/ui/error_file_path.rs:7:10 - | -7 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/error_file_path.rs:8:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +8 | #[template(path = "include_invalid_syntax.html")] + | ^^^^^^^^ error: failed to parse template source --> testing/templates/invalid_syntax.html:1:15 @@ -30,9 +26,7 @@ error: failed to parse template source 1 | {% let 12 = 0 } | ^ close to this token | - --> tests/ui/error_file_path.rs:11:10 - | -11 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/error_file_path.rs:12:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template(source = r#"{% extends "include_invalid_syntax.html" %}"#, ext = "txt")] + | ^^^^^^^^ diff --git a/testing/tests/ui/excessive_nesting.stderr b/testing/tests/ui/excessive_nesting.stderr index 061554e07..5eda6a8e9 100644 --- a/testing/tests/ui/excessive_nesting.stderr +++ b/testing/tests/ui/excessive_nesting.stderr @@ -4,9 +4,7 @@ error: your template code is too deeply nested, or last expression is too comple 14 | {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} | ^ close to this token | - --> tests/ui/excessive_nesting.rs:3:10 + --> tests/ui/excessive_nesting.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/extends.stderr b/testing/tests/ui/extends.stderr index 5bf8d7e37..81d834b6e 100644 --- a/testing/tests/ui/extends.stderr +++ b/testing/tests/ui/extends.stderr @@ -4,12 +4,10 @@ error: whitespace control is not allowed on `extends` 1 | {%- extends "whatever.html" %} | ^ close to this token | - --> tests/ui/extends.rs:3:10 + --> tests/ui/extends.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ error: whitespace control is not allowed on `extends` --> :1:3 @@ -17,9 +15,7 @@ error: whitespace control is not allowed on `extends` 1 | {% extends "whatever.html" -%} | ^ close to this token | - --> tests/ui/extends.rs:10:10 - | -10 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/extends.rs:11:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +11 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/filter-recursion.stderr b/testing/tests/ui/filter-recursion.stderr index da7f5fac2..218f1c268 100644 --- a/testing/tests/ui/filter-recursion.stderr +++ b/testing/tests/ui/filter-recursion.stderr @@ -4,9 +4,7 @@ error: your template code is too deeply nested, or last expression is too comple 1 | ...A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A||A|A|AA|A... | ^ close to this token | - --> tests/ui/filter-recursion.rs:3:10 + --> tests/ui/filter-recursion.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(path = "filter-recursion.html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/filter_block_ws.stderr b/testing/tests/ui/filter_block_ws.stderr index 4afbc043b..aed27cc43 100644 --- a/testing/tests/ui/filter_block_ws.stderr +++ b/testing/tests/ui/filter_block_ws.stderr @@ -4,9 +4,7 @@ error: failed to parse template source 1 | {% filter lower|indent(2) - %} | ^ close to this token | - --> tests/ui/filter_block_ws.rs:3:10 + --> tests/ui/filter_block_ws.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{% filter lower|indent(2) - %} + | ^^^^^^^^ diff --git a/testing/tests/ui/include-a-folder.stderr b/testing/tests/ui/include-a-folder.stderr index f87ecfb5e..40d423cb6 100644 --- a/testing/tests/ui/include-a-folder.stderr +++ b/testing/tests/ui/include-a-folder.stderr @@ -4,9 +4,7 @@ error: unable to open template file '$WORKSPACE/target/tests/trybuild/rinja_test 1 | {% include "a_file_that_is_actually_a_folder.html" %} | ^ close to this token | - --> tests/ui/include-a-folder.rs:3:10 + --> tests/ui/include-a-folder.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(ext = "txt", source = r#"{% include "a_file_that_is_actually_a_folder.html" %}"#)] + | ^^^^^^^^ diff --git a/testing/tests/ui/incorrect_path.stderr b/testing/tests/ui/incorrect_path.stderr index 7f9d58c33..6d20a3ada 100644 --- a/testing/tests/ui/incorrect_path.stderr +++ b/testing/tests/ui/incorrect_path.stderr @@ -1,7 +1,5 @@ error: template "thisdoesnotexist.html" not found in directories ["$WORKSPACE/target/tests/trybuild/rinja_testing/templates"] - --> tests/ui/incorrect_path.rs:3:10 + --> tests/ui/incorrect_path.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(path = "thisdoesnotexist.html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/is_defined.stderr b/testing/tests/ui/is_defined.stderr index a7ff9019a..261a36499 100644 --- a/testing/tests/ui/is_defined.stderr +++ b/testing/tests/ui/is_defined.stderr @@ -4,12 +4,10 @@ error: `is defined` operator can only be used on variables, not on their fields 1 | {% if x.y is defined %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:3:10 + --> tests/ui/is_defined.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ error: `is defined` operator can only be used on variables --> :1:7 @@ -17,12 +15,10 @@ error: `is defined` operator can only be used on variables 1 | {% if true is defined %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:10:10 - | -10 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/is_defined.rs:11:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +11 | #[template( + | ^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -30,12 +26,10 @@ error: expected `defined` or `not defined` after `is` 1 | {% if true is %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:17:10 - | -17 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/is_defined.rs:18:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +18 | #[template( + | ^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -43,12 +37,10 @@ error: expected `defined` or `not defined` after `is` 1 | {% if x is %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:24:10 + --> tests/ui/is_defined.rs:25:3 | -24 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +25 | #[template( + | ^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -56,12 +48,10 @@ error: expected `defined` or `not defined` after `is` 1 | {% if x is blue %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:31:10 - | -31 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/is_defined.rs:32:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +32 | #[template( + | ^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -69,9 +59,7 @@ error: expected `defined` or `not defined` after `is` 1 | {% if x is blue.red %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:38:10 - | -38 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/is_defined.rs:39:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +39 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/iso646.stderr b/testing/tests/ui/iso646.stderr index c4fdfb488..1e8016f02 100644 --- a/testing/tests/ui/iso646.stderr +++ b/testing/tests/ui/iso646.stderr @@ -4,12 +4,10 @@ error: the binary AND operator is called `bitand` in rinja 1 | {{ a & b }} | ^ close to this token | - --> tests/ui/iso646.rs:3:10 + --> tests/ui/iso646.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(ext = "txt", source = "{{ a & b }}")] + | ^^^^^^^^ error: the filter operator `|` must not be preceded by any whitespace characters the binary OR operator is called `bitor` in rinja @@ -18,12 +16,10 @@ error: the filter operator `|` must not be preceded by any whitespace characters 1 | {{ a | b }} | ^ close to this token | - --> tests/ui/iso646.rs:17:10 - | -17 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/iso646.rs:18:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +18 | #[template(ext = "txt", source = "{{ a | b }}")] + | ^^^^^^^^ error: the binary XOR operator is called `xor` in rinja --> :1:7 @@ -31,9 +27,7 @@ error: the binary XOR operator is called `xor` in rinja 1 | {{ a ^ b }} | ^ close to this token | - --> tests/ui/iso646.rs:31:10 - | -31 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/iso646.rs:32:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +32 | #[template(ext = "txt", source = "{{ a ^ b }}")] + | ^^^^^^^^ diff --git a/testing/tests/ui/json-too-many-args.stderr b/testing/tests/ui/json-too-many-args.stderr index 6ad9d0164..7df4ba906 100644 --- a/testing/tests/ui/json-too-many-args.stderr +++ b/testing/tests/ui/json-too-many-args.stderr @@ -4,9 +4,7 @@ error: unexpected argument(s) in `json` filter 1 | {{ 1|json(2, 3) }} | ^ close to this token | - --> tests/ui/json-too-many-args.rs:5:10 + --> tests/ui/json-too-many-args.rs:6:3 | -5 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +6 | #[template(ext = "txt", source = "{{ 1|json(2, 3) }}")] + | ^^^^^^^^ diff --git a/testing/tests/ui/let_destructuring_has_rest.stderr b/testing/tests/ui/let_destructuring_has_rest.stderr index 64297582a..c18bbdf6f 100644 --- a/testing/tests/ui/let_destructuring_has_rest.stderr +++ b/testing/tests/ui/let_destructuring_has_rest.stderr @@ -5,12 +5,10 @@ error: unexpected `,` character after `..` 2 | {%- if let X { a, .., } = x -%}hello {{ a }}{%- endif -%} | ^ close to this token | - --> tests/ui/let_destructuring_has_rest.rs:8:10 + --> tests/ui/let_destructuring_has_rest.rs:9:3 | -8 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +9 | #[template(source = " + | ^^^^^^^^ error: expected `,` for more members, or `}` as terminator --> :2:18 @@ -18,12 +16,10 @@ error: expected `,` for more members, or `}` as terminator 2 | {%- if let X { a .. } = x -%}hello {{ a }}{%- endif -%} | ^ close to this token | - --> tests/ui/let_destructuring_has_rest.rs:16:10 - | -16 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/let_destructuring_has_rest.rs:17:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +17 | #[template(source = " + | ^^^^^^^^ error: expected member, or `}` as terminator --> :2:19 @@ -31,12 +27,10 @@ error: expected member, or `}` as terminator 2 | {%- if let X { a, 1 } = x -%}hello {{ a }}{%- endif -%} | ^ close to this token | - --> tests/ui/let_destructuring_has_rest.rs:24:10 - | -24 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/let_destructuring_has_rest.rs:25:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +25 | #[template(source = " + | ^^^^^^^^ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members @@ -45,12 +39,10 @@ error: unexpected `,` character after `..` 2 | {%- if let X { a, .., b } = x -%}hello {{ a }}{%- endif -%} | ^ close to this token | - --> tests/ui/let_destructuring_has_rest.rs:32:10 + --> tests/ui/let_destructuring_has_rest.rs:33:3 | -32 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +33 | #[template(source = " + | ^^^^^^^^ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members @@ -59,9 +51,7 @@ error: unexpected `,` character after `..` 2 | {%- if let X { .., b } = x -%}hello {{ a }}{%- endif -%} | ^ close to this token | - --> tests/ui/let_destructuring_has_rest.rs:40:10 - | -40 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/let_destructuring_has_rest.rs:41:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +41 | #[template(source = " + | ^^^^^^^^ diff --git a/testing/tests/ui/lit_on_assignment_lhs.stderr b/testing/tests/ui/lit_on_assignment_lhs.stderr index 0f0bcdaba..f9d13580f 100644 --- a/testing/tests/ui/lit_on_assignment_lhs.stderr +++ b/testing/tests/ui/lit_on_assignment_lhs.stderr @@ -4,9 +4,7 @@ error: literals are not allowed on the left-hand side of an assignment 1 | {%let 7=x%} | ^ close to this token | - --> tests/ui/lit_on_assignment_lhs.rs:3:10 + --> tests/ui/lit_on_assignment_lhs.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/loop_cycle_empty.stderr b/testing/tests/ui/loop_cycle_empty.stderr index 87cbf2032..c1c834961 100644 --- a/testing/tests/ui/loop_cycle_empty.stderr +++ b/testing/tests/ui/loop_cycle_empty.stderr @@ -4,9 +4,7 @@ error: loop.cycle(…) cannot use an empty array 1 | {% for v in values %}{{ loop.cycle([]) }}{{ v }},{% endfor %} | ^ close to this token | - --> tests/ui/loop_cycle_empty.rs:3:10 + --> tests/ui/loop_cycle_empty.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr index 89e5a30bc..0fcc539fa 100644 --- a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr +++ b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr @@ -4,9 +4,7 @@ error: loop.cycle(…) cannot use an empty array 1 | {% for v in values %}{{ loop.cycle("r", "g", "b") }}{{ v }},{% endfor %} | ^ close to this token | - --> tests/ui/loop_cycle_wrong_argument_count.rs:3:10 + --> tests/ui/loop_cycle_wrong_argument_count.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/macro-super.stderr b/testing/tests/ui/macro-super.stderr index 9c206ca3d..99146d03b 100644 --- a/testing/tests/ui/macro-super.stderr +++ b/testing/tests/ui/macro-super.stderr @@ -4,9 +4,7 @@ error: 'super' is not a valid name for a macro 1 | {%- macro super() -%}{%- endmacro -%} | ^ close to this token | - --> tests/ui/macro-super.rs:3:10 + --> tests/ui/macro-super.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{%- macro super() -%}{%- endmacro -%}", ext = "html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/macro.stderr b/testing/tests/ui/macro.stderr index 1dd23ead8..45b84638b 100644 --- a/testing/tests/ui/macro.stderr +++ b/testing/tests/ui/macro.stderr @@ -4,12 +4,10 @@ error: macro "thrice" expected 1 argument, found 2 5 | {%- call thrice(2, 3) -%} | ^ close to this token | - --> tests/ui/macro.rs:3:10 + --> tests/ui/macro.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{%- macro thrice(param) -%} + | ^^^^^^^^ error: macro "thrice" expected 2 arguments, found 0 --> InvalidNumberOfArgs2.html:5:3 @@ -17,12 +15,10 @@ error: macro "thrice" expected 2 arguments, found 0 5 | {%- call thrice() -%} | ^ close to this token | - --> tests/ui/macro.rs:11:10 - | -11 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/macro.rs:12:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template(source = "{%- macro thrice(param, param2) -%} + | ^^^^^^^^ error: macro "thrice" expected 0 arguments, found 2 --> InvalidNumberOfArgs3.html:4:3 @@ -30,9 +26,7 @@ error: macro "thrice" expected 0 arguments, found 2 4 | {%- call thrice(1, 2) -%} | ^ close to this token | - --> tests/ui/macro.rs:19:10 - | -19 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/macro.rs:20:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +20 | #[template(source = "{%- macro thrice() -%} + | ^^^^^^^^ diff --git a/testing/tests/ui/macro_named_argument.stderr b/testing/tests/ui/macro_named_argument.stderr index dd754b133..4322e04a2 100644 --- a/testing/tests/ui/macro_named_argument.stderr +++ b/testing/tests/ui/macro_named_argument.stderr @@ -4,12 +4,10 @@ error: no argument named `param3` in macro "thrice" 5 | {%- call thrice(param1=2, param3=3) -%} | ^ close to this token | - --> tests/ui/macro_named_argument.rs:3:10 + --> tests/ui/macro_named_argument.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{%- macro thrice(param1, param2) -%} + | ^^^^^^^^ error: named argument `param1` was passed more than once --> :5:16 @@ -17,12 +15,10 @@ error: named argument `param1` was passed more than once 5 | {%- call thrice(param1=2, param1=3) -%} | ^ close to this token | - --> tests/ui/macro_named_argument.rs:11:10 - | -11 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/macro_named_argument.rs:12:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template(source = "{%- macro thrice(param1, param2) -%} + | ^^^^^^^^ error: failed to parse template source --> :5:30 @@ -30,12 +26,10 @@ error: failed to parse template source 5 | {%- call thrice(3, param1=2) | filter(param1=12) -%} | ^ close to this token | - --> tests/ui/macro_named_argument.rs:20:10 - | -20 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/macro_named_argument.rs:21:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +21 | #[template(source = "{%- macro thrice(param1, param2) -%} + | ^^^^^^^^ error: named arguments must always be passed last --> :4:16 @@ -43,12 +37,10 @@ error: named arguments must always be passed last 4 | {%- call thrice(param1=2, 3) -%} | ^ close to this token | - --> tests/ui/macro_named_argument.rs:29:10 + --> tests/ui/macro_named_argument.rs:30:3 | -29 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +30 | #[template(source = "{%- macro thrice(param1, param2) -%} + | ^^^^^^^^ error: cannot have unnamed argument (`param2`) after named argument in macro "thrice" --> InvalidNamedArg5.html:4:3 @@ -56,9 +48,7 @@ error: cannot have unnamed argument (`param2`) after named argument in macro "th 4 | {%- call thrice(3, param1=2) -%} | ^ close to this token | - --> tests/ui/macro_named_argument.rs:37:10 - | -37 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/macro_named_argument.rs:38:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +38 | #[template(source = "{%- macro thrice(param1, param2) -%} + | ^^^^^^^^ diff --git a/testing/tests/ui/match_with_extra.stderr b/testing/tests/ui/match_with_extra.stderr index b68ee3666..d0aa5182b 100644 --- a/testing/tests/ui/match_with_extra.stderr +++ b/testing/tests/ui/match_with_extra.stderr @@ -4,9 +4,7 @@ error: failed to parse template source 3 | // Help, I forgot how to write comments! | ^ close to this token | - --> tests/ui/match_with_extra.rs:3:10 + --> tests/ui/match_with_extra.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/multiple_extends.stderr b/testing/tests/ui/multiple_extends.stderr index 64b5a5a21..b43e33144 100644 --- a/testing/tests/ui/multiple_extends.stderr +++ b/testing/tests/ui/multiple_extends.stderr @@ -4,9 +4,7 @@ error: multiple extend blocks found 3 | {% extends "foo.html" %} | ^ close to this token | - --> tests/ui/multiple_extends.rs:3:10 + --> tests/ui/multiple_extends.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = r#" + | ^^^^^^^^ diff --git a/testing/tests/ui/name_mismatch_endblock.stderr b/testing/tests/ui/name_mismatch_endblock.stderr index b09b199bd..7dc71e917 100644 --- a/testing/tests/ui/name_mismatch_endblock.stderr +++ b/testing/tests/ui/name_mismatch_endblock.stderr @@ -4,9 +4,7 @@ error: expected name `foo` in `endblock` tag, found `not_foo` 1 | {% block foo %}{% endblock not_foo %} | ^ close to this token | - --> tests/ui/name_mismatch_endblock.rs:3:10 + --> tests/ui/name_mismatch_endblock.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{% block foo %}{% endblock not_foo %}", ext = "html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/name_mismatch_endmacro.stderr b/testing/tests/ui/name_mismatch_endmacro.stderr index e8919b37d..6838fd30b 100644 --- a/testing/tests/ui/name_mismatch_endmacro.stderr +++ b/testing/tests/ui/name_mismatch_endmacro.stderr @@ -4,9 +4,7 @@ error: expected name `foo` in `endmacro` tag, found `not_foo` 1 | {% macro foo(arg) %} {{arg}} {% endmacro not_foo %} | ^ close to this token | - --> tests/ui/name_mismatch_endmacro.rs:3:10 + --> tests/ui/name_mismatch_endmacro.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{% macro foo(arg) %} {{arg}} {% endmacro not_foo %}", ext = "html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/no-such-escaper.stderr b/testing/tests/ui/no-such-escaper.stderr index 58e90ca73..a5f5dd246 100644 --- a/testing/tests/ui/no-such-escaper.stderr +++ b/testing/tests/ui/no-such-escaper.stderr @@ -4,17 +4,13 @@ error: invalid escaper 'latex' for `escape` filter. The available extensions are 1 | In LaTeX you write `{{text}}` like `{{text|escape("latex")}}`. | ^ close to this token | - --> tests/ui/no-such-escaper.rs:3:10 + --> tests/ui/no-such-escaper.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ error: no escaper defined for extension 'tex'. The available extensions are: "", "htm", "html", "j2", "jinja", "jinja2", "md", "none", "svg", "txt", "xml", "yml" - --> tests/ui/no-such-escaper.rs:12:10 - | -12 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/no-such-escaper.rs:13:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +13 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/no_template_attribute.stderr b/testing/tests/ui/no_template_attribute.stderr index d45d7ceb7..fa215cfc1 100644 --- a/testing/tests/ui/no_template_attribute.stderr +++ b/testing/tests/ui/no_template_attribute.stderr @@ -1,7 +1,5 @@ error: no attribute 'template' found - --> tests/ui/no_template_attribute.rs:3:10 + --> tests/ui/no_template_attribute.rs:4:8 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | struct NoTemplate; + | ^^^^^^^^^^ diff --git a/testing/tests/ui/num-suffix.stderr b/testing/tests/ui/num-suffix.stderr index e632f9320..bdecff626 100644 --- a/testing/tests/ui/num-suffix.stderr +++ b/testing/tests/ui/num-suffix.stderr @@ -4,12 +4,10 @@ error: unknown integer suffix `x` 1 | {{ 0x0x }} | ^ close to this token | - --> tests/ui/num-suffix.rs:4:10 + --> tests/ui/num-suffix.rs:5:3 | -4 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +5 | #[template( + | ^^^^^^^^ error: unknown float suffix `f127` --> :1:4 @@ -17,12 +15,10 @@ error: unknown float suffix `f127` 1 | {{ 0.0_f127 }} | ^ close to this token | - --> tests/ui/num-suffix.rs:11:10 - | -11 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/num-suffix.rs:12:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template( + | ^^^^^^^^ error: unknown number suffix `u321` --> :1:4 @@ -30,9 +26,7 @@ error: unknown number suffix `u321` 1 | {{ 654u321 }} | ^ close to this token | - --> tests/ui/num-suffix.rs:18:10 - | -18 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/num-suffix.rs:19:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +19 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/ref_deref.stderr b/testing/tests/ui/ref_deref.stderr index 509a94d66..5ac72f8e9 100644 --- a/testing/tests/ui/ref_deref.stderr +++ b/testing/tests/ui/ref_deref.stderr @@ -4,9 +4,7 @@ error: failed to parse template source 1 | {% let *x = 2 %} | ^ close to this token | - --> tests/ui/ref_deref.rs:3:10 + --> tests/ui/ref_deref.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{% let *x = 2 %}", ext = "html")] + | ^^^^^^^^ diff --git a/testing/tests/ui/space-pipe.stderr b/testing/tests/ui/space-pipe.stderr index 578eaaa97..41995ec53 100644 --- a/testing/tests/ui/space-pipe.stderr +++ b/testing/tests/ui/space-pipe.stderr @@ -5,12 +5,10 @@ error: the filter operator `|` must not be preceded by any whitespace characters 1 | {{a |lower}} | ^ close to this token | - --> tests/ui/space-pipe.rs:9:10 - | -9 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) + --> tests/ui/space-pipe.rs:10:3 + | +10 | #[template(ext = "txt", source = "{{a |lower}}")] + | ^^^^^^^^ error: the filter operator `|` must not be preceded by any whitespace characters the binary OR operator is called `bitor` in rinja @@ -19,9 +17,7 @@ error: the filter operator `|` must not be preceded by any whitespace characters 1 | {{a | lower}} | ^ close to this token | - --> tests/ui/space-pipe.rs:21:10 - | -21 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/space-pipe.rs:22:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +22 | #[template(ext = "txt", source = "{{a | lower}}")] + | ^^^^^^^^ diff --git a/testing/tests/ui/typo_in_keyword.stderr b/testing/tests/ui/typo_in_keyword.stderr index bc88cfabb..93268a62f 100644 --- a/testing/tests/ui/typo_in_keyword.stderr +++ b/testing/tests/ui/typo_in_keyword.stderr @@ -4,9 +4,7 @@ error: failed to parse template source 1 | {%for i in 1..=10%}{{i}}{%endfo%} | ^ close to this token | - --> tests/ui/typo_in_keyword.rs:3:10 + --> tests/ui/typo_in_keyword.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template( + | ^^^^^^^^ diff --git a/testing/tests/ui/unclosed-nodes.stderr b/testing/tests/ui/unclosed-nodes.stderr index ed63f6eb6..e66393db6 100644 --- a/testing/tests/ui/unclosed-nodes.stderr +++ b/testing/tests/ui/unclosed-nodes.stderr @@ -4,12 +4,10 @@ error: unclosed expression, missing "}}" 1 | {{ expr | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:3:10 + --> tests/ui/unclosed-nodes.rs:4:3 | -3 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +4 | #[template(source = "{{ expr", ext = "txt")] + | ^^^^^^^^ error: unclosed expression, missing "}}" --> :1:1 @@ -17,12 +15,10 @@ error: unclosed expression, missing "}}" 1 | {{ expr | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:7:10 - | -7 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:8:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +8 | #[template(source = "{{ expr ", ext = "txt")] + | ^^^^^^^^ error: unclosed expression, missing "}}" --> :1:1 @@ -30,12 +26,10 @@ error: unclosed expression, missing "}}" 1 | {{ expr - | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:11:10 - | -11 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:12:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +12 | #[template(source = "{{ expr -", ext = "txt")] + | ^^^^^^^^ error: failed to parse template source --> :1:10 @@ -43,12 +37,10 @@ error: failed to parse template source 1 | {{ expr -} | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:15:10 + --> tests/ui/unclosed-nodes.rs:16:3 | -15 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +16 | #[template(source = "{{ expr -}", ext = "txt")] + | ^^^^^^^^ error: unclosed block, missing "%}" --> :1:1 @@ -56,12 +48,10 @@ error: unclosed block, missing "%}" 1 | {% let x | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:19:10 - | -19 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:20:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +20 | #[template(source = "{% let x", ext = "txt")] + | ^^^^^^^^ error: unclosed block, missing "%}" --> :1:1 @@ -69,12 +59,10 @@ error: unclosed block, missing "%}" 1 | {% let x | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:23:10 - | -23 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:24:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +24 | #[template(source = "{% let x ", ext = "txt")] + | ^^^^^^^^ error: unclosed block, missing "%}" --> :1:1 @@ -82,12 +70,10 @@ error: unclosed block, missing "%}" 1 | {% let x - | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:27:10 + --> tests/ui/unclosed-nodes.rs:28:3 | -27 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +28 | #[template(source = "{% let x -", ext = "txt")] + | ^^^^^^^^ error: failed to parse template source --> :1:11 @@ -95,12 +81,10 @@ error: failed to parse template source 1 | {% let x -% | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:31:10 - | -31 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:32:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +32 | #[template(source = "{% let x -%", ext = "txt")] + | ^^^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -108,12 +92,10 @@ error: unclosed comment, missing "#}" 1 | {# comment | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:35:10 - | -35 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:36:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +36 | #[template(source = "{# comment", ext = "txt")] + | ^^^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -121,12 +103,10 @@ error: unclosed comment, missing "#}" 1 | {# comment | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:39:10 + --> tests/ui/unclosed-nodes.rs:40:3 | -39 | #[derive(Template)] - | ^^^^^^^^ - | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +40 | #[template(source = "{# comment ", ext = "txt")] + | ^^^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -134,12 +114,10 @@ error: unclosed comment, missing "#}" 1 | {# comment - | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:43:10 - | -43 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:44:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +44 | #[template(source = "{# comment -", ext = "txt")] + | ^^^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -147,9 +125,7 @@ error: unclosed comment, missing "#}" 1 | {# comment -# | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:47:10 - | -47 | #[derive(Template)] - | ^^^^^^^^ + --> tests/ui/unclosed-nodes.rs:48:3 | - = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) +48 | #[template(source = "{# comment -#", ext = "txt")] + | ^^^^^^^^