diff --git a/rinja_derive/src/config.rs b/rinja_derive/src/config.rs index 8defbf790..e020dd6c1 100644 --- a/rinja_derive/src/config.rs +++ b/rinja_derive/src/config.rs @@ -198,6 +198,7 @@ impl Config { &self, path: &str, start_at: Option<&Path>, + file_info: Option>, ) -> Result, CompileError> { if let Some(root) = start_at { let relative = root.with_file_name(path); @@ -213,12 +214,12 @@ impl Config { } } - Err(CompileError::no_file_info( + Err(CompileError::new( format!( "template {:?} not found in directories {:?}", path, self.dirs ), - None, + file_info, )) } } @@ -500,8 +501,10 @@ mod tests { #[test] fn find_absolute() { let config = Config::new("", None, None).unwrap(); - let root = config.find_template("a.html", None).unwrap(); - let path = config.find_template("sub/b.html", Some(&root)).unwrap(); + let root = config.find_template("a.html", None, None).unwrap(); + let path = config + .find_template("sub/b.html", Some(&root), None) + .unwrap(); assert_eq_rooted(&path, "sub/b.html"); } @@ -509,23 +512,25 @@ mod tests { #[should_panic] fn find_relative_nonexistent() { let config = Config::new("", None, None).unwrap(); - let root = config.find_template("a.html", None).unwrap(); - config.find_template("c.html", Some(&root)).unwrap(); + let root = config.find_template("a.html", None, None).unwrap(); + config.find_template("c.html", Some(&root), None).unwrap(); } #[test] fn find_relative() { let config = Config::new("", None, None).unwrap(); - let root = config.find_template("sub/b.html", None).unwrap(); - let path = config.find_template("c.html", Some(&root)).unwrap(); + let root = config.find_template("sub/b.html", None, None).unwrap(); + let path = config.find_template("c.html", Some(&root), None).unwrap(); assert_eq_rooted(&path, "sub/c.html"); } #[test] fn find_relative_sub() { let config = Config::new("", None, None).unwrap(); - let root = config.find_template("sub/b.html", None).unwrap(); - let path = config.find_template("sub1/d.html", Some(&root)).unwrap(); + let root = config.find_template("sub/b.html", None, None).unwrap(); + let path = config + .find_template("sub1/d.html", Some(&root), None) + .unwrap(); assert_eq_rooted(&path, "sub/sub1/d.html"); } diff --git a/rinja_derive/src/generator.rs b/rinja_derive/src/generator.rs index b497dd967..f3f4ff77e 100644 --- a/rinja_derive/src/generator.rs +++ b/rinja_derive/src/generator.rs @@ -16,7 +16,7 @@ use crate::config::WhitespaceHandling; use crate::heritage::{Context, Heritage}; use crate::html::write_escaped_str; use crate::input::{Source, TemplateInput}; -use crate::{CompileError, MsgValidEscapers, CRATE}; +use crate::{CompileError, FileInfo, MsgValidEscapers, CRATE}; #[derive(Clone, Copy, PartialEq, Debug)] enum EvaluatedResult { @@ -78,7 +78,13 @@ impl<'a> Generator<'a> { pub(crate) fn build(mut self, ctx: &Context<'a>) -> Result { let mut buf = Buffer::new(); - self.impl_template(ctx, &mut buf)?; + if let Err(mut err) = self.impl_template(ctx, &mut buf) { + if err.span.is_some() { + err.span = self.input.source_span; + } + return Err(err); + } + self.impl_display(&mut buf); #[cfg(feature = "with-actix-web")] @@ -907,14 +913,15 @@ impl<'a> Generator<'a> { &mut self, ctx: &Context<'a>, buf: &mut Buffer, - i: &'a Include<'_>, + i: &'a WithSpan<'_, Include<'_>>, ) -> Result { self.flush_ws(i.ws); self.write_buf_writable(ctx, buf)?; + let file_info = ctx.path.map(|path| FileInfo::of(i, path, ctx.parsed)); let path = self .input .config - .find_template(i.path, Some(&self.input.path))?; + .find_template(i.path, Some(&self.input.path), file_info)?; // We clone the context of the child in order to preserve their macros and imports. // But also add all the imports and macros from this template that don't override the diff --git a/rinja_derive/src/heritage.rs b/rinja_derive/src/heritage.rs index 535bee0dd..17f57402a 100644 --- a/rinja_derive/src/heritage.rs +++ b/rinja_derive/src/heritage.rs @@ -44,8 +44,8 @@ pub(crate) struct Context<'a> { pub(crate) blocks: HashMap<&'a str, &'a BlockDef<'a>>, pub(crate) macros: HashMap<&'a str, &'a Macro<'a>>, pub(crate) imports: HashMap<&'a str, Arc>, - path: Option<&'a Path>, - parsed: &'a Parsed, + pub(crate) path: Option<&'a Path>, + pub(crate) parsed: &'a Parsed, } impl Context<'_> { @@ -84,7 +84,11 @@ impl Context<'_> { Some(FileInfo::of(e, path, parsed)), )); } - extends = Some(config.find_template(e.path, Some(path))?); + extends = Some(config.find_template( + e.path, + Some(path), + Some(FileInfo::of(e, &path, &parsed)), + )?); } Node::Macro(m) => { ensure_top(top, m, path, parsed, "macro")?; @@ -92,7 +96,11 @@ impl Context<'_> { } Node::Import(import) => { ensure_top(top, import, path, parsed, "import")?; - let path = config.find_template(import.path, Some(path))?; + let path = config.find_template( + import.path, + Some(path), + Some(FileInfo::of(import, &path, &parsed)), + )?; imports.insert(import.scope, path); } Node::BlockDef(b) => { diff --git a/rinja_derive/src/input.rs b/rinja_derive/src/input.rs index e3f11c304..ff86f16f6 100644 --- a/rinja_derive/src/input.rs +++ b/rinja_derive/src/input.rs @@ -7,6 +7,7 @@ use std::sync::{Arc, OnceLock}; use mime::Mime; use once_map::OnceMap; use parser::{Node, Parsed}; +use proc_macro2::Span; use syn::punctuated::Punctuated; use syn::spanned::Spanned; @@ -18,6 +19,7 @@ pub(crate) struct TemplateInput<'a> { pub(crate) config: &'a Config, pub(crate) syntax: &'a SyntaxAndCache<'a>, pub(crate) source: &'a Source, + pub(crate) source_span: Option, pub(crate) block: Option<&'a str>, pub(crate) print: Print, pub(crate) escaper: &'a str, @@ -42,6 +44,7 @@ impl TemplateInput<'_> { print, escaping, ext, + ext_span, syntax, .. } = args; @@ -49,11 +52,11 @@ impl TemplateInput<'_> { // Validate the `source` and `ext` value together, since they are // related. In case `source` was used instead of `path`, the value // of `ext` is merged into a synthetic `path` value here. - let source = source + let &(ref source, source_span) = source .as_ref() .expect("template path or source not found in attributes"); let path = match (&source, &ext) { - (Source::Path(path), _) => config.find_template(path, None)?, + (Source::Path(path), _) => config.find_template(path, None, None)?, (&Source::Source(_), Some(ext)) => { PathBuf::from(format!("{}.{}", ast.ident, ext)).into() } @@ -95,7 +98,7 @@ impl TemplateInput<'_> { "no escaper defined for extension '{escaping}'. {}", MsgValidEscapers(&config.escapers), ), - None, + *ext_span, ) })?; @@ -127,6 +130,7 @@ impl TemplateInput<'_> { config, syntax, source, + source_span, block: block.as_deref(), print: *print, escaper, @@ -189,7 +193,11 @@ impl TemplateInput<'_> { match n { Node::Extends(extends) if top => { - let extends = self.config.find_template(extends.path, Some(&path))?; + let extends = self.config.find_template( + extends.path, + Some(&path), + Some(FileInfo::of(extends, &path, &parsed)), + )?; let dependency_path = (path.clone(), extends.clone()); if path == extends { // We add the path into the graph to have a better looking error. @@ -205,14 +213,22 @@ impl TemplateInput<'_> { nested.push(&m.nodes); } Node::Import(import) if top => { - let import = self.config.find_template(import.path, Some(&path))?; + let import = self.config.find_template( + import.path, + Some(&path), + Some(FileInfo::of(import, &path, &parsed)), + )?; add_to_check(import)?; } Node::FilterBlock(f) => { nested.push(&f.nodes); } Node::Include(include) => { - let include = self.config.find_template(include.path, Some(&path))?; + let include = self.config.find_template( + include.path, + Some(&path), + Some(FileInfo::of(include, &path, &parsed)), + )?; add_to_check(include)?; } Node::BlockDef(b) => { @@ -260,15 +276,16 @@ impl TemplateInput<'_> { #[derive(Debug, Default)] pub(crate) struct TemplateArgs { - source: Option, + pub(crate) source: Option<(Source, Option)>, block: Option, print: Print, escaping: Option, ext: Option, + ext_span: Option, syntax: Option, config: Option, pub(crate) whitespace: Option, - pub(crate) span: Option, + pub(crate) template_span: Option, } impl TemplateArgs { @@ -305,7 +322,7 @@ impl TemplateArgs { .ok_or_else(|| CompileError::no_file_info("no attribute 'template' found", None))?; let mut args = Self { - span, + template_span: span, ..Self::default() }; // Loop over the meta attributes and find everything that we @@ -348,6 +365,7 @@ impl TemplateArgs { if ident == "path" { source_or_path(ident, value, &mut args.source, Source::Path)?; + args.ext_span = Some(ident.span()); } else if ident == "source" { source_or_path(ident, value, &mut args.source, |s| Source::Source(s.into()))?; } else if ident == "block" { @@ -376,6 +394,7 @@ impl TemplateArgs { set_template_str_attr(ident, value, &mut args.escaping)?; } else if ident == "ext" { set_template_str_attr(ident, value, &mut args.ext)?; + args.ext_span = Some(ident.span()); } else if ident == "syntax" { set_template_str_attr(ident, value, &mut args.syntax)?; } else if ident == "config" { @@ -395,7 +414,7 @@ impl TemplateArgs { pub(crate) fn fallback() -> Self { Self { - source: Some(Source::Source("".into())), + source: Some((Source::Source("".into()), None)), ext: Some("txt".to_string()), ..Self::default() } @@ -409,7 +428,7 @@ impl TemplateArgs { fn source_or_path( name: &syn::Ident, value: &syn::ExprLit, - dest: &mut Option, + dest: &mut Option<(Source, Option)>, ctor: fn(String) -> Source, ) -> Result<(), CompileError> { if dest.is_some() { @@ -418,7 +437,7 @@ fn source_or_path( Some(name.span()), )) } else if let syn::Lit::Str(s) = &value.lit { - *dest = Some(ctor(s.value())); + *dest = Some((ctor(s.value()), Some(name.span()))); Ok(()) } else { Err(CompileError::no_file_info( @@ -611,7 +630,7 @@ mod tests { #[test] fn get_source() { let path = Config::new("", None, None) - .and_then(|config| config.find_template("b.html", None)) + .and_then(|config| config.find_template("b.html", None, None)) .unwrap(); assert_eq!(get_template_source(&path, None).unwrap(), "bar".into()); } diff --git a/rinja_derive/src/lib.rs b/rinja_derive/src/lib.rs index 47599cfc0..7dbd43a5e 100644 --- a/rinja_derive/src/lib.rs +++ b/rinja_derive/src/lib.rs @@ -137,7 +137,11 @@ pub(crate) fn build_template(ast: &syn::DeriveInput) -> Result tests/ui/as-primitive-type.rs:4:3 + --> tests/ui/as-primitive-type.rs:4:12 | 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 @@ -15,10 +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:8:3 + --> tests/ui/as-primitive-type.rs:8:12 | 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 @@ -26,10 +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:12:3 + --> tests/ui/as-primitive-type.rs:12:12 | 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 @@ -37,10 +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:16:3 + --> tests/ui/as-primitive-type.rs:16:12 | 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 @@ -48,10 +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:20:3 + --> tests/ui/as-primitive-type.rs:20:12 | 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 @@ -59,7 +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:24:3 + --> tests/ui/as-primitive-type.rs:24:12 | 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 b791e1a2c..3b96494f0 100644 --- a/testing/tests/ui/block_in_filter_block.stderr +++ b/testing/tests/ui/block_in_filter_block.stderr @@ -4,7 +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:4:3 + --> tests/ui/block_in_filter_block.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = r#"{% extends "html-base.html" %} + | ^^^^^^ diff --git a/testing/tests/ui/blocks_below_top_level.stderr b/testing/tests/ui/blocks_below_top_level.stderr index fe201e20a..ccb5c1870 100644 --- a/testing/tests/ui/blocks_below_top_level.stderr +++ b/testing/tests/ui/blocks_below_top_level.stderr @@ -4,10 +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:4:3 + --> tests/ui/blocks_below_top_level.rs:4:12 | 4 | #[template(source = r#" - | ^^^^^^^^ + | ^^^^^^ error: `macro` blocks are not allowed below top level --> MyTemplate2.txt:3:3 @@ -15,10 +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:12:3 + --> tests/ui/blocks_below_top_level.rs:12:12 | 12 | #[template(source = r#" - | ^^^^^^^^ + | ^^^^^^ error: `import` blocks are not allowed below top level --> MyTemplate3.txt:3:3 @@ -26,7 +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:21:3 + --> tests/ui/blocks_below_top_level.rs:21:12 | 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 df9e12b6a..d1f1da8a6 100644 --- a/testing/tests/ui/break_outside_of_loop.stderr +++ b/testing/tests/ui/break_outside_of_loop.stderr @@ -4,7 +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:4:3 + --> tests/ui/break_outside_of_loop.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = "Have a {%break%}, have a parsing error!", + | ^^^^^^ diff --git a/testing/tests/ui/char_literal.stderr b/testing/tests/ui/char_literal.stderr index cdc957703..03d3c3aaa 100644 --- a/testing/tests/ui/char_literal.stderr +++ b/testing/tests/ui/char_literal.stderr @@ -4,10 +4,10 @@ error: invalid character 1 | {% let s = '\a' %} | ^ close to this token | - --> tests/ui/char_literal.rs:4:3 + --> tests/ui/char_literal.rs:4:12 | 4 | #[template(path = "char-literals/char-literal-1.txt")] - | ^^^^^^^^ + | ^^^^ error: invalid character --> testing/templates/char-literals/char-literal-2.txt:1:12 @@ -15,10 +15,10 @@ error: invalid character 1 | {% let s = '\x' %} | ^ close to this token | - --> tests/ui/char_literal.rs:8:3 + --> tests/ui/char_literal.rs:8:12 | 8 | #[template(path = "char-literals/char-literal-2.txt")] - | ^^^^^^^^ + | ^^^^ error: invalid character --> testing/templates/char-literals/char-literal-3.txt:1:12 @@ -26,10 +26,10 @@ error: invalid character 1 | {% let s = '\x1' %} | ^ close to this token | - --> tests/ui/char_literal.rs:12:3 + --> tests/ui/char_literal.rs:12:12 | 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 @@ -37,10 +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:16:3 + --> tests/ui/char_literal.rs:16:12 | 16 | #[template(path = "char-literals/char-literal-4.txt")] - | ^^^^^^^^ + | ^^^^ error: invalid character --> testing/templates/char-literals/char-literal-5.txt:1:12 @@ -48,10 +48,10 @@ error: invalid character 1 | {% let s = '\u' %} | ^ close to this token | - --> tests/ui/char_literal.rs:20:3 + --> tests/ui/char_literal.rs:20:12 | 20 | #[template(path = "char-literals/char-literal-5.txt")] - | ^^^^^^^^ + | ^^^^ error: invalid character --> testing/templates/char-literals/char-literal-6.txt:1:12 @@ -59,10 +59,10 @@ error: invalid character 1 | {% let s = '\u{}' %} | ^ close to this token | - --> tests/ui/char_literal.rs:24:3 + --> tests/ui/char_literal.rs:24:12 | 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 @@ -70,10 +70,10 @@ error: unicode escape must be at most 10FFFF 1 | {% let s = '\u{110000}' %} | ^ close to this token | - --> tests/ui/char_literal.rs:28:3 + --> tests/ui/char_literal.rs:28:12 | 28 | #[template(path = "char-literals/char-literal-7.txt")] - | ^^^^^^^^ + | ^^^^ error: invalid character --> :1:12 @@ -81,7 +81,7 @@ error: invalid character 1 | {% let s = 'aaa' %} | ^ close to this token | - --> tests/ui/char_literal.rs:32:3 + --> tests/ui/char_literal.rs:32:12 | 32 | #[template(source = "{% let s = 'aaa' %}", ext = "html")] - | ^^^^^^^^ + | ^^^^^^ diff --git a/testing/tests/ui/cycle.stderr b/testing/tests/ui/cycle.stderr index 415a5ad07..ddff9a7dc 100644 --- a/testing/tests/ui/cycle.stderr +++ b/testing/tests/ui/cycle.stderr @@ -2,7 +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:4:3 + --> tests/ui/cycle.rs:4:12 | 4 | #[template(path = "cycle2.html")] - | ^^^^^^^^ + | ^^^^ diff --git a/testing/tests/ui/cycle2.stderr b/testing/tests/ui/cycle2.stderr index 176cfea95..c5415fbbb 100644 --- a/testing/tests/ui/cycle2.stderr +++ b/testing/tests/ui/cycle2.stderr @@ -1,7 +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:4:3 + --> tests/ui/cycle2.rs:4:12 | 4 | #[template(path = "cycle1.html")] - | ^^^^^^^^ + | ^^^^ diff --git a/testing/tests/ui/error_file_path.stderr b/testing/tests/ui/error_file_path.stderr index ec947b8df..32eaeaa03 100644 --- a/testing/tests/ui/error_file_path.stderr +++ b/testing/tests/ui/error_file_path.stderr @@ -4,10 +4,10 @@ error: failed to parse template source 1 | {% let 12 = 0 } | ^ close to this token | - --> tests/ui/error_file_path.rs:4:3 + --> tests/ui/error_file_path.rs:4:12 | 4 | #[template(path = "invalid_syntax.html")] - | ^^^^^^^^ + | ^^^^ error: failed to parse template source --> testing/templates/invalid_syntax.html:1:15 @@ -15,10 +15,10 @@ error: failed to parse template source 1 | {% let 12 = 0 } | ^ close to this token | - --> tests/ui/error_file_path.rs:8:3 + --> tests/ui/error_file_path.rs:8:12 | 8 | #[template(path = "include_invalid_syntax.html")] - | ^^^^^^^^ + | ^^^^ error: failed to parse template source --> testing/templates/invalid_syntax.html:1:15 @@ -26,7 +26,7 @@ error: failed to parse template source 1 | {% let 12 = 0 } | ^ close to this token | - --> tests/ui/error_file_path.rs:12:3 + --> tests/ui/error_file_path.rs:12:12 | 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 5eda6a8e9..4292e3f64 100644 --- a/testing/tests/ui/excessive_nesting.stderr +++ b/testing/tests/ui/excessive_nesting.stderr @@ -4,7 +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:4:3 + --> tests/ui/excessive_nesting.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = " + | ^^^^^^ diff --git a/testing/tests/ui/extends.stderr b/testing/tests/ui/extends.stderr index 81d834b6e..81a6d6e13 100644 --- a/testing/tests/ui/extends.stderr +++ b/testing/tests/ui/extends.stderr @@ -4,10 +4,10 @@ error: whitespace control is not allowed on `extends` 1 | {%- extends "whatever.html" %} | ^ close to this token | - --> tests/ui/extends.rs:4:3 + --> tests/ui/extends.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = r#"{%- extends "whatever.html" %}"#, + | ^^^^^^ error: whitespace control is not allowed on `extends` --> :1:3 @@ -15,7 +15,7 @@ error: whitespace control is not allowed on `extends` 1 | {% extends "whatever.html" -%} | ^ close to this token | - --> tests/ui/extends.rs:11:3 + --> tests/ui/extends.rs:12:5 | -11 | #[template( - | ^^^^^^^^ +12 | source = r#"{% extends "whatever.html" -%}"#, + | ^^^^^^ diff --git a/testing/tests/ui/filter-recursion.stderr b/testing/tests/ui/filter-recursion.stderr index 218f1c268..c27777b0d 100644 --- a/testing/tests/ui/filter-recursion.stderr +++ b/testing/tests/ui/filter-recursion.stderr @@ -4,7 +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:4:3 + --> tests/ui/filter-recursion.rs:4:12 | 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 aed27cc43..157572844 100644 --- a/testing/tests/ui/filter_block_ws.stderr +++ b/testing/tests/ui/filter_block_ws.stderr @@ -4,7 +4,7 @@ error: failed to parse template source 1 | {% filter lower|indent(2) - %} | ^ close to this token | - --> tests/ui/filter_block_ws.rs:4:3 + --> tests/ui/filter_block_ws.rs:4:12 | 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 40d423cb6..24736d40b 100644 --- a/testing/tests/ui/include-a-folder.stderr +++ b/testing/tests/ui/include-a-folder.stderr @@ -4,7 +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:4:3 + --> tests/ui/include-a-folder.rs:4:25 | 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 6d20a3ada..c57f49aa3 100644 --- a/testing/tests/ui/incorrect_path.stderr +++ b/testing/tests/ui/incorrect_path.stderr @@ -1,5 +1,5 @@ error: template "thisdoesnotexist.html" not found in directories ["$WORKSPACE/target/tests/trybuild/rinja_testing/templates"] - --> tests/ui/incorrect_path.rs:4:3 + --> tests/ui/incorrect_path.rs:4:12 | 4 | #[template(path = "thisdoesnotexist.html")] - | ^^^^^^^^ + | ^^^^ diff --git a/testing/tests/ui/is_defined.stderr b/testing/tests/ui/is_defined.stderr index 261a36499..6e5ef2e3b 100644 --- a/testing/tests/ui/is_defined.stderr +++ b/testing/tests/ui/is_defined.stderr @@ -4,10 +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:4:3 + --> tests/ui/is_defined.rs:6:5 | -4 | #[template( - | ^^^^^^^^ +6 | source = r#"{% if x.y is defined %}{% endif %}"#, + | ^^^^^^ error: `is defined` operator can only be used on variables --> :1:7 @@ -15,10 +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:11:3 + --> tests/ui/is_defined.rs:13:5 | -11 | #[template( - | ^^^^^^^^ +13 | source = r#"{% if true is defined %}{% endif %}"#, + | ^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -26,10 +26,10 @@ error: expected `defined` or `not defined` after `is` 1 | {% if true is %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:18:3 + --> tests/ui/is_defined.rs:20:5 | -18 | #[template( - | ^^^^^^^^ +20 | source = r#"{% if true is %}{% endif %}"#, + | ^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -37,10 +37,10 @@ error: expected `defined` or `not defined` after `is` 1 | {% if x is %}{% endif %} | ^ close to this token | - --> tests/ui/is_defined.rs:25:3 + --> tests/ui/is_defined.rs:27:5 | -25 | #[template( - | ^^^^^^^^ +27 | source = r#"{% if x is %}{% endif %}"#, + | ^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -48,10 +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:32:3 + --> tests/ui/is_defined.rs:34:5 | -32 | #[template( - | ^^^^^^^^ +34 | source = r#"{% if x is blue %}{% endif %}"#, + | ^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:7 @@ -59,7 +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:39:3 + --> tests/ui/is_defined.rs:41:5 | -39 | #[template( - | ^^^^^^^^ +41 | source = r#"{% if x is blue.red %}{% endif %}"#, + | ^^^^^^ diff --git a/testing/tests/ui/iso646.stderr b/testing/tests/ui/iso646.stderr index 1e8016f02..8a7874b78 100644 --- a/testing/tests/ui/iso646.stderr +++ b/testing/tests/ui/iso646.stderr @@ -4,10 +4,10 @@ error: the binary AND operator is called `bitand` in rinja 1 | {{ a & b }} | ^ close to this token | - --> tests/ui/iso646.rs:4:3 + --> tests/ui/iso646.rs:4:25 | 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 @@ -16,10 +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:18:3 + --> tests/ui/iso646.rs:18:25 | 18 | #[template(ext = "txt", source = "{{ a | b }}")] - | ^^^^^^^^ + | ^^^^^^ error: the binary XOR operator is called `xor` in rinja --> :1:7 @@ -27,7 +27,7 @@ error: the binary XOR operator is called `xor` in rinja 1 | {{ a ^ b }} | ^ close to this token | - --> tests/ui/iso646.rs:32:3 + --> tests/ui/iso646.rs:32:25 | 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 7df4ba906..22fbe5681 100644 --- a/testing/tests/ui/json-too-many-args.stderr +++ b/testing/tests/ui/json-too-many-args.stderr @@ -4,7 +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:6:3 + --> tests/ui/json-too-many-args.rs:6:25 | 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 c18bbdf6f..b78b5f304 100644 --- a/testing/tests/ui/let_destructuring_has_rest.stderr +++ b/testing/tests/ui/let_destructuring_has_rest.stderr @@ -5,10 +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:9:3 + --> tests/ui/let_destructuring_has_rest.rs:9:12 | 9 | #[template(source = " - | ^^^^^^^^ + | ^^^^^^ error: expected `,` for more members, or `}` as terminator --> :2:18 @@ -16,10 +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:17:3 + --> tests/ui/let_destructuring_has_rest.rs:17:12 | 17 | #[template(source = " - | ^^^^^^^^ + | ^^^^^^ error: expected member, or `}` as terminator --> :2:19 @@ -27,10 +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:25:3 + --> tests/ui/let_destructuring_has_rest.rs:25:12 | 25 | #[template(source = " - | ^^^^^^^^ + | ^^^^^^ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members @@ -39,10 +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:33:3 + --> tests/ui/let_destructuring_has_rest.rs:33:12 | 33 | #[template(source = " - | ^^^^^^^^ + | ^^^^^^ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members @@ -51,7 +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:41:3 + --> tests/ui/let_destructuring_has_rest.rs:41:12 | 41 | #[template(source = " - | ^^^^^^^^ + | ^^^^^^ diff --git a/testing/tests/ui/lit_on_assignment_lhs.stderr b/testing/tests/ui/lit_on_assignment_lhs.stderr index f9d13580f..7ceb311fb 100644 --- a/testing/tests/ui/lit_on_assignment_lhs.stderr +++ b/testing/tests/ui/lit_on_assignment_lhs.stderr @@ -4,7 +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:4:3 + --> tests/ui/lit_on_assignment_lhs.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = "{%let 7=x%}", + | ^^^^^^ diff --git a/testing/tests/ui/loop_cycle_empty.stderr b/testing/tests/ui/loop_cycle_empty.stderr index c1c834961..a946c65fa 100644 --- a/testing/tests/ui/loop_cycle_empty.stderr +++ b/testing/tests/ui/loop_cycle_empty.stderr @@ -4,7 +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:4:3 + --> tests/ui/loop_cycle_empty.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = r#"{% for v in values %}{{ loop.cycle([]) }}{{ v }},{% endfor %}"#, + | ^^^^^^ diff --git a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr index 0fcc539fa..bbe669cf9 100644 --- a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr +++ b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr @@ -4,7 +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:4:3 + --> tests/ui/loop_cycle_wrong_argument_count.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = r#"{% for v in values %}{{ loop.cycle("r", "g", "b") }}{{ v }},{% endfor %}"#, + | ^^^^^^ diff --git a/testing/tests/ui/macro-super.stderr b/testing/tests/ui/macro-super.stderr index 99146d03b..cca29c948 100644 --- a/testing/tests/ui/macro-super.stderr +++ b/testing/tests/ui/macro-super.stderr @@ -4,7 +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:4:3 + --> tests/ui/macro-super.rs:4:12 | 4 | #[template(source = "{%- macro super() -%}{%- endmacro -%}", ext = "html")] - | ^^^^^^^^ + | ^^^^^^ diff --git a/testing/tests/ui/macro.stderr b/testing/tests/ui/macro.stderr index 45b84638b..af0741f34 100644 --- a/testing/tests/ui/macro.stderr +++ b/testing/tests/ui/macro.stderr @@ -4,10 +4,10 @@ error: macro "thrice" expected 1 argument, found 2 5 | {%- call thrice(2, 3) -%} | ^ close to this token | - --> tests/ui/macro.rs:4:3 + --> tests/ui/macro.rs:4:12 | 4 | #[template(source = "{%- macro thrice(param) -%} - | ^^^^^^^^ + | ^^^^^^ error: macro "thrice" expected 2 arguments, found 0 --> InvalidNumberOfArgs2.html:5:3 @@ -15,10 +15,10 @@ error: macro "thrice" expected 2 arguments, found 0 5 | {%- call thrice() -%} | ^ close to this token | - --> tests/ui/macro.rs:12:3 + --> tests/ui/macro.rs:12:12 | 12 | #[template(source = "{%- macro thrice(param, param2) -%} - | ^^^^^^^^ + | ^^^^^^ error: macro "thrice" expected 0 arguments, found 2 --> InvalidNumberOfArgs3.html:4:3 @@ -26,7 +26,7 @@ error: macro "thrice" expected 0 arguments, found 2 4 | {%- call thrice(1, 2) -%} | ^ close to this token | - --> tests/ui/macro.rs:20:3 + --> tests/ui/macro.rs:20:12 | 20 | #[template(source = "{%- macro thrice() -%} - | ^^^^^^^^ + | ^^^^^^ diff --git a/testing/tests/ui/macro_named_argument.stderr b/testing/tests/ui/macro_named_argument.stderr index 4322e04a2..4bc30e52e 100644 --- a/testing/tests/ui/macro_named_argument.stderr +++ b/testing/tests/ui/macro_named_argument.stderr @@ -4,10 +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:4:3 + --> tests/ui/macro_named_argument.rs:4:12 | 4 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^^^ + | ^^^^^^ error: named argument `param1` was passed more than once --> :5:16 @@ -15,10 +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:12:3 + --> tests/ui/macro_named_argument.rs:12:12 | 12 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^^^ + | ^^^^^^ error: failed to parse template source --> :5:30 @@ -26,10 +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:21:3 + --> tests/ui/macro_named_argument.rs:21:12 | 21 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^^^ + | ^^^^^^ error: named arguments must always be passed last --> :4:16 @@ -37,10 +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:30:3 + --> tests/ui/macro_named_argument.rs:30:12 | 30 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^^^ + | ^^^^^^ error: cannot have unnamed argument (`param2`) after named argument in macro "thrice" --> InvalidNamedArg5.html:4:3 @@ -48,7 +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:38:3 + --> tests/ui/macro_named_argument.rs:38:12 | 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 d0aa5182b..c2b687c1e 100644 --- a/testing/tests/ui/match_with_extra.stderr +++ b/testing/tests/ui/match_with_extra.stderr @@ -4,7 +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:4:3 + --> tests/ui/match_with_extra.rs:6:5 | -4 | #[template( - | ^^^^^^^^ +6 | source = r#" + | ^^^^^^ diff --git a/testing/tests/ui/multiple_extends.stderr b/testing/tests/ui/multiple_extends.stderr index b43e33144..dbce76a3c 100644 --- a/testing/tests/ui/multiple_extends.stderr +++ b/testing/tests/ui/multiple_extends.stderr @@ -4,7 +4,7 @@ error: multiple extend blocks found 3 | {% extends "foo.html" %} | ^ close to this token | - --> tests/ui/multiple_extends.rs:4:3 + --> tests/ui/multiple_extends.rs:4:12 | 4 | #[template(source = r#" - | ^^^^^^^^ + | ^^^^^^ diff --git a/testing/tests/ui/name_mismatch_endblock.stderr b/testing/tests/ui/name_mismatch_endblock.stderr index 7dc71e917..34a20bcef 100644 --- a/testing/tests/ui/name_mismatch_endblock.stderr +++ b/testing/tests/ui/name_mismatch_endblock.stderr @@ -4,7 +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:4:3 + --> tests/ui/name_mismatch_endblock.rs:4:12 | 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 6838fd30b..7bfe89f59 100644 --- a/testing/tests/ui/name_mismatch_endmacro.stderr +++ b/testing/tests/ui/name_mismatch_endmacro.stderr @@ -4,7 +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:4:3 + --> tests/ui/name_mismatch_endmacro.rs:4:12 | 4 | #[template(source = "{% macro foo(arg) %} {{arg}} {% endmacro not_foo %}", ext = "html")] - | ^^^^^^^^ + | ^^^^^^ diff --git a/testing/tests/ui/no-such-escaper.rs b/testing/tests/ui/no-such-escaper.rs index f090f67f5..a7ec2dc6d 100644 --- a/testing/tests/ui/no-such-escaper.rs +++ b/testing/tests/ui/no-such-escaper.rs @@ -18,5 +18,9 @@ struct GlobalEscaper<'a> { text: &'a str, } +#[derive(Template)] +#[template(path = "latex-file.tex")] +struct NoSuchEscaper; + fn main() { } diff --git a/testing/tests/ui/no-such-escaper.stderr b/testing/tests/ui/no-such-escaper.stderr index a5f5dd246..d79e6c862 100644 --- a/testing/tests/ui/no-such-escaper.stderr +++ b/testing/tests/ui/no-such-escaper.stderr @@ -4,13 +4,19 @@ 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:4:3 + --> tests/ui/no-such-escaper.rs:6:5 | -4 | #[template( - | ^^^^^^^^ +6 | source = r#"In LaTeX you write `{{text}}` like `{{text|escape("latex")}}`."#, + | ^^^^^^ 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:13:3 + --> tests/ui/no-such-escaper.rs:14:5 | -13 | #[template( - | ^^^^^^^^ +14 | ext = "tex", + | ^^^ + +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:22:12 + | +22 | #[template(path = "latex-file.tex")] + | ^^^^ diff --git a/testing/tests/ui/num-suffix.stderr b/testing/tests/ui/num-suffix.stderr index bdecff626..709e6e2d8 100644 --- a/testing/tests/ui/num-suffix.stderr +++ b/testing/tests/ui/num-suffix.stderr @@ -4,10 +4,10 @@ error: unknown integer suffix `x` 1 | {{ 0x0x }} | ^ close to this token | - --> tests/ui/num-suffix.rs:5:3 + --> tests/ui/num-suffix.rs:7:5 | -5 | #[template( - | ^^^^^^^^ +7 | source = "{{ 0x0x }}", + | ^^^^^^ error: unknown float suffix `f127` --> :1:4 @@ -15,10 +15,10 @@ error: unknown float suffix `f127` 1 | {{ 0.0_f127 }} | ^ close to this token | - --> tests/ui/num-suffix.rs:12:3 + --> tests/ui/num-suffix.rs:14:5 | -12 | #[template( - | ^^^^^^^^ +14 | source = "{{ 0.0_f127 }}", + | ^^^^^^ error: unknown number suffix `u321` --> :1:4 @@ -26,7 +26,7 @@ error: unknown number suffix `u321` 1 | {{ 654u321 }} | ^ close to this token | - --> tests/ui/num-suffix.rs:19:3 + --> tests/ui/num-suffix.rs:21:5 | -19 | #[template( - | ^^^^^^^^ +21 | source = "{{ 654u321 }}", + | ^^^^^^ diff --git a/testing/tests/ui/ref_deref.stderr b/testing/tests/ui/ref_deref.stderr index 5ac72f8e9..befd34448 100644 --- a/testing/tests/ui/ref_deref.stderr +++ b/testing/tests/ui/ref_deref.stderr @@ -4,7 +4,7 @@ error: failed to parse template source 1 | {% let *x = 2 %} | ^ close to this token | - --> tests/ui/ref_deref.rs:4:3 + --> tests/ui/ref_deref.rs:4:12 | 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 41995ec53..8153e1a7c 100644 --- a/testing/tests/ui/space-pipe.stderr +++ b/testing/tests/ui/space-pipe.stderr @@ -5,10 +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:10:3 + --> tests/ui/space-pipe.rs:10:25 | 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 @@ -17,7 +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:22:3 + --> tests/ui/space-pipe.rs:22:25 | 22 | #[template(ext = "txt", source = "{{a | lower}}")] - | ^^^^^^^^ + | ^^^^^^ diff --git a/testing/tests/ui/transclude-missing.rs b/testing/tests/ui/transclude-missing.rs new file mode 100644 index 000000000..8cb18dea2 --- /dev/null +++ b/testing/tests/ui/transclude-missing.rs @@ -0,0 +1,11 @@ +use rinja::Template; + +#[derive(Template)] +#[template(path = "transclude-there.html")] +struct Indirect; + +#[derive(Template)] +#[template(source = r#"{% include "transclude-there.html" %}"#, ext = "html")] +struct Direct; + +fn main() {} diff --git a/testing/tests/ui/transclude-missing.stderr b/testing/tests/ui/transclude-missing.stderr new file mode 100644 index 000000000..175bb4010 --- /dev/null +++ b/testing/tests/ui/transclude-missing.stderr @@ -0,0 +1,21 @@ +error: template "transclude-missing.html" not found in directories ["$WORKSPACE/target/tests/trybuild/rinja_testing/templates"] + --> testing/templates/transclude-there.html:1:3 + | + 1 | {% include "transclude-missing.html" %} + | ^ close to this token + | + --> tests/ui/transclude-missing.rs:4:12 + | +4 | #[template(path = "transclude-there.html")] + | ^^^^ + +error: template "transclude-missing.html" not found in directories ["$WORKSPACE/target/tests/trybuild/rinja_testing/templates"] + --> testing/templates/transclude-there.html:1:3 + | + 1 | {% include "transclude-missing.html" %} + | ^ close to this token + | + --> tests/ui/transclude-missing.rs:8:12 + | +8 | #[template(source = r#"{% include "transclude-there.html" %}"#, ext = "html")] + | ^^^^^^ diff --git a/testing/tests/ui/typo_in_keyword.stderr b/testing/tests/ui/typo_in_keyword.stderr index 93268a62f..e91011b2b 100644 --- a/testing/tests/ui/typo_in_keyword.stderr +++ b/testing/tests/ui/typo_in_keyword.stderr @@ -4,7 +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:4:3 + --> tests/ui/typo_in_keyword.rs:5:5 | -4 | #[template( - | ^^^^^^^^ +5 | source = "{%for i in 1..=10%}{{i}}{%endfo%}\n1234567890123456789012345678901234567890", + | ^^^^^^ diff --git a/testing/tests/ui/unclosed-nodes.stderr b/testing/tests/ui/unclosed-nodes.stderr index e66393db6..6749c787f 100644 --- a/testing/tests/ui/unclosed-nodes.stderr +++ b/testing/tests/ui/unclosed-nodes.stderr @@ -4,10 +4,10 @@ error: unclosed expression, missing "}}" 1 | {{ expr | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:4:3 + --> tests/ui/unclosed-nodes.rs:4:12 | 4 | #[template(source = "{{ expr", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed expression, missing "}}" --> :1:1 @@ -15,10 +15,10 @@ error: unclosed expression, missing "}}" 1 | {{ expr | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:8:3 + --> tests/ui/unclosed-nodes.rs:8:12 | 8 | #[template(source = "{{ expr ", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed expression, missing "}}" --> :1:1 @@ -26,10 +26,10 @@ error: unclosed expression, missing "}}" 1 | {{ expr - | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:12:3 + --> tests/ui/unclosed-nodes.rs:12:12 | 12 | #[template(source = "{{ expr -", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: failed to parse template source --> :1:10 @@ -37,10 +37,10 @@ error: failed to parse template source 1 | {{ expr -} | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:16:3 + --> tests/ui/unclosed-nodes.rs:16:12 | 16 | #[template(source = "{{ expr -}", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed block, missing "%}" --> :1:1 @@ -48,10 +48,10 @@ error: unclosed block, missing "%}" 1 | {% let x | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:20:3 + --> tests/ui/unclosed-nodes.rs:20:12 | 20 | #[template(source = "{% let x", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed block, missing "%}" --> :1:1 @@ -59,10 +59,10 @@ error: unclosed block, missing "%}" 1 | {% let x | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:24:3 + --> tests/ui/unclosed-nodes.rs:24:12 | 24 | #[template(source = "{% let x ", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed block, missing "%}" --> :1:1 @@ -70,10 +70,10 @@ error: unclosed block, missing "%}" 1 | {% let x - | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:28:3 + --> tests/ui/unclosed-nodes.rs:28:12 | 28 | #[template(source = "{% let x -", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: failed to parse template source --> :1:11 @@ -81,10 +81,10 @@ error: failed to parse template source 1 | {% let x -% | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:32:3 + --> tests/ui/unclosed-nodes.rs:32:12 | 32 | #[template(source = "{% let x -%", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -92,10 +92,10 @@ error: unclosed comment, missing "#}" 1 | {# comment | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:36:3 + --> tests/ui/unclosed-nodes.rs:36:12 | 36 | #[template(source = "{# comment", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -103,10 +103,10 @@ error: unclosed comment, missing "#}" 1 | {# comment | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:40:3 + --> tests/ui/unclosed-nodes.rs:40:12 | 40 | #[template(source = "{# comment ", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -114,10 +114,10 @@ error: unclosed comment, missing "#}" 1 | {# comment - | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:44:3 + --> tests/ui/unclosed-nodes.rs:44:12 | 44 | #[template(source = "{# comment -", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^ error: unclosed comment, missing "#}" --> :1:3 @@ -125,7 +125,7 @@ error: unclosed comment, missing "#}" 1 | {# comment -# | ^ close to this token | - --> tests/ui/unclosed-nodes.rs:48:3 + --> tests/ui/unclosed-nodes.rs:48:12 | 48 | #[template(source = "{# comment -#", ext = "txt")] - | ^^^^^^^^ + | ^^^^^^