From 380ecc1d8e67019836b1c559980d963786692cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Mon, 29 Jul 2024 04:58:30 +0200 Subject: [PATCH 1/7] derive: properly display error locations --- rinja_derive/Cargo.toml | 1 + rinja_derive/src/input.rs | 16 ++- rinja_derive/src/lib.rs | 99 ++++++++++++++----- rinja_derive_standalone/Cargo.toml | 1 + rinja_parser/src/lib.rs | 99 ++++--------------- rinja_parser/src/tests.rs | 4 +- testing/tests/ui/as-primitive-type.stderr | 42 +++++--- testing/tests/ui/block_in_filter_block.stderr | 7 +- .../tests/ui/blocks_below_top_level.stderr | 21 ++-- testing/tests/ui/break_outside_of_loop.stderr | 7 +- testing/tests/ui/char_literal.stderr | 63 +++++++----- testing/tests/ui/error_file_path.stderr | 21 ++-- testing/tests/ui/excessive_nesting.stderr | 7 +- testing/tests/ui/extends.stderr | 14 ++- testing/tests/ui/filter-recursion.stderr | 8 +- testing/tests/ui/filter_block_ws.stderr | 8 +- testing/tests/ui/include-a-folder.stderr | 7 +- testing/tests/ui/is_defined.stderr | 42 +++++--- testing/tests/ui/iso646.stderr | 21 ++-- testing/tests/ui/json-too-many-args.stderr | 7 +- .../ui/let_destructuring_has_rest.stderr | 35 +++++-- testing/tests/ui/lit_on_assignment_lhs.stderr | 7 +- testing/tests/ui/loop_cycle_empty.stderr | 7 +- .../ui/loop_cycle_wrong_argument_count.stderr | 7 +- testing/tests/ui/macro-super.stderr | 7 +- testing/tests/ui/macro.stderr | 21 ++-- testing/tests/ui/macro_named_argument.stderr | 36 +++++-- testing/tests/ui/match_with_extra.stderr | 8 +- testing/tests/ui/multiple_extends.stderr | 7 +- .../tests/ui/name_mismatch_endblock.stderr | 7 +- .../tests/ui/name_mismatch_endmacro.stderr | 7 +- testing/tests/ui/no-such-escaper.stderr | 7 +- testing/tests/ui/num-suffix.stderr | 21 ++-- testing/tests/ui/ref_deref.stderr | 8 +- testing/tests/ui/space-pipe.stderr | 14 ++- testing/tests/ui/typo_in_keyword.stderr | 8 +- testing/tests/ui/unclosed-nodes.stderr | 86 +++++++++++----- 37 files changed, 516 insertions(+), 272 deletions(-) diff --git a/rinja_derive/Cargo.toml b/rinja_derive/Cargo.toml index 9e14897b8..a51606970 100644 --- a/rinja_derive/Cargo.toml +++ b/rinja_derive/Cargo.toml @@ -26,6 +26,7 @@ with-warp = [] [dependencies] parser = { package = "rinja_parser", version = "0.2.0", path = "../rinja_parser" } +annotate-snippets = "0.11.4" basic-toml = { version = "0.1.1", optional = true } memchr = "2" mime = "0.3" diff --git a/rinja_derive/src/input.rs b/rinja_derive/src/input.rs index f858d8743..127afe15f 100644 --- a/rinja_derive/src/input.rs +++ b/rinja_derive/src/input.rs @@ -149,7 +149,21 @@ impl TemplateInput<'_> { let mut dependency_graph = Vec::new(); let mut check = vec![(Arc::clone(&self.path), source, source_path)]; while let Some((path, source, source_path)) = check.pop() { - let parsed = self.syntax.parse(source, source_path)?; + let parsed = match self.syntax.parse(Arc::clone(&source), source_path) { + Ok(parsed) => parsed, + Err(err) => { + let msg = err + .message + .unwrap_or_else(|| "failed to parse template source".into()); + let file_path = err + .file_path + .as_deref() + .unwrap_or(Path::new("")); + let file_info = + FileInfo::new(file_path, Some(&source), Some(&source[err.offset..])); + return Err(CompileError::new(msg, Some(file_info))); + } + }; let mut top = true; let mut nested = vec![parsed.nodes()]; diff --git a/rinja_derive/src/lib.rs b/rinja_derive/src/lib.rs index 38db6dd98..b56c89c46 100644 --- a/rinja_derive/src/lib.rs +++ b/rinja_derive/src/lib.rs @@ -14,11 +14,12 @@ use std::collections::HashMap; use std::fmt; use std::path::Path; +use annotate_snippets::{Level, Renderer, Snippet}; use config::{read_config_file, Config}; use generator::{Generator, MapChain}; use heritage::{Context, Heritage}; use input::{Print, TemplateArgs, TemplateInput}; -use parser::{generate_error_info, strip_common, ErrorInfo, ParseError, Parsed, WithSpan}; +use parser::{strip_common, Parsed, WithSpan}; #[cfg(not(feature = "__standalone"))] use proc_macro::TokenStream as TokenStream12; #[cfg(feature = "__standalone")] @@ -188,14 +189,46 @@ struct CompileError { impl CompileError { fn new(msg: S, file_info: Option>) -> Self { + let span = Span::call_site(); + + if let Some(FileInfo { + path, + source: Some(source), + node_source: Some(node_source), + }) = file_info + { + if source + .as_bytes() + .as_ptr_range() + .contains(&node_source.as_ptr()) + { + let label = msg.to_string(); + let path = match std::env::current_dir() { + Ok(cwd) => strip_common(&cwd, path), + Err(_) => path.display().to_string(), + }; + + let start = node_source.as_ptr() as usize - source.as_ptr() as usize; + let annotation = Level::Error.span(start..start).label("close to this token"); + let snippet = Snippet::source(source) + .origin(&path) + .fold(true) + .annotation(annotation); + let message = Level::Error.title(&label).snippet(snippet); + + let mut msg = Renderer::styled().render(message).to_string(); + if let Some((prefix, _)) = msg.split_once(' ') { + msg.replace_range(..=prefix.len(), ""); + } + return Self { msg, span }; + } + } + let msg = match file_info { Some(file_info) => format!("{msg}{file_info}"), None => msg.to_string(), }; - Self { - msg, - span: Span::call_site(), - } + Self { msg, span } } fn no_file_info(msg: S) -> Self { @@ -219,14 +252,7 @@ impl fmt::Display for CompileError { } } -impl From for CompileError { - #[inline] - fn from(e: ParseError) -> Self { - // It already has the correct message so no need to do anything. - Self::no_file_info(e) - } -} - +#[derive(Debug, Clone, Copy)] struct FileInfo<'a> { path: &'a Path, source: Option<&'a str>, @@ -255,18 +281,13 @@ impl fmt::Display for FileInfo<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match (self.source, self.node_source) { (Some(source), Some(node_source)) => { - let ( - ErrorInfo { - row, - column, - source_after, - }, - file_path, - ) = generate_error_info(source, node_source, self.path); + let (error_info, file_path) = generate_error_info(source, node_source, self.path); write!( f, "\n --> {file_path}:{row}:{column}\n{source_after}", - row = row + 1 + row = error_info.row, + column = error_info.column, + source_after = &error_info.source_after, ) } _ => { @@ -280,6 +301,40 @@ impl fmt::Display for FileInfo<'_> { } } +struct ErrorInfo { + row: usize, + column: usize, + source_after: String, +} + +fn generate_row_and_column(src: &str, input: &str) -> ErrorInfo { + let offset = src.len() - input.len(); + let (source_before, source_after) = src.split_at(offset); + + let source_after = match source_after.char_indices().enumerate().take(41).last() { + Some((80, (i, _))) => format!("{:?}...", &source_after[..i]), + _ => format!("{source_after:?}"), + }; + + let (row, last_line) = source_before.lines().enumerate().last().unwrap_or_default(); + let column = last_line.chars().count(); + ErrorInfo { + row, + column, + source_after, + } +} + +/// Return the error related information and its display file path. +fn generate_error_info(src: &str, input: &str, file_path: &Path) -> (ErrorInfo, String) { + let file_path = match std::env::current_dir() { + Ok(cwd) => strip_common(&cwd, file_path), + Err(_) => file_path.display().to_string(), + }; + let error_info = generate_row_and_column(src, input); + (error_info, file_path) +} + struct MsgValidEscapers<'a>(&'a [(Vec>, Cow<'a, str>)]); impl fmt::Display for MsgValidEscapers<'_> { diff --git a/rinja_derive_standalone/Cargo.toml b/rinja_derive_standalone/Cargo.toml index 657daa617..4a1c4a3ba 100644 --- a/rinja_derive_standalone/Cargo.toml +++ b/rinja_derive_standalone/Cargo.toml @@ -25,6 +25,7 @@ with-warp = [] [dependencies] parser = { package = "rinja_parser", version = "0.2.0", path = "../rinja_parser" } +annotate-snippets = "0.11.4" basic-toml = { version = "0.1.1", optional = true } memchr = "2" mime = "0.3" diff --git a/rinja_parser/src/lib.rs b/rinja_parser/src/lib.rs index ffb34067d..a4534b97c 100644 --- a/rinja_parser/src/lib.rs +++ b/rinja_parser/src/lib.rs @@ -12,7 +12,7 @@ use std::{fmt, str}; use nom::branch::alt; use nom::bytes::complete::{escaped, is_not, tag, take_till, take_while_m_n}; use nom::character::complete::{anychar, char, one_of, satisfy}; -use nom::combinator::{cut, eof, map, not, opt, recognize}; +use nom::combinator::{complete, cut, eof, map, not, opt, recognize}; use nom::error::{Error, ErrorKind, FromExternalError}; use nom::multi::{many0_count, many1}; use nom::sequence::{delimited, pair, preceded, terminated, tuple}; @@ -110,31 +110,18 @@ impl<'a> Ast<'a> { syntax: &Syntax<'_>, ) -> Result { let parse = |i: &'a str| Node::many(i, &State::new(syntax)); - let (input, message) = match terminated(parse, cut(eof))(src) { + let (input, message) = match complete(terminated(parse, cut(eof)))(src) { Ok(("", nodes)) => return Ok(Self { nodes }), Ok(_) => unreachable!("eof() is not eof?"), + Err(nom::Err::Incomplete(_)) => unreachable!("complete() is not complete?"), Err( nom::Err::Error(ErrorContext { input, message, .. }) | nom::Err::Failure(ErrorContext { input, message, .. }), ) => (input, message), - Err(nom::Err::Incomplete(_)) => return Err(ParseError::Incomplete), }; - - let offset = src.len() - input.len(); - let (source_before, source_after) = src.split_at(offset); - - let source_after = match source_after.char_indices().enumerate().take(41).last() { - Some((40, (i, _))) => format!("{:?}...", &source_after[..i]), - _ => format!("{source_after:?}"), - }; - - let (row, last_line) = source_before.lines().enumerate().last().unwrap_or_default(); - let column = last_line.chars().count(); - Err(ParseError::Details { + Err(ParseError { message, - row, - column, - source_after, + offset: src.len() - input.len(), file_path, }) } @@ -198,48 +185,32 @@ impl<'a, T: PartialEq> PartialEq for WithSpan<'a, T> { } #[derive(Debug, Clone, PartialEq, Eq)] -pub enum ParseError { - Incomplete, - Details { - message: Option>, - row: usize, - column: usize, - source_after: String, - file_path: Option>, - }, +pub struct ParseError { + pub message: Option>, + pub offset: usize, + pub file_path: Option>, } impl std::error::Error for ParseError {} impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let (message, mut row, column, source, path) = match self { - ParseError::Incomplete => return write!(f, "parsing incomplete"), - ParseError::Details { - message, - row, - column, - source_after, - file_path, - } => (message, *row, column, source_after, file_path), - }; + let ParseError { + message, + file_path, + offset, + } = self; if let Some(message) = message { writeln!(f, "{}", message)?; } - let path = path + let path = file_path .as_ref() .and_then(|path| Some(strip_common(¤t_dir().ok()?, path))); - - row += 1; match path { - Some(path) => f.write_fmt(format_args!( - "failed to parse template source\n --> {path}:{row}:{column}\n{source}", - )), - None => f.write_fmt(format_args!( - "failed to parse template source at row {row}, column {column} near:\n{source}", - )), + Some(path) => write!(f, "failed to parse template source\n --> {path}@{offset}"), + None => write!(f, "failed to parse template source near offset {offset}"), } } } @@ -247,40 +218,6 @@ impl fmt::Display for ParseError { pub(crate) type ParseErr<'a> = nom::Err>; pub(crate) type ParseResult<'a, T = &'a str> = Result<(&'a str, T), ParseErr<'a>>; -pub struct ErrorInfo { - pub row: usize, - pub column: usize, - pub source_after: String, -} - -pub fn generate_row_and_column(src: &str, input: &str) -> ErrorInfo { - let offset = src.len() - input.len(); - let (source_before, source_after) = src.split_at(offset); - - let source_after = match source_after.char_indices().enumerate().take(41).last() { - Some((40, (i, _))) => format!("{:?}...", &source_after[..i]), - _ => format!("{source_after:?}"), - }; - - let (row, last_line) = source_before.lines().enumerate().last().unwrap_or_default(); - let column = last_line.chars().count(); - ErrorInfo { - row, - column, - source_after, - } -} - -/// Return the error related information and its display file path. -pub fn generate_error_info(src: &str, input: &str, file_path: &Path) -> (ErrorInfo, String) { - let file_path = match std::env::current_dir() { - Ok(cwd) => strip_common(&cwd, file_path), - Err(_) => file_path.display().to_string(), - }; - let error_info = generate_row_and_column(src, input); - (error_info, file_path) -} - /// This type is used to handle `nom` errors and in particular to add custom error messages. /// It used to generate `ParserError`. /// @@ -801,7 +738,7 @@ pub fn strip_common(base: &Path, path: &Path) -> String { if path_parts.is_empty() { path.display().to_string() } else { - path_parts.join("/") + path_parts.join(std::path::MAIN_SEPARATOR_STR) } } diff --git a/rinja_parser/src/tests.rs b/rinja_parser/src/tests.rs index e2e9f6c53..737d8bcb9 100644 --- a/rinja_parser/src/tests.rs +++ b/rinja_parser/src/tests.rs @@ -360,7 +360,7 @@ fn test_rust_macro() { &*Ast::from_str("{{a.b.c!( hello )}}", None, &syntax) .unwrap_err() .to_string(), - "failed to parse template source at row 1, column 7 near:\n\"!( hello )}}\"", + "failed to parse template source near offset 7", ); } @@ -908,7 +908,7 @@ fn test_missing_space_after_kw() { let err = Ast::from_str("{%leta=b%}", None, &syntax).unwrap_err(); assert!(matches!( &*err.to_string(), - "failed to parse template source at row 1, column 0 near:\n\"{%leta=b%}\"", + "failed to parse template source near offset 0", )); } diff --git a/testing/tests/ui/as-primitive-type.stderr b/testing/tests/ui/as-primitive-type.stderr index 2ec4b5b40..2faf9c4b5 100644 --- a/testing/tests/ui/as-primitive-type.stderr +++ b/testing/tests/ui/as-primitive-type.stderr @@ -1,6 +1,9 @@ error: `as` operator expects the name of a primitive type on its right-hand side - failed to parse template source at row 1, column 8 near: - "as 4567 }}" + --> :1:9 + | + 1 | {{ 1234 as 4567 }} + | ^ close to this token + | --> tests/ui/as-primitive-type.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: `as` operator expects the name of a primitive type on its right-hand side = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `as` operator expects the name of a primitive type on its right-hand side - failed to parse template source at row 1, column 8 near: - "as ? }}" + --> :1:9 + | + 1 | {{ 1234 as ? }} + | ^ close to this token + | --> tests/ui/as-primitive-type.rs:7:10 | 7 | #[derive(Template)] @@ -19,8 +25,11 @@ error: `as` operator expects the name of a primitive type on its right-hand side = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `as` operator expects the name of a primitive type on its right-hand side, found `u1234` - failed to parse template source at row 1, column 8 near: - "as u1234 }}" + --> :1:9 + | + 1 | {{ 1234 as u1234 }} + | ^ close to this token + | --> tests/ui/as-primitive-type.rs:11:10 | 11 | #[derive(Template)] @@ -29,8 +38,11 @@ error: `as` operator expects the name of a primitive type on its right-hand side = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `as` operator expects the name of a primitive type on its right-hand side, found `core` - failed to parse template source at row 1, column 8 near: - "as core::primitive::u32 }}" + --> :1:9 + | + 1 | {{ 1234 as core::primitive::u32 }} + | ^ close to this token + | --> tests/ui/as-primitive-type.rs:15:10 | 15 | #[derive(Template)] @@ -39,8 +51,11 @@ error: `as` operator expects the name of a primitive type on its right-hand side = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `as` operator expects the name of a primitive type on its right-hand side, found `int32_t` - failed to parse template source at row 1, column 8 near: - "as int32_t }}" + --> :1:9 + | + 1 | {{ 1234 as int32_t }} + | ^ close to this token + | --> tests/ui/as-primitive-type.rs:19:10 | 19 | #[derive(Template)] @@ -49,8 +64,11 @@ error: `as` operator expects the name of a primitive type on its right-hand side = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `as` operator expects the name of a primitive type on its right-hand side, found `int32_t` - failed to parse template source at row 1, column 35 near: - "as int32_t }}" + --> :1:36 + | + 1 | {{ (1234 + 4 * 12 / 45675445 - 13) as int32_t }} + | ^ close to this token + | --> tests/ui/as-primitive-type.rs:23:10 | 23 | #[derive(Template)] diff --git a/testing/tests/ui/block_in_filter_block.stderr b/testing/tests/ui/block_in_filter_block.stderr index db83021b7..0224aa150 100644 --- a/testing/tests/ui/block_in_filter_block.stderr +++ b/testing/tests/ui/block_in_filter_block.stderr @@ -1,6 +1,9 @@ error: cannot have a block inside a filter block - --> BlockInFilter.html:7:10 - " block title %}New title{% endblock %}\n "... + --> BlockInFilter.html:7:11 + | + 7 | {% block title %}New title{% endblock %} + | ^ close to this token + | --> tests/ui/block_in_filter_block.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/blocks_below_top_level.stderr b/testing/tests/ui/blocks_below_top_level.stderr index 740388fd1..138978ac1 100644 --- a/testing/tests/ui/blocks_below_top_level.stderr +++ b/testing/tests/ui/blocks_below_top_level.stderr @@ -1,6 +1,9 @@ error: `extends` blocks are not allowed below top level - --> MyTemplate1.txt:3:2 - " extends \"bla.txt\" %}\n{% endblock %}\n" + --> MyTemplate1.txt:3:3 + | + 3 | {% extends "bla.txt" %} + | ^ close to this token + | --> tests/ui/blocks_below_top_level.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: `extends` blocks are not allowed below top level = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `macro` blocks are not allowed below top level - --> MyTemplate2.txt:3:2 - " macro bla() %}\n{% endmacro %}\n{% endblo"... + --> MyTemplate2.txt:3:3 + | + 3 | {% macro bla() %} + | ^ close to this token + | --> tests/ui/blocks_below_top_level.rs:11:10 | 11 | #[derive(Template)] @@ -19,8 +25,11 @@ error: `macro` blocks are not allowed below top level = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `import` blocks are not allowed below top level - --> MyTemplate3.txt:3:2 - " import \"bla.txt\" as blue %}\n{% endblock"... + --> MyTemplate3.txt:3:3 + | + 3 | {% import "bla.txt" as blue %} + | ^ close to this token + | --> tests/ui/blocks_below_top_level.rs:20:10 | 20 | #[derive(Template)] diff --git a/testing/tests/ui/break_outside_of_loop.stderr b/testing/tests/ui/break_outside_of_loop.stderr index 96aa54bb8..6419e40ce 100644 --- a/testing/tests/ui/break_outside_of_loop.stderr +++ b/testing/tests/ui/break_outside_of_loop.stderr @@ -1,6 +1,9 @@ error: you can only `break` inside a `for` loop - failed to parse template source at row 1, column 9 near: - "break%}, have a parsing error!" + --> :1:10 + | + 1 | Have a {%break%}, have a parsing error! + | ^ close to this token + | --> tests/ui/break_outside_of_loop.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/char_literal.stderr b/testing/tests/ui/char_literal.stderr index bed5bb3fa..83b9f640f 100644 --- a/testing/tests/ui/char_literal.stderr +++ b/testing/tests/ui/char_literal.stderr @@ -1,7 +1,9 @@ error: invalid character - failed to parse template source - --> testing/templates/char-literals/char-literal-1.txt:1:11 - "'\\a' %}" + --> testing/templates/char-literals/char-literal-1.txt:1:12 + | + 1 | {% let s = '\a' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:3:10 | 3 | #[derive(Template)] @@ -10,9 +12,11 @@ error: invalid character = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid character - failed to parse template source - --> testing/templates/char-literals/char-literal-2.txt:1:11 - "'\\x' %}" + --> testing/templates/char-literals/char-literal-2.txt:1:12 + | + 1 | {% let s = '\x' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:7:10 | 7 | #[derive(Template)] @@ -21,9 +25,11 @@ error: invalid character = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid character - failed to parse template source - --> testing/templates/char-literals/char-literal-3.txt:1:11 - "'\\x1' %}" + --> testing/templates/char-literals/char-literal-3.txt:1:12 + | + 1 | {% let s = '\x1' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:11:10 | 11 | #[derive(Template)] @@ -32,9 +38,11 @@ error: invalid character = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: must be a character in the range [\x00-\x7f] - failed to parse template source - --> testing/templates/char-literals/char-literal-4.txt:1:11 - "'\\x80' %}" + --> testing/templates/char-literals/char-literal-4.txt:1:12 + | + 1 | {% let s = '\x80' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:15:10 | 15 | #[derive(Template)] @@ -43,9 +51,11 @@ error: must be a character in the range [\x00-\x7f] = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid character - failed to parse template source - --> testing/templates/char-literals/char-literal-5.txt:1:11 - "'\\u' %}" + --> testing/templates/char-literals/char-literal-5.txt:1:12 + | + 1 | {% let s = '\u' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:19:10 | 19 | #[derive(Template)] @@ -54,9 +64,11 @@ error: invalid character = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid character - failed to parse template source - --> testing/templates/char-literals/char-literal-6.txt:1:11 - "'\\u{}' %}" + --> testing/templates/char-literals/char-literal-6.txt:1:12 + | + 1 | {% let s = '\u{}' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:23:10 | 23 | #[derive(Template)] @@ -65,9 +77,11 @@ error: invalid character = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unicode escape must be at most 10FFFF - failed to parse template source - --> testing/templates/char-literals/char-literal-7.txt:1:11 - "'\\u{110000}' %}" + --> testing/templates/char-literals/char-literal-7.txt:1:12 + | + 1 | {% let s = '\u{110000}' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:27:10 | 27 | #[derive(Template)] @@ -76,8 +90,11 @@ error: unicode escape must be at most 10FFFF = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: invalid character - failed to parse template source at row 1, column 11 near: - "'aaa' %}" + --> :1:12 + | + 1 | {% let s = 'aaa' %} + | ^ close to this token + | --> tests/ui/char_literal.rs:31:10 | 31 | #[derive(Template)] diff --git a/testing/tests/ui/error_file_path.stderr b/testing/tests/ui/error_file_path.stderr index 58b449a0e..f1cdc14da 100644 --- a/testing/tests/ui/error_file_path.stderr +++ b/testing/tests/ui/error_file_path.stderr @@ -1,6 +1,9 @@ error: failed to parse template source - --> testing/templates/invalid_syntax.html:1:14 - "}" + --> testing/templates/invalid_syntax.html:1:15 + | + 1 | {% let 12 = 0 } + | ^ close to this token + | --> tests/ui/error_file_path.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: failed to parse template source = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: failed to parse template source - --> testing/templates/invalid_syntax.html:1:14 - "}" + --> testing/templates/invalid_syntax.html:1:15 + | + 1 | {% let 12 = 0 } + | ^ close to this token + | --> tests/ui/error_file_path.rs:7:10 | 7 | #[derive(Template)] @@ -19,8 +25,11 @@ error: failed to parse template source = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: failed to parse template source - --> testing/templates/invalid_syntax.html:1:14 - "}" + --> testing/templates/invalid_syntax.html:1:15 + | + 1 | {% let 12 = 0 } + | ^ close to this token + | --> tests/ui/error_file_path.rs:11:10 | 11 | #[derive(Template)] diff --git a/testing/tests/ui/excessive_nesting.stderr b/testing/tests/ui/excessive_nesting.stderr index ce932012e..061554e07 100644 --- a/testing/tests/ui/excessive_nesting.stderr +++ b/testing/tests/ui/excessive_nesting.stderr @@ -1,6 +1,9 @@ error: your template code is too deeply nested, or last expression is too complex - failed to parse template source at row 14, column 42 near: - "%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1"... + --> :14:43 + | + 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 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/extends.stderr b/testing/tests/ui/extends.stderr index a2098114d..5bf8d7e37 100644 --- a/testing/tests/ui/extends.stderr +++ b/testing/tests/ui/extends.stderr @@ -1,6 +1,9 @@ error: whitespace control is not allowed on `extends` - failed to parse template source at row 1, column 2 near: - "- extends \"whatever.html\" %}" + --> :1:3 + | + 1 | {%- extends "whatever.html" %} + | ^ close to this token + | --> tests/ui/extends.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: whitespace control is not allowed on `extends` = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: whitespace control is not allowed on `extends` - failed to parse template source at row 1, column 2 near: - " extends \"whatever.html\" -%}" + --> :1:3 + | + 1 | {% extends "whatever.html" -%} + | ^ close to this token + | --> tests/ui/extends.rs:10:10 | 10 | #[derive(Template)] diff --git a/testing/tests/ui/filter-recursion.stderr b/testing/tests/ui/filter-recursion.stderr index 218bf5bde..da7f5fac2 100644 --- a/testing/tests/ui/filter-recursion.stderr +++ b/testing/tests/ui/filter-recursion.stderr @@ -1,7 +1,9 @@ error: your template code is too deeply nested, or last expression is too complex - failed to parse template source - --> testing/templates/filter-recursion.html:1:255 - "|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A"... + --> testing/templates/filter-recursion.html:1:256 + | + 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 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/filter_block_ws.stderr b/testing/tests/ui/filter_block_ws.stderr index 2740efef3..4afbc043b 100644 --- a/testing/tests/ui/filter_block_ws.stderr +++ b/testing/tests/ui/filter_block_ws.stderr @@ -1,5 +1,9 @@ -error: failed to parse template source at row 1, column 27 near: - " %}\nHELLO\n{{v}}\n{%- endfilter %}" +error: failed to parse template source + --> :1:28 + | + 1 | {% filter lower|indent(2) - %} + | ^ close to this token + | --> tests/ui/filter_block_ws.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/include-a-folder.stderr b/testing/tests/ui/include-a-folder.stderr index 8f029260b..f87ecfb5e 100644 --- a/testing/tests/ui/include-a-folder.stderr +++ b/testing/tests/ui/include-a-folder.stderr @@ -1,6 +1,9 @@ error: unable to open template file '$WORKSPACE/target/tests/trybuild/rinja_testing/templates/a_file_that_is_actually_a_folder.html': Is a directory (os error 21) - --> YouCannotIncludeFolders.txt:1:2 - " include \"a_file_that_is_actually_a_fold"... + --> YouCannotIncludeFolders.txt:1:3 + | + 1 | {% include "a_file_that_is_actually_a_folder.html" %} + | ^ close to this token + | --> tests/ui/include-a-folder.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/is_defined.stderr b/testing/tests/ui/is_defined.stderr index f3c809ca2..a7ff9019a 100644 --- a/testing/tests/ui/is_defined.stderr +++ b/testing/tests/ui/is_defined.stderr @@ -1,6 +1,9 @@ error: `is defined` operator can only be used on variables, not on their fields - failed to parse template source at row 1, column 6 near: - "x.y is defined %}{% endif %}" + --> :1:7 + | + 1 | {% if x.y is defined %}{% endif %} + | ^ close to this token + | --> tests/ui/is_defined.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: `is defined` operator can only be used on variables, not on their fields = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: `is defined` operator can only be used on variables - failed to parse template source at row 1, column 6 near: - "true is defined %}{% endif %}" + --> :1:7 + | + 1 | {% if true is defined %}{% endif %} + | ^ close to this token + | --> tests/ui/is_defined.rs:10:10 | 10 | #[derive(Template)] @@ -19,8 +25,11 @@ error: `is defined` operator can only be used on variables = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `defined` or `not defined` after `is` - failed to parse template source at row 1, column 6 near: - "true is %}{% endif %}" + --> :1:7 + | + 1 | {% if true is %}{% endif %} + | ^ close to this token + | --> tests/ui/is_defined.rs:17:10 | 17 | #[derive(Template)] @@ -29,8 +38,11 @@ error: expected `defined` or `not defined` after `is` = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `defined` or `not defined` after `is` - failed to parse template source at row 1, column 6 near: - "x is %}{% endif %}" + --> :1:7 + | + 1 | {% if x is %}{% endif %} + | ^ close to this token + | --> tests/ui/is_defined.rs:24:10 | 24 | #[derive(Template)] @@ -39,8 +51,11 @@ error: expected `defined` or `not defined` after `is` = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `defined` or `not defined` after `is` - failed to parse template source at row 1, column 6 near: - "x is blue %}{% endif %}" + --> :1:7 + | + 1 | {% if x is blue %}{% endif %} + | ^ close to this token + | --> tests/ui/is_defined.rs:31:10 | 31 | #[derive(Template)] @@ -49,8 +64,11 @@ error: expected `defined` or `not defined` after `is` = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `defined` or `not defined` after `is` - failed to parse template source at row 1, column 6 near: - "x is blue.red %}{% endif %}" + --> :1:7 + | + 1 | {% if x is blue.red %}{% endif %} + | ^ close to this token + | --> tests/ui/is_defined.rs:38:10 | 38 | #[derive(Template)] diff --git a/testing/tests/ui/iso646.stderr b/testing/tests/ui/iso646.stderr index 9484a2ff7..c4fdfb488 100644 --- a/testing/tests/ui/iso646.stderr +++ b/testing/tests/ui/iso646.stderr @@ -1,6 +1,9 @@ error: the binary AND operator is called `bitand` in rinja - failed to parse template source at row 1, column 6 near: - " b }}" + --> :1:7 + | + 1 | {{ a & b }} + | ^ close to this token + | --> tests/ui/iso646.rs:3:10 | 3 | #[derive(Template)] @@ -10,8 +13,11 @@ error: the binary AND operator is called `bitand` in rinja error: the filter operator `|` must not be preceded by any whitespace characters the binary OR operator is called `bitor` in rinja - failed to parse template source at row 1, column 4 near: - " | b }}" + --> :1:5 + | + 1 | {{ a | b }} + | ^ close to this token + | --> tests/ui/iso646.rs:17:10 | 17 | #[derive(Template)] @@ -20,8 +26,11 @@ error: the filter operator `|` must not be preceded by any whitespace characters = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: the binary XOR operator is called `xor` in rinja - failed to parse template source at row 1, column 6 near: - " b }}" + --> :1:7 + | + 1 | {{ a ^ b }} + | ^ close to this token + | --> tests/ui/iso646.rs:31:10 | 31 | #[derive(Template)] diff --git a/testing/tests/ui/json-too-many-args.stderr b/testing/tests/ui/json-too-many-args.stderr index 6ecd1c412..6ad9d0164 100644 --- a/testing/tests/ui/json-too-many-args.stderr +++ b/testing/tests/ui/json-too-many-args.stderr @@ -1,6 +1,9 @@ error: unexpected argument(s) in `json` filter - --> OneTwoThree.txt:1:3 - "1|json(2, 3) }}" + --> OneTwoThree.txt:1:4 + | + 1 | {{ 1|json(2, 3) }} + | ^ close to this token + | --> tests/ui/json-too-many-args.rs:5:10 | 5 | #[derive(Template)] diff --git a/testing/tests/ui/let_destructuring_has_rest.stderr b/testing/tests/ui/let_destructuring_has_rest.stderr index 7be692058..64297582a 100644 --- a/testing/tests/ui/let_destructuring_has_rest.stderr +++ b/testing/tests/ui/let_destructuring_has_rest.stderr @@ -1,7 +1,10 @@ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members - failed to parse template source at row 2, column 20 near: - ", } = x -%}hello {{ a }}{%- endif -%}\n" + --> :2:21 + | + 2 | {%- if let X { a, .., } = x -%}hello {{ a }}{%- endif -%} + | ^ close to this token + | --> tests/ui/let_destructuring_has_rest.rs:8:10 | 8 | #[derive(Template)] @@ -10,8 +13,11 @@ error: unexpected `,` character after `..` = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected `,` for more members, or `}` as terminator - failed to parse template source at row 2, column 17 near: - ".. } = x -%}hello {{ a }}{%- endif -%}\n" + --> :2:18 + | + 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)] @@ -20,8 +26,11 @@ error: expected `,` for more members, or `}` as terminator = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected member, or `}` as terminator - failed to parse template source at row 2, column 18 near: - "1 } = x -%}hello {{ a }}{%- endif -%}\n" + --> :2:19 + | + 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)] @@ -31,8 +40,11 @@ error: expected member, or `}` as terminator error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members - failed to parse template source at row 2, column 20 near: - ", b } = x -%}hello {{ a }}{%- endif -%}\n" + --> :2:21 + | + 2 | {%- if let X { a, .., b } = x -%}hello {{ a }}{%- endif -%} + | ^ close to this token + | --> tests/ui/let_destructuring_has_rest.rs:32:10 | 32 | #[derive(Template)] @@ -42,8 +54,11 @@ error: unexpected `,` character after `..` error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members - failed to parse template source at row 2, column 17 near: - ", b } = x -%}hello {{ a }}{%- endif -%}\n" + --> :2:18 + | + 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)] diff --git a/testing/tests/ui/lit_on_assignment_lhs.stderr b/testing/tests/ui/lit_on_assignment_lhs.stderr index ceb2b7732..0f0bcdaba 100644 --- a/testing/tests/ui/lit_on_assignment_lhs.stderr +++ b/testing/tests/ui/lit_on_assignment_lhs.stderr @@ -1,6 +1,9 @@ error: literals are not allowed on the left-hand side of an assignment - --> MyTemplate.txt:1:2 - "let 7=x%}" + --> MyTemplate.txt:1:3 + | + 1 | {%let 7=x%} + | ^ close to this token + | --> tests/ui/lit_on_assignment_lhs.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/loop_cycle_empty.stderr b/testing/tests/ui/loop_cycle_empty.stderr index a34673ea8..87cbf2032 100644 --- a/testing/tests/ui/loop_cycle_empty.stderr +++ b/testing/tests/ui/loop_cycle_empty.stderr @@ -1,6 +1,9 @@ error: loop.cycle(…) cannot use an empty array - --> ForCycleEmpty.txt:1:35 - "[]) }}{{ v }},{% endfor %}" + --> ForCycleEmpty.txt:1:36 + | + 1 | {% for v in values %}{{ loop.cycle([]) }}{{ v }},{% endfor %} + | ^ close to this token + | --> tests/ui/loop_cycle_empty.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr index 6a033e036..89e5a30bc 100644 --- a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr +++ b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr @@ -1,6 +1,9 @@ error: loop.cycle(…) cannot use an empty array - --> ForCycle.txt:1:28 - ".cycle(\"r\", \"g\", \"b\") }}{{ v }},{% endfo"... + --> ForCycle.txt:1:29 + | + 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 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/macro-super.stderr b/testing/tests/ui/macro-super.stderr index 2437cdf43..9c206ca3d 100644 --- a/testing/tests/ui/macro-super.stderr +++ b/testing/tests/ui/macro-super.stderr @@ -1,6 +1,9 @@ error: 'super' is not a valid name for a macro - failed to parse template source at row 1, column 2 near: - "- macro super() -%}{%- endmacro -%}" + --> :1:3 + | + 1 | {%- macro super() -%}{%- endmacro -%} + | ^ close to this token + | --> tests/ui/macro-super.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/macro.stderr b/testing/tests/ui/macro.stderr index f2011721a..1dd23ead8 100644 --- a/testing/tests/ui/macro.stderr +++ b/testing/tests/ui/macro.stderr @@ -1,6 +1,9 @@ error: macro "thrice" expected 1 argument, found 2 - --> InvalidNumberOfArgs.html:5:2 - "- call thrice(2, 3) -%}" + --> InvalidNumberOfArgs.html:5:3 + | + 5 | {%- call thrice(2, 3) -%} + | ^ close to this token + | --> tests/ui/macro.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: macro "thrice" expected 1 argument, found 2 = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro "thrice" expected 2 arguments, found 0 - --> InvalidNumberOfArgs2.html:5:2 - "- call thrice() -%}" + --> InvalidNumberOfArgs2.html:5:3 + | + 5 | {%- call thrice() -%} + | ^ close to this token + | --> tests/ui/macro.rs:11:10 | 11 | #[derive(Template)] @@ -19,8 +25,11 @@ error: macro "thrice" expected 2 arguments, found 0 = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro "thrice" expected 0 arguments, found 2 - --> InvalidNumberOfArgs3.html:4:2 - "- call thrice(1, 2) -%}" + --> InvalidNumberOfArgs3.html:4:3 + | + 4 | {%- call thrice(1, 2) -%} + | ^ close to this token + | --> tests/ui/macro.rs:19:10 | 19 | #[derive(Template)] diff --git a/testing/tests/ui/macro_named_argument.stderr b/testing/tests/ui/macro_named_argument.stderr index e31ed0e48..dd754b133 100644 --- a/testing/tests/ui/macro_named_argument.stderr +++ b/testing/tests/ui/macro_named_argument.stderr @@ -1,6 +1,9 @@ error: no argument named `param3` in macro "thrice" - --> InvalidNamedArg.html:5:2 - "- call thrice(param1=2, param3=3) -%}" + --> InvalidNamedArg.html:5:3 + | + 5 | {%- call thrice(param1=2, param3=3) -%} + | ^ close to this token + | --> tests/ui/macro_named_argument.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: no argument named `param3` in macro "thrice" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: named argument `param1` was passed more than once - failed to parse template source at row 5, column 15 near: - "(param1=2, param1=3) -%}" + --> :5:16 + | + 5 | {%- call thrice(param1=2, param1=3) -%} + | ^ close to this token + | --> tests/ui/macro_named_argument.rs:11:10 | 11 | #[derive(Template)] @@ -18,8 +24,12 @@ error: named argument `param1` was passed more than once | = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) -error: failed to parse template source at row 5, column 29 near: - "| filter(param1=12) -%}" +error: failed to parse template source + --> :5:30 + | + 5 | {%- call thrice(3, param1=2) | filter(param1=12) -%} + | ^ close to this token + | --> tests/ui/macro_named_argument.rs:20:10 | 20 | #[derive(Template)] @@ -28,8 +38,11 @@ error: failed to parse template source at row 5, column 29 near: = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: named arguments must always be passed last - failed to parse template source at row 4, column 15 near: - "(param1=2, 3) -%}" + --> :4:16 + | + 4 | {%- call thrice(param1=2, 3) -%} + | ^ close to this token + | --> tests/ui/macro_named_argument.rs:29:10 | 29 | #[derive(Template)] @@ -38,8 +51,11 @@ error: named arguments must always be passed last = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot have unnamed argument (`param2`) after named argument in macro "thrice" - --> InvalidNamedArg5.html:4:2 - "- call thrice(3, param1=2) -%}" + --> InvalidNamedArg5.html:4:3 + | + 4 | {%- call thrice(3, param1=2) -%} + | ^ close to this token + | --> tests/ui/macro_named_argument.rs:37:10 | 37 | #[derive(Template)] diff --git a/testing/tests/ui/match_with_extra.stderr b/testing/tests/ui/match_with_extra.stderr index 841ee2efb..b68ee3666 100644 --- a/testing/tests/ui/match_with_extra.stderr +++ b/testing/tests/ui/match_with_extra.stderr @@ -1,5 +1,9 @@ -error: failed to parse template source at row 3, column 4 near: - "// Help, I forgot how to write comments!"... +error: failed to parse template source + --> :3:5 + | + 3 | // Help, I forgot how to write comments! + | ^ close to this token + | --> tests/ui/match_with_extra.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/multiple_extends.stderr b/testing/tests/ui/multiple_extends.stderr index 878349269..64b5a5a21 100644 --- a/testing/tests/ui/multiple_extends.stderr +++ b/testing/tests/ui/multiple_extends.stderr @@ -1,6 +1,9 @@ error: multiple extend blocks found - --> MyTemplate4.txt:3:2 - " extends \"foo.html\" %}\n" + --> MyTemplate4.txt:3:3 + | + 3 | {% extends "foo.html" %} + | ^ close to this token + | --> tests/ui/multiple_extends.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/name_mismatch_endblock.stderr b/testing/tests/ui/name_mismatch_endblock.stderr index 8894e13a4..b09b199bd 100644 --- a/testing/tests/ui/name_mismatch_endblock.stderr +++ b/testing/tests/ui/name_mismatch_endblock.stderr @@ -1,6 +1,9 @@ error: expected name `foo` in `endblock` tag, found `not_foo` - failed to parse template source at row 1, column 27 near: - "not_foo %}" + --> :1:28 + | + 1 | {% block foo %}{% endblock not_foo %} + | ^ close to this token + | --> tests/ui/name_mismatch_endblock.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/name_mismatch_endmacro.stderr b/testing/tests/ui/name_mismatch_endmacro.stderr index 14e7d0a6f..e8919b37d 100644 --- a/testing/tests/ui/name_mismatch_endmacro.stderr +++ b/testing/tests/ui/name_mismatch_endmacro.stderr @@ -1,6 +1,9 @@ error: expected name `foo` in `endmacro` tag, found `not_foo` - failed to parse template source at row 1, column 41 near: - "not_foo %}" + --> :1:42 + | + 1 | {% macro foo(arg) %} {{arg}} {% endmacro not_foo %} + | ^ close to this token + | --> tests/ui/name_mismatch_endmacro.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/no-such-escaper.stderr b/testing/tests/ui/no-such-escaper.stderr index 12fbeac5c..58e90ca73 100644 --- a/testing/tests/ui/no-such-escaper.stderr +++ b/testing/tests/ui/no-such-escaper.stderr @@ -1,6 +1,9 @@ error: invalid escaper 'latex' for `escape` filter. The available extensions are: "", "htm", "html", "j2", "jinja", "jinja2", "md", "none", "svg", "txt", "xml", "yml" - --> LocalEscaper.html:1:38 - "text|escape(\"latex\")}}`." + --> LocalEscaper.html:1:39 + | + 1 | In LaTeX you write `{{text}}` like `{{text|escape("latex")}}`. + | ^ close to this token + | --> tests/ui/no-such-escaper.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/num-suffix.stderr b/testing/tests/ui/num-suffix.stderr index 4ee8d3823..e632f9320 100644 --- a/testing/tests/ui/num-suffix.stderr +++ b/testing/tests/ui/num-suffix.stderr @@ -1,6 +1,9 @@ error: unknown integer suffix `x` - failed to parse template source at row 1, column 3 near: - "0x0x }}" + --> :1:4 + | + 1 | {{ 0x0x }} + | ^ close to this token + | --> tests/ui/num-suffix.rs:4:10 | 4 | #[derive(Template)] @@ -9,8 +12,11 @@ error: unknown integer suffix `x` = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unknown float suffix `f127` - failed to parse template source at row 1, column 3 near: - "0.0_f127 }}" + --> :1:4 + | + 1 | {{ 0.0_f127 }} + | ^ close to this token + | --> tests/ui/num-suffix.rs:11:10 | 11 | #[derive(Template)] @@ -19,8 +25,11 @@ error: unknown float suffix `f127` = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unknown number suffix `u321` - failed to parse template source at row 1, column 3 near: - "654u321 }}" + --> :1:4 + | + 1 | {{ 654u321 }} + | ^ close to this token + | --> tests/ui/num-suffix.rs:18:10 | 18 | #[derive(Template)] diff --git a/testing/tests/ui/ref_deref.stderr b/testing/tests/ui/ref_deref.stderr index a6dd2fbf0..509a94d66 100644 --- a/testing/tests/ui/ref_deref.stderr +++ b/testing/tests/ui/ref_deref.stderr @@ -1,5 +1,9 @@ -error: failed to parse template source at row 1, column 7 near: - "*x = 2 %}" +error: failed to parse template source + --> :1:8 + | + 1 | {% let *x = 2 %} + | ^ close to this token + | --> tests/ui/ref_deref.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/space-pipe.stderr b/testing/tests/ui/space-pipe.stderr index 4f273d380..578eaaa97 100644 --- a/testing/tests/ui/space-pipe.stderr +++ b/testing/tests/ui/space-pipe.stderr @@ -1,7 +1,10 @@ error: the filter operator `|` must not be preceded by any whitespace characters the binary OR operator is called `bitor` in rinja - failed to parse template source at row 1, column 3 near: - " |lower}}" + --> :1:4 + | + 1 | {{a |lower}} + | ^ close to this token + | --> tests/ui/space-pipe.rs:9:10 | 9 | #[derive(Template)] @@ -11,8 +14,11 @@ error: the filter operator `|` must not be preceded by any whitespace characters error: the filter operator `|` must not be preceded by any whitespace characters the binary OR operator is called `bitor` in rinja - failed to parse template source at row 1, column 3 near: - " | lower}}" + --> :1:4 + | + 1 | {{a | lower}} + | ^ close to this token + | --> tests/ui/space-pipe.rs:21:10 | 21 | #[derive(Template)] diff --git a/testing/tests/ui/typo_in_keyword.stderr b/testing/tests/ui/typo_in_keyword.stderr index a869bb5cc..bc88cfabb 100644 --- a/testing/tests/ui/typo_in_keyword.stderr +++ b/testing/tests/ui/typo_in_keyword.stderr @@ -1,5 +1,9 @@ -error: failed to parse template source at row 1, column 26 near: - "endfo%}\n12345678901234567890123456789012"... +error: failed to parse template source + --> :1:27 + | + 1 | {%for i in 1..=10%}{{i}}{%endfo%} + | ^ close to this token + | --> tests/ui/typo_in_keyword.rs:3:10 | 3 | #[derive(Template)] diff --git a/testing/tests/ui/unclosed-nodes.stderr b/testing/tests/ui/unclosed-nodes.stderr index aa393544a..ed63f6eb6 100644 --- a/testing/tests/ui/unclosed-nodes.stderr +++ b/testing/tests/ui/unclosed-nodes.stderr @@ -1,6 +1,9 @@ error: unclosed expression, missing "}}" - failed to parse template source at row 1, column 0 near: - "{{ expr" + --> :1:1 + | + 1 | {{ expr + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:3:10 | 3 | #[derive(Template)] @@ -9,8 +12,11 @@ error: unclosed expression, missing "}}" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed expression, missing "}}" - failed to parse template source at row 1, column 0 near: - "{{ expr " + --> :1:1 + | + 1 | {{ expr + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:7:10 | 7 | #[derive(Template)] @@ -19,8 +25,11 @@ error: unclosed expression, missing "}}" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed expression, missing "}}" - failed to parse template source at row 1, column 0 near: - "{{ expr -" + --> :1:1 + | + 1 | {{ expr - + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:11:10 | 11 | #[derive(Template)] @@ -28,8 +37,12 @@ error: unclosed expression, missing "}}" | = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) -error: failed to parse template source at row 1, column 9 near: - "}" +error: failed to parse template source + --> :1:10 + | + 1 | {{ expr -} + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:15:10 | 15 | #[derive(Template)] @@ -38,8 +51,11 @@ error: failed to parse template source at row 1, column 9 near: = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed block, missing "%}" - failed to parse template source at row 1, column 0 near: - "{% let x" + --> :1:1 + | + 1 | {% let x + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:19:10 | 19 | #[derive(Template)] @@ -48,8 +64,11 @@ error: unclosed block, missing "%}" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed block, missing "%}" - failed to parse template source at row 1, column 0 near: - "{% let x " + --> :1:1 + | + 1 | {% let x + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:23:10 | 23 | #[derive(Template)] @@ -58,8 +77,11 @@ error: unclosed block, missing "%}" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed block, missing "%}" - failed to parse template source at row 1, column 0 near: - "{% let x -" + --> :1:1 + | + 1 | {% let x - + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:27:10 | 27 | #[derive(Template)] @@ -67,8 +89,12 @@ error: unclosed block, missing "%}" | = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) -error: failed to parse template source at row 1, column 10 near: - "%" +error: failed to parse template source + --> :1:11 + | + 1 | {% let x -% + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:31:10 | 31 | #[derive(Template)] @@ -77,8 +103,11 @@ error: failed to parse template source at row 1, column 10 near: = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed comment, missing "#}" - failed to parse template source at row 1, column 2 near: - " comment" + --> :1:3 + | + 1 | {# comment + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:35:10 | 35 | #[derive(Template)] @@ -87,8 +116,11 @@ error: unclosed comment, missing "#}" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed comment, missing "#}" - failed to parse template source at row 1, column 2 near: - " comment " + --> :1:3 + | + 1 | {# comment + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:39:10 | 39 | #[derive(Template)] @@ -97,8 +129,11 @@ error: unclosed comment, missing "#}" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed comment, missing "#}" - failed to parse template source at row 1, column 2 near: - " comment -" + --> :1:3 + | + 1 | {# comment - + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:43:10 | 43 | #[derive(Template)] @@ -107,8 +142,11 @@ error: unclosed comment, missing "#}" = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error: unclosed comment, missing "#}" - failed to parse template source at row 1, column 2 near: - " comment -#" + --> :1:3 + | + 1 | {# comment -# + | ^ close to this token + | --> tests/ui/unclosed-nodes.rs:47:10 | 47 | #[derive(Template)] From fa8c936cff10384f1b7935b45b2f52adec2215ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Mon, 29 Jul 2024 13:42:45 +0200 Subject: [PATCH 2/7] derive: way less noisy error messages --- rinja_derive/src/config.rs | 51 ++-- rinja_derive/src/input.rs | 249 +++++++++--------- rinja_derive/src/lib.rs | 38 ++- testing/tests/ui/as-primitive-type.stderr | 48 ++-- testing/tests/ui/block_in_filter_block.stderr | 8 +- .../tests/ui/blocks_below_top_level.stderr | 24 +- testing/tests/ui/break_outside_of_loop.stderr | 8 +- testing/tests/ui/char_literal.stderr | 64 ++--- testing/tests/ui/cycle.stderr | 8 +- testing/tests/ui/cycle2.stderr | 8 +- .../ui/duplicated_template_attribute.stderr | 8 +- testing/tests/ui/error_file_path.stderr | 24 +- testing/tests/ui/excessive_nesting.stderr | 8 +- testing/tests/ui/extends.stderr | 16 +- testing/tests/ui/filter-recursion.stderr | 8 +- testing/tests/ui/filter_block_ws.stderr | 8 +- testing/tests/ui/include-a-folder.stderr | 8 +- testing/tests/ui/incorrect_path.stderr | 8 +- testing/tests/ui/is_defined.stderr | 48 ++-- testing/tests/ui/iso646.stderr | 24 +- testing/tests/ui/json-too-many-args.stderr | 8 +- .../ui/let_destructuring_has_rest.stderr | 40 ++- testing/tests/ui/lit_on_assignment_lhs.stderr | 8 +- testing/tests/ui/loop_cycle_empty.stderr | 8 +- .../ui/loop_cycle_wrong_argument_count.stderr | 8 +- testing/tests/ui/macro-super.stderr | 8 +- testing/tests/ui/macro.stderr | 24 +- testing/tests/ui/macro_named_argument.stderr | 40 ++- testing/tests/ui/match_with_extra.stderr | 8 +- testing/tests/ui/multiple_extends.stderr | 8 +- .../tests/ui/name_mismatch_endblock.stderr | 8 +- .../tests/ui/name_mismatch_endmacro.stderr | 8 +- testing/tests/ui/no-such-escaper.stderr | 16 +- testing/tests/ui/no_template_attribute.stderr | 8 +- testing/tests/ui/num-suffix.stderr | 24 +- testing/tests/ui/ref_deref.stderr | 8 +- testing/tests/ui/space-pipe.stderr | 18 +- testing/tests/ui/typo_in_keyword.stderr | 8 +- testing/tests/ui/unclosed-nodes.stderr | 96 +++---- 39 files changed, 437 insertions(+), 583 deletions(-) diff --git a/rinja_derive/src/config.rs b/rinja_derive/src/config.rs index 4272495de..8defbf790 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,13 +366,16 @@ 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) }) } #[cfg(not(feature = "config"))] fn from_toml_str(_: &str) -> Result, CompileError> { - Err(CompileError::no_file_info("TOML support not available")) + Err(CompileError::no_file_info( + "TOML support not available", + None, + )) } } @@ -428,13 +439,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,57 @@ 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(); + let mut args = Self { + span, + ..Self::default() + }; // 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 +327,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 +406,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 +482,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 +515,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..47599cfc0 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,10 +134,23 @@ 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())?; - let input = TemplateInput::new(ast, config, &template_args)?; + let input = TemplateInput::new(ast, config, template_args)?; let mut templates = HashMap::new(); input.find_used_templates(&mut templates)?; @@ -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")] + | ^^^^^^^^ From c3639ec14a2a43190569f6bb13c1adff92e0eae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Mon, 29 Jul 2024 15:38:28 +0200 Subject: [PATCH 3/7] derive: use source/path as error source span --- rinja_derive/src/config.rs | 25 ++++++---- rinja_derive/src/generator.rs | 15 ++++-- rinja_derive/src/heritage.rs | 16 +++++-- rinja_derive/src/input.rs | 45 ++++++++++++----- rinja_derive/src/lib.rs | 6 ++- testing/templates/latex-file.tex | 1 + testing/templates/transclude-there.html | 1 + testing/tests/ui/as-primitive-type.stderr | 24 +++++----- testing/tests/ui/block_in_filter_block.stderr | 6 +-- .../tests/ui/blocks_below_top_level.stderr | 12 ++--- testing/tests/ui/break_outside_of_loop.stderr | 6 +-- testing/tests/ui/char_literal.stderr | 32 ++++++------- testing/tests/ui/cycle.stderr | 4 +- testing/tests/ui/cycle2.stderr | 4 +- testing/tests/ui/error_file_path.stderr | 12 ++--- testing/tests/ui/excessive_nesting.stderr | 6 +-- testing/tests/ui/extends.stderr | 12 ++--- testing/tests/ui/filter-recursion.stderr | 4 +- testing/tests/ui/filter_block_ws.stderr | 4 +- testing/tests/ui/include-a-folder.stderr | 4 +- testing/tests/ui/incorrect_path.stderr | 4 +- testing/tests/ui/is_defined.stderr | 36 +++++++------- testing/tests/ui/iso646.stderr | 12 ++--- testing/tests/ui/json-too-many-args.stderr | 4 +- .../ui/let_destructuring_has_rest.stderr | 20 ++++---- testing/tests/ui/lit_on_assignment_lhs.stderr | 6 +-- testing/tests/ui/loop_cycle_empty.stderr | 6 +-- .../ui/loop_cycle_wrong_argument_count.stderr | 6 +-- testing/tests/ui/macro-super.stderr | 4 +- testing/tests/ui/macro.stderr | 12 ++--- testing/tests/ui/macro_named_argument.stderr | 20 ++++---- testing/tests/ui/match_with_extra.stderr | 6 +-- testing/tests/ui/multiple_extends.stderr | 4 +- .../tests/ui/name_mismatch_endblock.stderr | 4 +- .../tests/ui/name_mismatch_endmacro.stderr | 4 +- testing/tests/ui/no-such-escaper.rs | 4 ++ testing/tests/ui/no-such-escaper.stderr | 18 ++++--- testing/tests/ui/num-suffix.stderr | 18 +++---- testing/tests/ui/ref_deref.stderr | 4 +- testing/tests/ui/space-pipe.stderr | 8 ++-- testing/tests/ui/transclude-missing.rs | 11 +++++ testing/tests/ui/transclude-missing.stderr | 21 ++++++++ testing/tests/ui/typo_in_keyword.stderr | 6 +-- testing/tests/ui/unclosed-nodes.stderr | 48 +++++++++---------- 44 files changed, 306 insertions(+), 219 deletions(-) create mode 100644 testing/templates/latex-file.tex create mode 100644 testing/templates/transclude-there.html create mode 100644 testing/tests/ui/transclude-missing.rs create mode 100644 testing/tests/ui/transclude-missing.stderr 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..9f4efad9d 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_none() { + 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..18a00023d 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")] - | ^^^^^^^^ + | ^^^^^^ From 2e887a56a6313fb42efbf4920f1da49a74d21f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Mon, 29 Jul 2024 16:36:22 +0200 Subject: [PATCH 4/7] derive: use config span in error message --- rinja_derive/src/config.rs | 97 +++++++++++++++++---------- rinja_derive/src/input.rs | 4 +- rinja_derive/src/lib.rs | 19 ++++-- testing/delim-clash.toml | 4 ++ testing/delim-too-short.toml | 3 + testing/folder-config.toml/.gitignore | 2 + testing/tests/ui.rs | 53 ++++++++++----- testing/tests/ui/broken-config.rs | 19 ++++++ testing/tests/ui/broken-config.stderr | 25 +++++++ 9 files changed, 167 insertions(+), 59 deletions(-) create mode 100644 testing/delim-clash.toml create mode 100644 testing/delim-too-short.toml create mode 100644 testing/folder-config.toml/.gitignore create mode 100644 testing/tests/ui/broken-config.rs create mode 100644 testing/tests/ui/broken-config.stderr diff --git a/rinja_derive/src/config.rs b/rinja_derive/src/config.rs index e020dd6c1..1a5bc83d0 100644 --- a/rinja_derive/src/config.rs +++ b/rinja_derive/src/config.rs @@ -9,6 +9,7 @@ use std::{env, fs}; use once_map::sync::OnceMap; use parser::node::Whitespace; use parser::{ParseError, Parsed, Syntax}; +use proc_macro2::Span; #[cfg(feature = "config")] use serde::Deserialize; @@ -71,6 +72,7 @@ impl Config { source: &str, config_path: Option<&str>, template_whitespace: Option<&str>, + config_span: Option, ) -> Result<&'static Config, CompileError> { static CACHE: OnceLock>> = OnceLock::new(); @@ -80,9 +82,9 @@ impl Config { config_path: config_path.map(Cow::Borrowed), template_whitespace: template_whitespace.map(Cow::Borrowed), }, - (), + config_span, ConfigKey::to_owned, - |_, key| match Config::new_uncached(key.clone()) { + |config_span, key| match Config::new_uncached(key.clone(), config_span) { Ok(config) => Ok((Arc::clone(&config), config)), Err(err) => Err(err), }, @@ -94,7 +96,10 @@ impl Config { } impl Config { - fn new_uncached(key: OwnedConfigKey) -> Result, CompileError> { + fn new_uncached( + key: OwnedConfigKey, + config_span: Option, + ) -> Result, CompileError> { // SAFETY: the resulting `Config` will keep a reference to the `key` let eternal_key = unsafe { transmute::<&ConfigKey<'_>, &'static ConfigKey<'static>>(key.borrow()) }; @@ -152,7 +157,9 @@ impl Config { let name = raw_s.name; match syntaxes.entry(name.to_string()) { Entry::Vacant(entry) => { - entry.insert(SyntaxAndCache::new(raw_s.try_into()?)); + entry.insert(SyntaxAndCache::new( + raw_s.to_syntax(config_span, file_info.as_ref())?, + )); } Entry::Occupied(_) => { return Err(CompileError::new( @@ -300,10 +307,12 @@ impl<'a> SyntaxAndCache<'a> { } } -impl<'a> TryInto> for RawSyntax<'a> { - type Error = CompileError; - - fn try_into(self) -> Result, Self::Error> { +impl<'a> RawSyntax<'a> { + fn to_syntax( + &self, + config_span: Option, + file_info: Option<&FileInfo<'_>>, + ) -> Result, CompileError> { let default = Syntax::default(); let syntax = Syntax { block_start: self.block_start.unwrap_or(default.block_start), @@ -323,14 +332,16 @@ impl<'a> TryInto> for RawSyntax<'a> { syntax.comment_end, ] { if s.len() < 2 { - return Err(CompileError::no_file_info( + return Err(CompileError::new_with_span( format!("delimiters must be at least two characters long: {s:?}"), - None, + file_info.copied(), + config_span, )); } else if s.chars().any(|c| c.is_whitespace()) { - return Err(CompileError::no_file_info( + return Err(CompileError::new_with_span( format!("delimiters may not contain white spaces: {s:?}"), - None, + file_info.copied(), + config_span, )); } } @@ -341,11 +352,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( + return Err(CompileError::new_with_span( format!( "a delimiter may not be the prefix of another delimiter: {s1:?} vs {s2:?}", ), - None, + file_info.copied(), + config_span, )); } } @@ -431,7 +443,10 @@ struct RawEscaper<'a> { extensions: Vec<&'a str>, } -pub(crate) fn read_config_file(config_path: Option<&str>) -> Result { +pub(crate) fn read_config_file( + config_path: Option<&str>, + span: Option, +) -> Result { let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let filename = match config_path { Some(config_path) => root.join(config_path), @@ -439,13 +454,16 @@ pub(crate) fn read_config_file(config_path: Option<&str>) -> Result, pub(crate) whitespace: Option, pub(crate) template_span: Option, + pub(crate) config_span: Option, } impl TemplateArgs { @@ -399,6 +400,7 @@ impl TemplateArgs { set_template_str_attr(ident, value, &mut args.syntax)?; } else if ident == "config" { set_template_str_attr(ident, value, &mut args.config)?; + args.config_span = Some(ident.span()) } else if ident == "whitespace" { set_template_str_attr(ident, value, &mut args.whitespace)?; } else { @@ -629,7 +631,7 @@ mod tests { #[test] fn get_source() { - let path = Config::new("", None, None) + let path = Config::new("", None, None, 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 7dbd43a5e..e7a03e60d 100644 --- a/rinja_derive/src/lib.rs +++ b/rinja_derive/src/lib.rs @@ -109,7 +109,7 @@ pub fn derive_template(input: TokenStream12) -> TokenStream12 { fn build_skeleton(ast: &syn::DeriveInput) -> Result { let template_args = TemplateArgs::fallback(); - let config = Config::new("", None, None)?; + let config = Config::new("", None, None, None)?; let input = TemplateInput::new(ast, config, &template_args)?; let mut contexts = HashMap::new(); let parsed = parser::Parsed::default(); @@ -152,8 +152,13 @@ fn build_template_inner( 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())?; + let s = read_config_file(config_path, template_args.config_span)?; + let config = Config::new( + &s, + config_path, + template_args.whitespace.as_deref(), + template_args.config_span, + )?; let input = TemplateInput::new(ast, config, template_args)?; let mut templates = HashMap::new(); @@ -209,8 +214,14 @@ struct CompileError { impl CompileError { fn new(msg: S, file_info: Option>) -> Self { - let span = None; + Self::new_with_span(msg, file_info, None) + } + fn new_with_span( + msg: S, + file_info: Option>, + span: Option, + ) -> Self { if let Some(FileInfo { path, source: Some(source), diff --git a/testing/delim-clash.toml b/testing/delim-clash.toml new file mode 100644 index 000000000..c5be7728e --- /dev/null +++ b/testing/delim-clash.toml @@ -0,0 +1,4 @@ +[[syntax]] +name = "delim-clash" +block_start = "<<<" +expr_start = "<<<<" diff --git a/testing/delim-too-short.toml b/testing/delim-too-short.toml new file mode 100644 index 000000000..53610ebf4 --- /dev/null +++ b/testing/delim-too-short.toml @@ -0,0 +1,3 @@ +[[syntax]] +name = "delim-too-short" +block_start = "<" diff --git a/testing/folder-config.toml/.gitignore b/testing/folder-config.toml/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/testing/folder-config.toml/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/testing/tests/ui.rs b/testing/tests/ui.rs index bc92bf379..9ead429fe 100644 --- a/testing/tests/ui.rs +++ b/testing/tests/ui.rs @@ -1,7 +1,7 @@ #![cfg(not(windows))] use std::os::unix::fs::symlink; -use std::path::Path; +use std::path::PathBuf; use trybuild::TestCases; @@ -12,25 +12,44 @@ fn ui() { // To be able to use existing templates, we create a link to the `templates` folder. let manifest_dir = match std::env::var("CARGO_MANIFEST_DIR") { - Ok(manifest_dir) => manifest_dir, + Ok(manifest_dir) => PathBuf::from(manifest_dir), Err(_) => panic!("you need to run tests with `cargo`"), }; - let target = Path::new(&manifest_dir).join("../target/tests/trybuild/rinja_testing"); - if !target.exists() { - if let Err(err) = std::fs::create_dir_all(&target) { - panic!("failed to create folder `{}`: {err:?}", target.display()); + + let target_crate_root = manifest_dir.join("../target/tests/trybuild/rinja_testing"); + if !target_crate_root.exists() { + if let Err(err) = std::fs::create_dir_all(&target_crate_root) { + panic!( + "failed to create folder `{}`: {err:?}", + target_crate_root.display() + ); } } - let target = target.canonicalize().unwrap().join("templates"); - if target.exists() { - return; - } - let original = Path::new(&manifest_dir).join("templates"); - if symlink(&original, &target).is_err() { - panic!( - "failed to create to create link on `{}` as `{}`", - original.display(), - target.display() - ); + let target_crate_root = target_crate_root.canonicalize().unwrap(); + + let symlink = |name: &str| { + let target = target_crate_root.join(name); + if !target.exists() { + let original = manifest_dir.join(name); + if symlink(&original, &target).is_err() { + panic!( + "failed to create to create link on `{}` as `{}`", + original.display(), + target.display(), + ); + } + } + }; + + // soft-link the templates folder + symlink("templates"); + + // soft-link toml configs + for entry in manifest_dir.read_dir().unwrap().filter_map(Result::ok) { + if let Some(name) = entry.file_name().to_str() { + if name != "Cargo.toml" || !name.ends_with(".toml") { + symlink(name); + } + } } } diff --git a/testing/tests/ui/broken-config.rs b/testing/tests/ui/broken-config.rs new file mode 100644 index 000000000..b41f95046 --- /dev/null +++ b/testing/tests/ui/broken-config.rs @@ -0,0 +1,19 @@ +use rinja::Template; + +#[derive(Template)] +#[template(source = "", ext = "txt", config = "no-such-config.toml")] +struct NoSuchConfig; + +#[derive(Template)] +#[template(source = "", ext = "txt", config = "folder-config.toml")] +struct FolderConfig; + +#[derive(Template)] +#[template(source = "", ext = "txt", config = "delim-clash.toml")] +struct DelimClash; + +#[derive(Template)] +#[template(source = "", ext = "txt", config = "delim-too-short.toml")] +struct DelimTooShort; + +fn main() {} diff --git a/testing/tests/ui/broken-config.stderr b/testing/tests/ui/broken-config.stderr new file mode 100644 index 000000000..8765b02b7 --- /dev/null +++ b/testing/tests/ui/broken-config.stderr @@ -0,0 +1,25 @@ +error: `$WORKSPACE/target/tests/trybuild/rinja_testing/no-such-config.toml` does not exist + --> tests/ui/broken-config.rs:4:38 + | +4 | #[template(source = "", ext = "txt", config = "no-such-config.toml")] + | ^^^^^^ + +error: unable to read $WORKSPACE/target/tests/trybuild/rinja_testing/folder-config.toml: Is a directory (os error 21) + --> tests/ui/broken-config.rs:8:38 + | +8 | #[template(source = "", ext = "txt", config = "folder-config.toml")] + | ^^^^^^ + +error: a delimiter may not be the prefix of another delimiter: "<<<" vs "<<<<" + --> testing/delim-clash.toml + --> tests/ui/broken-config.rs:12:38 + | +12 | #[template(source = "", ext = "txt", config = "delim-clash.toml")] + | ^^^^^^ + +error: delimiters must be at least two characters long: "<" + --> testing/delim-too-short.toml + --> tests/ui/broken-config.rs:16:38 + | +16 | #[template(source = "", ext = "txt", config = "delim-too-short.toml")] + | ^^^^^^ From 821a147b37c14ebf005ac79f9b9f335ee576a5f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Mon, 29 Jul 2024 18:38:32 +0200 Subject: [PATCH 5/7] Doens't work: no indentation --- rinja_derive/src/lib.rs | 48 +++++++---- testing/tests/ui/as-primitive-type.stderr | 42 ++-------- testing/tests/ui/block_in_filter_block.stderr | 7 +- .../tests/ui/blocks_below_top_level.stderr | 21 +---- testing/tests/ui/break_outside_of_loop.stderr | 7 +- testing/tests/ui/char_literal.stderr | 56 ++----------- testing/tests/ui/error_file_path.stderr | 21 +---- testing/tests/ui/excessive_nesting.stderr | 7 +- testing/tests/ui/extends.stderr | 14 +--- testing/tests/ui/filter-recursion.stderr | 7 +- testing/tests/ui/filter_block_ws.stderr | 7 +- testing/tests/ui/include-a-folder.stderr | 7 +- testing/tests/ui/is_defined.stderr | 42 ++-------- testing/tests/ui/iso646.stderr | 22 +---- testing/tests/ui/json-too-many-args.stderr | 7 +- .../ui/let_destructuring_has_rest.stderr | 38 ++------- testing/tests/ui/lit_on_assignment_lhs.stderr | 7 +- testing/tests/ui/loop_cycle_empty.stderr | 7 +- .../ui/loop_cycle_wrong_argument_count.stderr | 7 +- testing/tests/ui/macro-super.stderr | 7 +- testing/tests/ui/macro.stderr | 21 +---- testing/tests/ui/macro_named_argument.stderr | 35 ++------ testing/tests/ui/match_with_extra.stderr | 7 +- testing/tests/ui/multiple_extends.stderr | 7 +- .../tests/ui/name_mismatch_endblock.stderr | 7 +- .../tests/ui/name_mismatch_endmacro.stderr | 7 +- testing/tests/ui/no-such-escaper.stderr | 7 +- testing/tests/ui/num-suffix.stderr | 21 +---- testing/tests/ui/ref_deref.stderr | 7 +- testing/tests/ui/space-pipe.stderr | 16 +--- testing/tests/ui/transclude-missing.stderr | 14 +--- testing/tests/ui/typo_in_keyword.stderr | 7 +- testing/tests/ui/unclosed-nodes.stderr | 84 +++---------------- 33 files changed, 111 insertions(+), 510 deletions(-) diff --git a/rinja_derive/src/lib.rs b/rinja_derive/src/lib.rs index e7a03e60d..276e46040 100644 --- a/rinja_derive/src/lib.rs +++ b/rinja_derive/src/lib.rs @@ -25,6 +25,7 @@ use proc_macro::TokenStream as TokenStream12; #[cfg(feature = "__standalone")] use proc_macro2::TokenStream as TokenStream12; use proc_macro2::{Span, TokenStream}; +use syn::parse_quote_spanned; /// The `Template` derive macro and its `template()` attribute. /// @@ -93,16 +94,26 @@ pub fn derive_template(input: TokenStream12) -> TokenStream12 { let ast = syn::parse2(input.into()).unwrap(); match build_template(&ast) { Ok(source) => source.parse().unwrap(), - Err(mut e) => { - if e.span.is_none() { - e.span = Some(ast.ident.span()); - } - let mut e = e.into_compile_error(); + Err(CompileError { + msg, + span, + rendered, + }) => { + let msg = if rendered { + eprintln!("{msg}"); + "the previous template error derives from" + } else { + &msg + }; + let mut ts: TokenStream = parse_quote_spanned! { + span.unwrap_or(ast.ident.span()) => + ::core::compile_error!(#msg); + }; if let Ok(source) = build_skeleton(&ast) { let source: TokenStream = source.parse().unwrap(); - e.extend(source); + ts.extend(source); } - e.into() + ts.into() } } } @@ -210,6 +221,7 @@ fn build_template_inner( struct CompileError { msg: String, span: Option, + rendered: bool, } impl CompileError { @@ -246,12 +258,11 @@ impl CompileError { .fold(true) .annotation(annotation); let message = Level::Error.title(&label).snippet(snippet); - - let mut msg = Renderer::styled().render(message).to_string(); - if let Some((prefix, _)) = msg.split_once(' ') { - msg.replace_range(..=prefix.len(), ""); - } - return Self { msg, span }; + return Self { + msg: Renderer::styled().render(message).to_string(), + span, + rendered: true, + }; } } @@ -259,19 +270,20 @@ impl CompileError { Some(file_info) => format!("{msg}{file_info}"), None => msg.to_string(), }; - Self { msg, span } + Self { + msg, + span, + rendered: false, + } } fn no_file_info(msg: S, span: Option) -> Self { Self { msg: msg.to_string(), span, + rendered: false, } } - - fn into_compile_error(self) -> TokenStream { - syn::Error::new(self.span.unwrap_or_else(Span::call_site), self.msg).to_compile_error() - } } impl std::error::Error for CompileError {} diff --git a/testing/tests/ui/as-primitive-type.stderr b/testing/tests/ui/as-primitive-type.stderr index 8b79e2609..816a9551b 100644 --- a/testing/tests/ui/as-primitive-type.stderr +++ b/testing/tests/ui/as-primitive-type.stderr @@ -1,64 +1,34 @@ -error: `as` operator expects the name of a primitive type on its right-hand side - --> :1:9 - | - 1 | {{ 1234 as 4567 }} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {{ 1234 as ? }} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {{ 1234 as u1234 }} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {{ 1234 as core::primitive::u32 }} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {{ 1234 as int32_t }} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {{ (1234 + 4 * 12 / 45675445 - 13) as int32_t }} - | ^ close to this token - | +error: the previous template error derives from --> 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 3b96494f0..634827464 100644 --- a/testing/tests/ui/block_in_filter_block.stderr +++ b/testing/tests/ui/block_in_filter_block.stderr @@ -1,9 +1,4 @@ -error: cannot have a block inside a filter block - --> BlockInFilter.html:7:11 - | - 7 | {% block title %}New title{% endblock %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/block_in_filter_block.rs:5:5 | 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 ccb5c1870..e2d1275da 100644 --- a/testing/tests/ui/blocks_below_top_level.stderr +++ b/testing/tests/ui/blocks_below_top_level.stderr @@ -1,31 +1,16 @@ -error: `extends` blocks are not allowed below top level - --> MyTemplate1.txt:3:3 - | - 3 | {% extends "bla.txt" %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 3 | {% macro bla() %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 3 | {% import "bla.txt" as blue %} - | ^ close to this token - | +error: the previous template error derives from --> 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 d1f1da8a6..2edd3f0d8 100644 --- a/testing/tests/ui/break_outside_of_loop.stderr +++ b/testing/tests/ui/break_outside_of_loop.stderr @@ -1,9 +1,4 @@ -error: you can only `break` inside a `for` loop - --> :1:10 - | - 1 | Have a {%break%}, have a parsing error! - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/break_outside_of_loop.rs:5:5 | 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 03d3c3aaa..0f89761f7 100644 --- a/testing/tests/ui/char_literal.stderr +++ b/testing/tests/ui/char_literal.stderr @@ -1,86 +1,46 @@ -error: invalid character - --> testing/templates/char-literals/char-literal-1.txt:1:12 - | - 1 | {% let s = '\a' %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let s = '\x' %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let s = '\x1' %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let s = '\x80' %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let s = '\u' %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let s = '\u{}' %} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let s = '\u{110000}' %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/char_literal.rs:28:12 | 28 | #[template(path = "char-literals/char-literal-7.txt")] | ^^^^ -error: invalid character - --> :1:12 - | - 1 | {% let s = 'aaa' %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/char_literal.rs:32:12 | 32 | #[template(source = "{% let s = 'aaa' %}", ext = "html")] diff --git a/testing/tests/ui/error_file_path.stderr b/testing/tests/ui/error_file_path.stderr index 32eaeaa03..ca0ef8ce5 100644 --- a/testing/tests/ui/error_file_path.stderr +++ b/testing/tests/ui/error_file_path.stderr @@ -1,31 +1,16 @@ -error: failed to parse template source - --> testing/templates/invalid_syntax.html:1:15 - | - 1 | {% let 12 = 0 } - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let 12 = 0 } - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {% let 12 = 0 } - | ^ close to this token - | +error: the previous template error derives from --> 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 4292e3f64..23d2b1833 100644 --- a/testing/tests/ui/excessive_nesting.stderr +++ b/testing/tests/ui/excessive_nesting.stderr @@ -1,9 +1,4 @@ -error: your template code is too deeply nested, or last expression is too complex - --> :14:43 - | - 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 - | +error: the previous template error derives from --> tests/ui/excessive_nesting.rs:5:5 | 5 | source = " diff --git a/testing/tests/ui/extends.stderr b/testing/tests/ui/extends.stderr index 81a6d6e13..bbda6781f 100644 --- a/testing/tests/ui/extends.stderr +++ b/testing/tests/ui/extends.stderr @@ -1,20 +1,10 @@ -error: whitespace control is not allowed on `extends` - --> :1:3 - | - 1 | {%- extends "whatever.html" %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/extends.rs:5:5 | 5 | source = r#"{%- extends "whatever.html" %}"#, | ^^^^^^ -error: whitespace control is not allowed on `extends` - --> :1:3 - | - 1 | {% extends "whatever.html" -%} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/extends.rs:12:5 | 12 | source = r#"{% extends "whatever.html" -%}"#, diff --git a/testing/tests/ui/filter-recursion.stderr b/testing/tests/ui/filter-recursion.stderr index c27777b0d..34b54723c 100644 --- a/testing/tests/ui/filter-recursion.stderr +++ b/testing/tests/ui/filter-recursion.stderr @@ -1,9 +1,4 @@ -error: your template code is too deeply nested, or last expression is too complex - --> testing/templates/filter-recursion.html:1:256 - | - 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 - | +error: the previous template error derives from --> 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 157572844..ea27fb9fd 100644 --- a/testing/tests/ui/filter_block_ws.stderr +++ b/testing/tests/ui/filter_block_ws.stderr @@ -1,9 +1,4 @@ -error: failed to parse template source - --> :1:28 - | - 1 | {% filter lower|indent(2) - %} - | ^ close to this token - | +error: the previous template error derives from --> 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 24736d40b..eb5e8d84a 100644 --- a/testing/tests/ui/include-a-folder.stderr +++ b/testing/tests/ui/include-a-folder.stderr @@ -1,9 +1,4 @@ -error: unable to open template file '$WORKSPACE/target/tests/trybuild/rinja_testing/templates/a_file_that_is_actually_a_folder.html': Is a directory (os error 21) - --> YouCannotIncludeFolders.txt:1:3 - | - 1 | {% include "a_file_that_is_actually_a_folder.html" %} - | ^ close to this token - | +error: the previous template error derives from --> 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/is_defined.stderr b/testing/tests/ui/is_defined.stderr index 6e5ef2e3b..f096a9bbd 100644 --- a/testing/tests/ui/is_defined.stderr +++ b/testing/tests/ui/is_defined.stderr @@ -1,64 +1,34 @@ -error: `is defined` operator can only be used on variables, not on their fields - --> :1:7 - | - 1 | {% if x.y is defined %}{% endif %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/is_defined.rs:6:5 | 6 | source = r#"{% if x.y is defined %}{% endif %}"#, | ^^^^^^ -error: `is defined` operator can only be used on variables - --> :1:7 - | - 1 | {% if true is defined %}{% endif %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/is_defined.rs:13:5 | 13 | source = r#"{% if true is defined %}{% endif %}"#, | ^^^^^^ -error: expected `defined` or `not defined` after `is` - --> :1:7 - | - 1 | {% if true is %}{% endif %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/is_defined.rs:20:5 | 20 | source = r#"{% if true is %}{% endif %}"#, | ^^^^^^ -error: expected `defined` or `not defined` after `is` - --> :1:7 - | - 1 | {% if x is %}{% endif %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/is_defined.rs:27:5 | 27 | source = r#"{% if x is %}{% endif %}"#, | ^^^^^^ -error: expected `defined` or `not defined` after `is` - --> :1:7 - | - 1 | {% if x is blue %}{% endif %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/is_defined.rs:34:5 | 34 | source = r#"{% if x is blue %}{% endif %}"#, | ^^^^^^ -error: expected `defined` or `not defined` after `is` - --> :1:7 - | - 1 | {% if x is blue.red %}{% endif %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/is_defined.rs:41:5 | 41 | source = r#"{% if x is blue.red %}{% endif %}"#, diff --git a/testing/tests/ui/iso646.stderr b/testing/tests/ui/iso646.stderr index 8a7874b78..15bd7084e 100644 --- a/testing/tests/ui/iso646.stderr +++ b/testing/tests/ui/iso646.stderr @@ -1,32 +1,16 @@ -error: the binary AND operator is called `bitand` in rinja - --> :1:7 - | - 1 | {{ a & b }} - | ^ close to this token - | +error: the previous template error derives from --> 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 - --> :1:5 - | - 1 | {{ a | b }} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 1 | {{ a ^ b }} - | ^ close to this token - | +error: the previous template error derives from --> 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 22fbe5681..d08a6d53e 100644 --- a/testing/tests/ui/json-too-many-args.stderr +++ b/testing/tests/ui/json-too-many-args.stderr @@ -1,9 +1,4 @@ -error: unexpected argument(s) in `json` filter - --> OneTwoThree.txt:1:4 - | - 1 | {{ 1|json(2, 3) }} - | ^ close to this token - | +error: the previous template error derives from --> 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 b78b5f304..0e0a2259c 100644 --- a/testing/tests/ui/let_destructuring_has_rest.stderr +++ b/testing/tests/ui/let_destructuring_has_rest.stderr @@ -1,56 +1,28 @@ -error: unexpected `,` character after `..` - note that in a named struct, `..` must come last to ignore other members - --> :2:21 - | - 2 | {%- if let X { a, .., } = x -%}hello {{ a }}{%- endif -%} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/let_destructuring_has_rest.rs:9:12 | 9 | #[template(source = " | ^^^^^^ -error: expected `,` for more members, or `}` as terminator - --> :2:18 - | - 2 | {%- if let X { a .. } = x -%}hello {{ a }}{%- endif -%} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/let_destructuring_has_rest.rs:17:12 | 17 | #[template(source = " | ^^^^^^ -error: expected member, or `}` as terminator - --> :2:19 - | - 2 | {%- if let X { a, 1 } = x -%}hello {{ a }}{%- endif -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 - --> :2:21 - | - 2 | {%- if let X { a, .., b } = x -%}hello {{ a }}{%- endif -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 - --> :2:18 - | - 2 | {%- if let X { .., b } = x -%}hello {{ a }}{%- endif -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 7ceb311fb..99b7f6907 100644 --- a/testing/tests/ui/lit_on_assignment_lhs.stderr +++ b/testing/tests/ui/lit_on_assignment_lhs.stderr @@ -1,9 +1,4 @@ -error: literals are not allowed on the left-hand side of an assignment - --> MyTemplate.txt:1:3 - | - 1 | {%let 7=x%} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/lit_on_assignment_lhs.rs:5:5 | 5 | source = "{%let 7=x%}", diff --git a/testing/tests/ui/loop_cycle_empty.stderr b/testing/tests/ui/loop_cycle_empty.stderr index a946c65fa..a82dc9b77 100644 --- a/testing/tests/ui/loop_cycle_empty.stderr +++ b/testing/tests/ui/loop_cycle_empty.stderr @@ -1,9 +1,4 @@ -error: loop.cycle(…) cannot use an empty array - --> ForCycleEmpty.txt:1:36 - | - 1 | {% for v in values %}{{ loop.cycle([]) }}{{ v }},{% endfor %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/loop_cycle_empty.rs:5:5 | 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 bbe669cf9..140497afb 100644 --- a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr +++ b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr @@ -1,9 +1,4 @@ -error: loop.cycle(…) cannot use an empty array - --> ForCycle.txt:1:29 - | - 1 | {% for v in values %}{{ loop.cycle("r", "g", "b") }}{{ v }},{% endfor %} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/loop_cycle_wrong_argument_count.rs:5:5 | 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 cca29c948..e6834ae2c 100644 --- a/testing/tests/ui/macro-super.stderr +++ b/testing/tests/ui/macro-super.stderr @@ -1,9 +1,4 @@ -error: 'super' is not a valid name for a macro - --> :1:3 - | - 1 | {%- macro super() -%}{%- endmacro -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 af0741f34..c73ade0a3 100644 --- a/testing/tests/ui/macro.stderr +++ b/testing/tests/ui/macro.stderr @@ -1,31 +1,16 @@ -error: macro "thrice" expected 1 argument, found 2 - --> InvalidNumberOfArgs.html:5:3 - | - 5 | {%- call thrice(2, 3) -%} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/macro.rs:4:12 | 4 | #[template(source = "{%- macro thrice(param) -%} | ^^^^^^ -error: macro "thrice" expected 2 arguments, found 0 - --> InvalidNumberOfArgs2.html:5:3 - | - 5 | {%- call thrice() -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 4 | {%- call thrice(1, 2) -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 4bc30e52e..33ceae6b4 100644 --- a/testing/tests/ui/macro_named_argument.stderr +++ b/testing/tests/ui/macro_named_argument.stderr @@ -1,53 +1,28 @@ -error: no argument named `param3` in macro "thrice" - --> InvalidNamedArg.html:5:3 - | - 5 | {%- call thrice(param1=2, param3=3) -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 5 | {%- call thrice(param1=2, param1=3) -%} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/macro_named_argument.rs:12:12 | 12 | #[template(source = "{%- macro thrice(param1, param2) -%} | ^^^^^^ -error: failed to parse template source - --> :5:30 - | - 5 | {%- call thrice(3, param1=2) | filter(param1=12) -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 4 | {%- call thrice(param1=2, 3) -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 - | - 4 | {%- call thrice(3, param1=2) -%} - | ^ close to this token - | +error: the previous template error derives from --> 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 c2b687c1e..596c7e277 100644 --- a/testing/tests/ui/match_with_extra.stderr +++ b/testing/tests/ui/match_with_extra.stderr @@ -1,9 +1,4 @@ -error: failed to parse template source - --> :3:5 - | - 3 | // Help, I forgot how to write comments! - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/match_with_extra.rs:6:5 | 6 | source = r#" diff --git a/testing/tests/ui/multiple_extends.stderr b/testing/tests/ui/multiple_extends.stderr index dbce76a3c..2d0a44a0d 100644 --- a/testing/tests/ui/multiple_extends.stderr +++ b/testing/tests/ui/multiple_extends.stderr @@ -1,9 +1,4 @@ -error: multiple extend blocks found - --> MyTemplate4.txt:3:3 - | - 3 | {% extends "foo.html" %} - | ^ close to this token - | +error: the previous template error derives from --> 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 34a20bcef..d3b21d9b0 100644 --- a/testing/tests/ui/name_mismatch_endblock.stderr +++ b/testing/tests/ui/name_mismatch_endblock.stderr @@ -1,9 +1,4 @@ -error: expected name `foo` in `endblock` tag, found `not_foo` - --> :1:28 - | - 1 | {% block foo %}{% endblock not_foo %} - | ^ close to this token - | +error: the previous template error derives from --> 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 7bfe89f59..b38f88a46 100644 --- a/testing/tests/ui/name_mismatch_endmacro.stderr +++ b/testing/tests/ui/name_mismatch_endmacro.stderr @@ -1,9 +1,4 @@ -error: expected name `foo` in `endmacro` tag, found `not_foo` - --> :1:42 - | - 1 | {% macro foo(arg) %} {{arg}} {% endmacro not_foo %} - | ^ close to this token - | +error: the previous template error derives from --> 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.stderr b/testing/tests/ui/no-such-escaper.stderr index d79e6c862..7691305ea 100644 --- a/testing/tests/ui/no-such-escaper.stderr +++ b/testing/tests/ui/no-such-escaper.stderr @@ -1,9 +1,4 @@ -error: invalid escaper 'latex' for `escape` filter. The available extensions are: "", "htm", "html", "j2", "jinja", "jinja2", "md", "none", "svg", "txt", "xml", "yml" - --> LocalEscaper.html:1:39 - | - 1 | In LaTeX you write `{{text}}` like `{{text|escape("latex")}}`. - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/no-such-escaper.rs:6:5 | 6 | source = r#"In LaTeX you write `{{text}}` like `{{text|escape("latex")}}`."#, diff --git a/testing/tests/ui/num-suffix.stderr b/testing/tests/ui/num-suffix.stderr index 709e6e2d8..281be1aa1 100644 --- a/testing/tests/ui/num-suffix.stderr +++ b/testing/tests/ui/num-suffix.stderr @@ -1,31 +1,16 @@ -error: unknown integer suffix `x` - --> :1:4 - | - 1 | {{ 0x0x }} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/num-suffix.rs:7:5 | 7 | source = "{{ 0x0x }}", | ^^^^^^ -error: unknown float suffix `f127` - --> :1:4 - | - 1 | {{ 0.0_f127 }} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/num-suffix.rs:14:5 | 14 | source = "{{ 0.0_f127 }}", | ^^^^^^ -error: unknown number suffix `u321` - --> :1:4 - | - 1 | {{ 654u321 }} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/num-suffix.rs:21:5 | 21 | source = "{{ 654u321 }}", diff --git a/testing/tests/ui/ref_deref.stderr b/testing/tests/ui/ref_deref.stderr index befd34448..1a25f6fb4 100644 --- a/testing/tests/ui/ref_deref.stderr +++ b/testing/tests/ui/ref_deref.stderr @@ -1,9 +1,4 @@ -error: failed to parse template source - --> :1:8 - | - 1 | {% let *x = 2 %} - | ^ close to this token - | +error: the previous template error derives from --> 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 8153e1a7c..83de4c923 100644 --- a/testing/tests/ui/space-pipe.stderr +++ b/testing/tests/ui/space-pipe.stderr @@ -1,22 +1,10 @@ -error: the filter operator `|` must not be preceded by any whitespace characters - the binary OR operator is called `bitor` in rinja - --> :1:4 - | - 1 | {{a |lower}} - | ^ close to this token - | +error: the previous template error derives from --> 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 - --> :1:4 - | - 1 | {{a | lower}} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/space-pipe.rs:22:25 | 22 | #[template(ext = "txt", source = "{{a | lower}}")] diff --git a/testing/tests/ui/transclude-missing.stderr b/testing/tests/ui/transclude-missing.stderr index 175bb4010..5a0e1e36e 100644 --- a/testing/tests/ui/transclude-missing.stderr +++ b/testing/tests/ui/transclude-missing.stderr @@ -1,20 +1,10 @@ -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 - | +error: the previous template error derives from --> 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 - | +error: the previous template error derives from --> 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 e91011b2b..3bdc833e4 100644 --- a/testing/tests/ui/typo_in_keyword.stderr +++ b/testing/tests/ui/typo_in_keyword.stderr @@ -1,9 +1,4 @@ -error: failed to parse template source - --> :1:27 - | - 1 | {%for i in 1..=10%}{{i}}{%endfo%} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/typo_in_keyword.rs:5:5 | 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 6749c787f..4cc716da9 100644 --- a/testing/tests/ui/unclosed-nodes.stderr +++ b/testing/tests/ui/unclosed-nodes.stderr @@ -1,130 +1,70 @@ -error: unclosed expression, missing "}}" - --> :1:1 - | - 1 | {{ expr - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:4:12 | 4 | #[template(source = "{{ expr", ext = "txt")] | ^^^^^^ -error: unclosed expression, missing "}}" - --> :1:1 - | - 1 | {{ expr - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:8:12 | 8 | #[template(source = "{{ expr ", ext = "txt")] | ^^^^^^ -error: unclosed expression, missing "}}" - --> :1:1 - | - 1 | {{ expr - - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:12:12 | 12 | #[template(source = "{{ expr -", ext = "txt")] | ^^^^^^ -error: failed to parse template source - --> :1:10 - | - 1 | {{ expr -} - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:16:12 | 16 | #[template(source = "{{ expr -}", ext = "txt")] | ^^^^^^ -error: unclosed block, missing "%}" - --> :1:1 - | - 1 | {% let x - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:20:12 | 20 | #[template(source = "{% let x", ext = "txt")] | ^^^^^^ -error: unclosed block, missing "%}" - --> :1:1 - | - 1 | {% let x - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:24:12 | 24 | #[template(source = "{% let x ", ext = "txt")] | ^^^^^^ -error: unclosed block, missing "%}" - --> :1:1 - | - 1 | {% let x - - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:28:12 | 28 | #[template(source = "{% let x -", ext = "txt")] | ^^^^^^ -error: failed to parse template source - --> :1:11 - | - 1 | {% let x -% - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:32:12 | 32 | #[template(source = "{% let x -%", ext = "txt")] | ^^^^^^ -error: unclosed comment, missing "#}" - --> :1:3 - | - 1 | {# comment - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:36:12 | 36 | #[template(source = "{# comment", ext = "txt")] | ^^^^^^ -error: unclosed comment, missing "#}" - --> :1:3 - | - 1 | {# comment - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:40:12 | 40 | #[template(source = "{# comment ", ext = "txt")] | ^^^^^^ -error: unclosed comment, missing "#}" - --> :1:3 - | - 1 | {# comment - - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:44:12 | 44 | #[template(source = "{# comment -", ext = "txt")] | ^^^^^^ -error: unclosed comment, missing "#}" - --> :1:3 - | - 1 | {# comment -# - | ^ close to this token - | +error: the previous template error derives from --> tests/ui/unclosed-nodes.rs:48:12 | 48 | #[template(source = "{# comment -#", ext = "txt")] From 08674bde1183b9224073a3abc1cbb3cdde6eb6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Mon, 29 Jul 2024 21:55:23 +0200 Subject: [PATCH 6/7] derive: without rendered message for now --- rinja_derive/Cargo.toml | 1 - rinja_derive/src/lib.rs | 45 ++--------------- rinja_derive_standalone/Cargo.toml | 1 - testing/tests/ui/as-primitive-type.stderr | 24 +++++++--- testing/tests/ui/block_in_filter_block.stderr | 4 +- .../tests/ui/blocks_below_top_level.stderr | 12 +++-- testing/tests/ui/break_outside_of_loop.stderr | 4 +- testing/tests/ui/char_literal.stderr | 32 +++++++++---- testing/tests/ui/error_file_path.stderr | 12 +++-- testing/tests/ui/excessive_nesting.stderr | 4 +- testing/tests/ui/extends.stderr | 8 +++- testing/tests/ui/filter-recursion.stderr | 4 +- testing/tests/ui/filter_block_ws.stderr | 4 +- testing/tests/ui/include-a-folder.stderr | 4 +- testing/tests/ui/is_defined.stderr | 24 +++++++--- testing/tests/ui/iso646.stderr | 13 +++-- testing/tests/ui/json-too-many-args.stderr | 4 +- .../ui/let_destructuring_has_rest.stderr | 23 +++++++-- testing/tests/ui/lit_on_assignment_lhs.stderr | 4 +- testing/tests/ui/loop_cycle_empty.stderr | 4 +- .../ui/loop_cycle_wrong_argument_count.stderr | 4 +- testing/tests/ui/macro-super.stderr | 4 +- testing/tests/ui/macro.stderr | 12 +++-- testing/tests/ui/macro_named_argument.stderr | 20 ++++++-- testing/tests/ui/match_with_extra.stderr | 4 +- testing/tests/ui/multiple_extends.stderr | 4 +- .../tests/ui/name_mismatch_endblock.stderr | 4 +- .../tests/ui/name_mismatch_endmacro.stderr | 4 +- testing/tests/ui/no-such-escaper.stderr | 4 +- testing/tests/ui/num-suffix.stderr | 12 +++-- testing/tests/ui/ref_deref.stderr | 4 +- testing/tests/ui/space-pipe.stderr | 10 +++- testing/tests/ui/transclude-missing.stderr | 8 +++- testing/tests/ui/typo_in_keyword.stderr | 4 +- testing/tests/ui/unclosed-nodes.stderr | 48 ++++++++++++++----- 35 files changed, 252 insertions(+), 125 deletions(-) diff --git a/rinja_derive/Cargo.toml b/rinja_derive/Cargo.toml index a51606970..9e14897b8 100644 --- a/rinja_derive/Cargo.toml +++ b/rinja_derive/Cargo.toml @@ -26,7 +26,6 @@ with-warp = [] [dependencies] parser = { package = "rinja_parser", version = "0.2.0", path = "../rinja_parser" } -annotate-snippets = "0.11.4" basic-toml = { version = "0.1.1", optional = true } memchr = "2" mime = "0.3" diff --git a/rinja_derive/src/lib.rs b/rinja_derive/src/lib.rs index 276e46040..6788a8df3 100644 --- a/rinja_derive/src/lib.rs +++ b/rinja_derive/src/lib.rs @@ -14,7 +14,6 @@ use std::collections::HashMap; use std::fmt; use std::path::Path; -use annotate_snippets::{Level, Renderer, Snippet}; use config::{read_config_file, Config}; use generator::{Generator, MapChain}; use heritage::{Context, Heritage}; @@ -97,14 +96,8 @@ pub fn derive_template(input: TokenStream12) -> TokenStream12 { Err(CompileError { msg, span, - rendered, + rendered: _rendered, }) => { - let msg = if rendered { - eprintln!("{msg}"); - "the previous template error derives from" - } else { - &msg - }; let mut ts: TokenStream = parse_quote_spanned! { span.unwrap_or(ast.ident.span()) => ::core::compile_error!(#msg); @@ -234,38 +227,6 @@ impl CompileError { file_info: Option>, span: Option, ) -> Self { - if let Some(FileInfo { - path, - source: Some(source), - node_source: Some(node_source), - }) = file_info - { - if source - .as_bytes() - .as_ptr_range() - .contains(&node_source.as_ptr()) - { - let label = msg.to_string(); - let path = match std::env::current_dir() { - Ok(cwd) => strip_common(&cwd, path), - Err(_) => path.display().to_string(), - }; - - let start = node_source.as_ptr() as usize - source.as_ptr() as usize; - let annotation = Level::Error.span(start..start).label("close to this token"); - let snippet = Snippet::source(source) - .origin(&path) - .fold(true) - .annotation(annotation); - let message = Level::Error.title(&label).snippet(snippet); - return Self { - msg: Renderer::styled().render(message).to_string(), - span, - rendered: true, - }; - } - } - let msg = match file_info { Some(file_info) => format!("{msg}{file_info}"), None => msg.to_string(), @@ -362,7 +323,7 @@ fn generate_row_and_column(src: &str, input: &str) -> ErrorInfo { let (row, last_line) = source_before.lines().enumerate().last().unwrap_or_default(); let column = last_line.chars().count(); ErrorInfo { - row, + row: row + 1, column, source_after, } @@ -374,7 +335,7 @@ fn generate_error_info(src: &str, input: &str, file_path: &Path) -> (ErrorInfo, Ok(cwd) => strip_common(&cwd, file_path), Err(_) => file_path.display().to_string(), }; - let error_info = generate_row_and_column(src, input); + let error_info: ErrorInfo = generate_row_and_column(src, input); (error_info, file_path) } diff --git a/rinja_derive_standalone/Cargo.toml b/rinja_derive_standalone/Cargo.toml index 4a1c4a3ba..657daa617 100644 --- a/rinja_derive_standalone/Cargo.toml +++ b/rinja_derive_standalone/Cargo.toml @@ -25,7 +25,6 @@ with-warp = [] [dependencies] parser = { package = "rinja_parser", version = "0.2.0", path = "../rinja_parser" } -annotate-snippets = "0.11.4" basic-toml = { version = "0.1.1", optional = true } memchr = "2" mime = "0.3" diff --git a/testing/tests/ui/as-primitive-type.stderr b/testing/tests/ui/as-primitive-type.stderr index 816a9551b..0d715e109 100644 --- a/testing/tests/ui/as-primitive-type.stderr +++ b/testing/tests/ui/as-primitive-type.stderr @@ -1,34 +1,46 @@ -error: the previous template error derives from +error: `as` operator expects the name of a primitive type on its right-hand side + --> :1:8 + "as 4567 }}" --> tests/ui/as-primitive-type.rs:4:12 | 4 | #[template(source = r#"{{ 1234 as 4567 }}"#, ext = "html")] | ^^^^^^ -error: the previous template error derives from +error: `as` operator expects the name of a primitive type on its right-hand side + --> :1:8 + "as ? }}" --> tests/ui/as-primitive-type.rs:8:12 | 8 | #[template(source = r#"{{ 1234 as ? }}"#, ext = "html")] | ^^^^^^ -error: the previous template error derives from +error: `as` operator expects the name of a primitive type on its right-hand side, found `u1234` + --> :1:8 + "as u1234 }}" --> tests/ui/as-primitive-type.rs:12:12 | 12 | #[template(source = r#"{{ 1234 as u1234 }}"#, ext = "html")] | ^^^^^^ -error: the previous template error derives from +error: `as` operator expects the name of a primitive type on its right-hand side, found `core` + --> :1:8 + "as core::primitive::u32 }}" --> tests/ui/as-primitive-type.rs:16:12 | 16 | #[template(source = r#"{{ 1234 as core::primitive::u32 }}"#, ext = "html")] | ^^^^^^ -error: the previous template error derives from +error: `as` operator expects the name of a primitive type on its right-hand side, found `int32_t` + --> :1:8 + "as int32_t }}" --> tests/ui/as-primitive-type.rs:20:12 | 20 | #[template(source = r#"{{ 1234 as int32_t }}"#, ext = "html")] | ^^^^^^ -error: the previous template error derives from +error: `as` operator expects the name of a primitive type on its right-hand side, found `int32_t` + --> :1:35 + "as int32_t }}" --> 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 634827464..ccd9fda71 100644 --- a/testing/tests/ui/block_in_filter_block.stderr +++ b/testing/tests/ui/block_in_filter_block.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: cannot have a block inside a filter block + --> BlockInFilter.html:7:10 + " block title %}New title{% endblock %}\n a b\n {% endfilter %}\n{%- endblock body %}\n" --> tests/ui/block_in_filter_block.rs:5:5 | 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 e2d1275da..cab6e8a2b 100644 --- a/testing/tests/ui/blocks_below_top_level.stderr +++ b/testing/tests/ui/blocks_below_top_level.stderr @@ -1,16 +1,22 @@ -error: the previous template error derives from +error: `extends` blocks are not allowed below top level + --> MyTemplate1.txt:3:2 + " extends \"bla.txt\" %}\n{% endblock %}\n" --> tests/ui/blocks_below_top_level.rs:4:12 | 4 | #[template(source = r#" | ^^^^^^ -error: the previous template error derives from +error: `macro` blocks are not allowed below top level + --> MyTemplate2.txt:3:2 + " macro bla() %}\n{% endmacro %}\n{% endblock %}\n" --> tests/ui/blocks_below_top_level.rs:12:12 | 12 | #[template(source = r#" | ^^^^^^ -error: the previous template error derives from +error: `import` blocks are not allowed below top level + --> MyTemplate3.txt:3:2 + " import \"bla.txt\" as blue %}\n{% endblock %}\n" --> 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 2edd3f0d8..1bffa3cbe 100644 --- a/testing/tests/ui/break_outside_of_loop.stderr +++ b/testing/tests/ui/break_outside_of_loop.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: you can only `break` inside a `for` loop + --> :1:9 + "break%}, have a parsing error!" --> tests/ui/break_outside_of_loop.rs:5:5 | 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 0f89761f7..058a74497 100644 --- a/testing/tests/ui/char_literal.stderr +++ b/testing/tests/ui/char_literal.stderr @@ -1,46 +1,62 @@ -error: the previous template error derives from +error: invalid character + --> testing/templates/char-literals/char-literal-1.txt:1:11 + "'\\a' %}" --> tests/ui/char_literal.rs:4:12 | 4 | #[template(path = "char-literals/char-literal-1.txt")] | ^^^^ -error: the previous template error derives from +error: invalid character + --> testing/templates/char-literals/char-literal-2.txt:1:11 + "'\\x' %}" --> tests/ui/char_literal.rs:8:12 | 8 | #[template(path = "char-literals/char-literal-2.txt")] | ^^^^ -error: the previous template error derives from +error: invalid character + --> testing/templates/char-literals/char-literal-3.txt:1:11 + "'\\x1' %}" --> tests/ui/char_literal.rs:12:12 | 12 | #[template(path = "char-literals/char-literal-3.txt")] | ^^^^ -error: the previous template error derives from +error: must be a character in the range [\x00-\x7f] + --> testing/templates/char-literals/char-literal-4.txt:1:11 + "'\\x80' %}" --> tests/ui/char_literal.rs:16:12 | 16 | #[template(path = "char-literals/char-literal-4.txt")] | ^^^^ -error: the previous template error derives from +error: invalid character + --> testing/templates/char-literals/char-literal-5.txt:1:11 + "'\\u' %}" --> tests/ui/char_literal.rs:20:12 | 20 | #[template(path = "char-literals/char-literal-5.txt")] | ^^^^ -error: the previous template error derives from +error: invalid character + --> testing/templates/char-literals/char-literal-6.txt:1:11 + "'\\u{}' %}" --> tests/ui/char_literal.rs:24:12 | 24 | #[template(path = "char-literals/char-literal-6.txt")] | ^^^^ -error: the previous template error derives from +error: unicode escape must be at most 10FFFF + --> testing/templates/char-literals/char-literal-7.txt:1:11 + "'\\u{110000}' %}" --> tests/ui/char_literal.rs:28:12 | 28 | #[template(path = "char-literals/char-literal-7.txt")] | ^^^^ -error: the previous template error derives from +error: invalid character + --> :1:11 + "'aaa' %}" --> tests/ui/char_literal.rs:32:12 | 32 | #[template(source = "{% let s = 'aaa' %}", ext = "html")] diff --git a/testing/tests/ui/error_file_path.stderr b/testing/tests/ui/error_file_path.stderr index ca0ef8ce5..4de70066b 100644 --- a/testing/tests/ui/error_file_path.stderr +++ b/testing/tests/ui/error_file_path.stderr @@ -1,16 +1,22 @@ -error: the previous template error derives from +error: failed to parse template source + --> testing/templates/invalid_syntax.html:1:14 + "}" --> tests/ui/error_file_path.rs:4:12 | 4 | #[template(path = "invalid_syntax.html")] | ^^^^ -error: the previous template error derives from +error: failed to parse template source + --> testing/templates/invalid_syntax.html:1:14 + "}" --> tests/ui/error_file_path.rs:8:12 | 8 | #[template(path = "include_invalid_syntax.html")] | ^^^^ -error: the previous template error derives from +error: failed to parse template source + --> testing/templates/invalid_syntax.html:1:14 + "}" --> 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 23d2b1833..46dd682d1 100644 --- a/testing/tests/ui/excessive_nesting.stderr +++ b/testing/tests/ui/excessive_nesting.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: your template code is too deeply nested, or last expression is too complex + --> :14:42 + "%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 200\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 300\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 400\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 500\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 600\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 700\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 800\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 900\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 1000\n " --> tests/ui/excessive_nesting.rs:5:5 | 5 | source = " diff --git a/testing/tests/ui/extends.stderr b/testing/tests/ui/extends.stderr index bbda6781f..7a86ececf 100644 --- a/testing/tests/ui/extends.stderr +++ b/testing/tests/ui/extends.stderr @@ -1,10 +1,14 @@ -error: the previous template error derives from +error: whitespace control is not allowed on `extends` + --> :1:2 + "- extends \"whatever.html\" %}" --> tests/ui/extends.rs:5:5 | 5 | source = r#"{%- extends "whatever.html" %}"#, | ^^^^^^ -error: the previous template error derives from +error: whitespace control is not allowed on `extends` + --> :1:2 + " extends \"whatever.html\" -%}" --> tests/ui/extends.rs:12:5 | 12 | source = r#"{% extends "whatever.html" -%}"#, diff --git a/testing/tests/ui/filter-recursion.stderr b/testing/tests/ui/filter-recursion.stderr index 34b54723c..6626e6f5f 100644 --- a/testing/tests/ui/filter-recursion.stderr +++ b/testing/tests/ui/filter-recursion.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: your template code is too deeply nested, or last expression is too complex + --> testing/templates/filter-recursion.html:1:255 + "|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|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A" --> 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 ea27fb9fd..7487e98ed 100644 --- a/testing/tests/ui/filter_block_ws.stderr +++ b/testing/tests/ui/filter_block_ws.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: failed to parse template source + --> :1:27 + " %}\nHELLO\n{{v}}\n{%- endfilter %}" --> 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 eb5e8d84a..d90135401 100644 --- a/testing/tests/ui/include-a-folder.stderr +++ b/testing/tests/ui/include-a-folder.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: unable to open template file '$WORKSPACE/target/tests/trybuild/rinja_testing/templates/a_file_that_is_actually_a_folder.html': Is a directory (os error 21) + --> YouCannotIncludeFolders.txt:1:2 + " include \"a_file_that_is_actually_a_folder.html\" %}" --> 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/is_defined.stderr b/testing/tests/ui/is_defined.stderr index f096a9bbd..9851d0f4c 100644 --- a/testing/tests/ui/is_defined.stderr +++ b/testing/tests/ui/is_defined.stderr @@ -1,34 +1,46 @@ -error: the previous template error derives from +error: `is defined` operator can only be used on variables, not on their fields + --> :1:6 + "x.y is defined %}{% endif %}" --> tests/ui/is_defined.rs:6:5 | 6 | source = r#"{% if x.y is defined %}{% endif %}"#, | ^^^^^^ -error: the previous template error derives from +error: `is defined` operator can only be used on variables + --> :1:6 + "true is defined %}{% endif %}" --> tests/ui/is_defined.rs:13:5 | 13 | source = r#"{% if true is defined %}{% endif %}"#, | ^^^^^^ -error: the previous template error derives from +error: expected `defined` or `not defined` after `is` + --> :1:6 + "true is %}{% endif %}" --> tests/ui/is_defined.rs:20:5 | 20 | source = r#"{% if true is %}{% endif %}"#, | ^^^^^^ -error: the previous template error derives from +error: expected `defined` or `not defined` after `is` + --> :1:6 + "x is %}{% endif %}" --> tests/ui/is_defined.rs:27:5 | 27 | source = r#"{% if x is %}{% endif %}"#, | ^^^^^^ -error: the previous template error derives from +error: expected `defined` or `not defined` after `is` + --> :1:6 + "x is blue %}{% endif %}" --> tests/ui/is_defined.rs:34:5 | 34 | source = r#"{% if x is blue %}{% endif %}"#, | ^^^^^^ -error: the previous template error derives from +error: expected `defined` or `not defined` after `is` + --> :1:6 + "x is blue.red %}{% endif %}" --> tests/ui/is_defined.rs:41:5 | 41 | source = r#"{% if x is blue.red %}{% endif %}"#, diff --git a/testing/tests/ui/iso646.stderr b/testing/tests/ui/iso646.stderr index 15bd7084e..f754c8ca0 100644 --- a/testing/tests/ui/iso646.stderr +++ b/testing/tests/ui/iso646.stderr @@ -1,16 +1,23 @@ -error: the previous template error derives from +error: the binary AND operator is called `bitand` in rinja + --> :1:6 + " b }}" --> tests/ui/iso646.rs:4:25 | 4 | #[template(ext = "txt", source = "{{ a & b }}")] | ^^^^^^ -error: the previous template error derives from +error: the filter operator `|` must not be preceded by any whitespace characters + the binary OR operator is called `bitor` in rinja + --> :1:4 + " | b }}" --> tests/ui/iso646.rs:18:25 | 18 | #[template(ext = "txt", source = "{{ a | b }}")] | ^^^^^^ -error: the previous template error derives from +error: the binary XOR operator is called `xor` in rinja + --> :1:6 + " b }}" --> 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 d08a6d53e..a69aea1e1 100644 --- a/testing/tests/ui/json-too-many-args.stderr +++ b/testing/tests/ui/json-too-many-args.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: unexpected argument(s) in `json` filter + --> OneTwoThree.txt:1:3 + "1|json(2, 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 0e0a2259c..a53e0e273 100644 --- a/testing/tests/ui/let_destructuring_has_rest.stderr +++ b/testing/tests/ui/let_destructuring_has_rest.stderr @@ -1,28 +1,41 @@ -error: the previous template error derives from +error: unexpected `,` character after `..` + note that in a named struct, `..` must come last to ignore other members + --> :2:20 + ", } = x -%}hello {{ a }}{%- endif -%}\n" --> tests/ui/let_destructuring_has_rest.rs:9:12 | 9 | #[template(source = " | ^^^^^^ -error: the previous template error derives from +error: expected `,` for more members, or `}` as terminator + --> :2:17 + ".. } = x -%}hello {{ a }}{%- endif -%}\n" --> tests/ui/let_destructuring_has_rest.rs:17:12 | 17 | #[template(source = " | ^^^^^^ -error: the previous template error derives from +error: expected member, or `}` as terminator + --> :2:18 + "1 } = x -%}hello {{ a }}{%- endif -%}\n" --> tests/ui/let_destructuring_has_rest.rs:25:12 | 25 | #[template(source = " | ^^^^^^ -error: the previous template error derives from +error: unexpected `,` character after `..` + note that in a named struct, `..` must come last to ignore other members + --> :2:20 + ", b } = x -%}hello {{ a }}{%- endif -%}\n" --> tests/ui/let_destructuring_has_rest.rs:33:12 | 33 | #[template(source = " | ^^^^^^ -error: the previous template error derives from +error: unexpected `,` character after `..` + note that in a named struct, `..` must come last to ignore other members + --> :2:17 + ", b } = x -%}hello {{ a }}{%- endif -%}\n" --> 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 99b7f6907..fd7ab00cf 100644 --- a/testing/tests/ui/lit_on_assignment_lhs.stderr +++ b/testing/tests/ui/lit_on_assignment_lhs.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: literals are not allowed on the left-hand side of an assignment + --> MyTemplate.txt:1:2 + "let 7=x%}" --> tests/ui/lit_on_assignment_lhs.rs:5:5 | 5 | source = "{%let 7=x%}", diff --git a/testing/tests/ui/loop_cycle_empty.stderr b/testing/tests/ui/loop_cycle_empty.stderr index a82dc9b77..eda9a050a 100644 --- a/testing/tests/ui/loop_cycle_empty.stderr +++ b/testing/tests/ui/loop_cycle_empty.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: loop.cycle(…) cannot use an empty array + --> ForCycleEmpty.txt:1:35 + "[]) }}{{ v }},{% endfor %}" --> tests/ui/loop_cycle_empty.rs:5:5 | 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 140497afb..9be0c6ba5 100644 --- a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr +++ b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: loop.cycle(…) cannot use an empty array + --> ForCycle.txt:1:28 + ".cycle(\"r\", \"g\", \"b\") }}{{ v }},{% endfor %}" --> tests/ui/loop_cycle_wrong_argument_count.rs:5:5 | 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 e6834ae2c..5ac86a467 100644 --- a/testing/tests/ui/macro-super.stderr +++ b/testing/tests/ui/macro-super.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: 'super' is not a valid name for a macro + --> :1:2 + "- macro super() -%}{%- endmacro -%}" --> 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 c73ade0a3..6b2a93752 100644 --- a/testing/tests/ui/macro.stderr +++ b/testing/tests/ui/macro.stderr @@ -1,16 +1,22 @@ -error: the previous template error derives from +error: macro "thrice" expected 1 argument, found 2 + --> InvalidNumberOfArgs.html:5:2 + "- call thrice(2, 3) -%}" --> tests/ui/macro.rs:4:12 | 4 | #[template(source = "{%- macro thrice(param) -%} | ^^^^^^ -error: the previous template error derives from +error: macro "thrice" expected 2 arguments, found 0 + --> InvalidNumberOfArgs2.html:5:2 + "- call thrice() -%}" --> tests/ui/macro.rs:12:12 | 12 | #[template(source = "{%- macro thrice(param, param2) -%} | ^^^^^^ -error: the previous template error derives from +error: macro "thrice" expected 0 arguments, found 2 + --> InvalidNumberOfArgs3.html:4:2 + "- call thrice(1, 2) -%}" --> 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 33ceae6b4..e132c6696 100644 --- a/testing/tests/ui/macro_named_argument.stderr +++ b/testing/tests/ui/macro_named_argument.stderr @@ -1,28 +1,38 @@ -error: the previous template error derives from +error: no argument named `param3` in macro "thrice" + --> InvalidNamedArg.html:5:2 + "- call thrice(param1=2, param3=3) -%}" --> tests/ui/macro_named_argument.rs:4:12 | 4 | #[template(source = "{%- macro thrice(param1, param2) -%} | ^^^^^^ -error: the previous template error derives from +error: named argument `param1` was passed more than once + --> :5:15 + "(param1=2, param1=3) -%}" --> tests/ui/macro_named_argument.rs:12:12 | 12 | #[template(source = "{%- macro thrice(param1, param2) -%} | ^^^^^^ -error: the previous template error derives from +error: failed to parse template source + --> :5:29 + "| filter(param1=12) -%}" --> tests/ui/macro_named_argument.rs:21:12 | 21 | #[template(source = "{%- macro thrice(param1, param2) -%} | ^^^^^^ -error: the previous template error derives from +error: named arguments must always be passed last + --> :4:15 + "(param1=2, 3) -%}" --> tests/ui/macro_named_argument.rs:30:12 | 30 | #[template(source = "{%- macro thrice(param1, param2) -%} | ^^^^^^ -error: the previous template error derives from +error: cannot have unnamed argument (`param2`) after named argument in macro "thrice" + --> InvalidNamedArg5.html:4:2 + "- call thrice(3, param1=2) -%}" --> 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 596c7e277..9f5bdae7d 100644 --- a/testing/tests/ui/match_with_extra.stderr +++ b/testing/tests/ui/match_with_extra.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: failed to parse template source + --> :3:4 + "// Help, I forgot how to write comments!\n {%- when true %}\n good\n {%- when _ -%}\n bad\n{%- endmatch -%}" --> tests/ui/match_with_extra.rs:6:5 | 6 | source = r#" diff --git a/testing/tests/ui/multiple_extends.stderr b/testing/tests/ui/multiple_extends.stderr index 2d0a44a0d..241279505 100644 --- a/testing/tests/ui/multiple_extends.stderr +++ b/testing/tests/ui/multiple_extends.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: multiple extend blocks found + --> MyTemplate4.txt:3:2 + " extends \"foo.html\" %}\n" --> 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 d3b21d9b0..156ef683a 100644 --- a/testing/tests/ui/name_mismatch_endblock.stderr +++ b/testing/tests/ui/name_mismatch_endblock.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: expected name `foo` in `endblock` tag, found `not_foo` + --> :1:27 + "not_foo %}" --> 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 b38f88a46..bf160c305 100644 --- a/testing/tests/ui/name_mismatch_endmacro.stderr +++ b/testing/tests/ui/name_mismatch_endmacro.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: expected name `foo` in `endmacro` tag, found `not_foo` + --> :1:41 + "not_foo %}" --> 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.stderr b/testing/tests/ui/no-such-escaper.stderr index 7691305ea..42f5db27f 100644 --- a/testing/tests/ui/no-such-escaper.stderr +++ b/testing/tests/ui/no-such-escaper.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: invalid escaper 'latex' for `escape` filter. The available extensions are: "", "htm", "html", "j2", "jinja", "jinja2", "md", "none", "svg", "txt", "xml", "yml" + --> LocalEscaper.html:1:38 + "text|escape(\"latex\")}}`." --> tests/ui/no-such-escaper.rs:6:5 | 6 | source = r#"In LaTeX you write `{{text}}` like `{{text|escape("latex")}}`."#, diff --git a/testing/tests/ui/num-suffix.stderr b/testing/tests/ui/num-suffix.stderr index 281be1aa1..c4a0726f9 100644 --- a/testing/tests/ui/num-suffix.stderr +++ b/testing/tests/ui/num-suffix.stderr @@ -1,16 +1,22 @@ -error: the previous template error derives from +error: unknown integer suffix `x` + --> :1:3 + "0x0x }}" --> tests/ui/num-suffix.rs:7:5 | 7 | source = "{{ 0x0x }}", | ^^^^^^ -error: the previous template error derives from +error: unknown float suffix `f127` + --> :1:3 + "0.0_f127 }}" --> tests/ui/num-suffix.rs:14:5 | 14 | source = "{{ 0.0_f127 }}", | ^^^^^^ -error: the previous template error derives from +error: unknown number suffix `u321` + --> :1:3 + "654u321 }}" --> tests/ui/num-suffix.rs:21:5 | 21 | source = "{{ 654u321 }}", diff --git a/testing/tests/ui/ref_deref.stderr b/testing/tests/ui/ref_deref.stderr index 1a25f6fb4..347f3c6ef 100644 --- a/testing/tests/ui/ref_deref.stderr +++ b/testing/tests/ui/ref_deref.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: failed to parse template source + --> :1:7 + "*x = 2 %}" --> 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 83de4c923..6fb8f7504 100644 --- a/testing/tests/ui/space-pipe.stderr +++ b/testing/tests/ui/space-pipe.stderr @@ -1,10 +1,16 @@ -error: the previous template error derives from +error: the filter operator `|` must not be preceded by any whitespace characters + the binary OR operator is called `bitor` in rinja + --> :1:3 + " |lower}}" --> tests/ui/space-pipe.rs:10:25 | 10 | #[template(ext = "txt", source = "{{a |lower}}")] | ^^^^^^ -error: the previous template error derives from +error: the filter operator `|` must not be preceded by any whitespace characters + the binary OR operator is called `bitor` in rinja + --> :1:3 + " | lower}}" --> tests/ui/space-pipe.rs:22:25 | 22 | #[template(ext = "txt", source = "{{a | lower}}")] diff --git a/testing/tests/ui/transclude-missing.stderr b/testing/tests/ui/transclude-missing.stderr index 5a0e1e36e..3d4e110ab 100644 --- a/testing/tests/ui/transclude-missing.stderr +++ b/testing/tests/ui/transclude-missing.stderr @@ -1,10 +1,14 @@ -error: the previous template error derives from +error: template "transclude-missing.html" not found in directories ["$WORKSPACE/target/tests/trybuild/rinja_testing/templates"] + --> testing/templates/transclude-there.html:1:2 + " include \"transclude-missing.html\" %}" --> tests/ui/transclude-missing.rs:4:12 | 4 | #[template(path = "transclude-there.html")] | ^^^^ -error: the previous template error derives from +error: template "transclude-missing.html" not found in directories ["$WORKSPACE/target/tests/trybuild/rinja_testing/templates"] + --> testing/templates/transclude-there.html:1:2 + " include \"transclude-missing.html\" %}" --> 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 3bdc833e4..0bb2e3745 100644 --- a/testing/tests/ui/typo_in_keyword.stderr +++ b/testing/tests/ui/typo_in_keyword.stderr @@ -1,4 +1,6 @@ -error: the previous template error derives from +error: failed to parse template source + --> :1:26 + "endfo%}\n1234567890123456789012345678901234567890" --> tests/ui/typo_in_keyword.rs:5:5 | 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 4cc716da9..cf5b19eb9 100644 --- a/testing/tests/ui/unclosed-nodes.stderr +++ b/testing/tests/ui/unclosed-nodes.stderr @@ -1,70 +1,94 @@ -error: the previous template error derives from +error: unclosed expression, missing "}}" + --> :1:0 + "{{ expr" --> tests/ui/unclosed-nodes.rs:4:12 | 4 | #[template(source = "{{ expr", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed expression, missing "}}" + --> :1:0 + "{{ expr " --> tests/ui/unclosed-nodes.rs:8:12 | 8 | #[template(source = "{{ expr ", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed expression, missing "}}" + --> :1:0 + "{{ expr -" --> tests/ui/unclosed-nodes.rs:12:12 | 12 | #[template(source = "{{ expr -", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: failed to parse template source + --> :1:9 + "}" --> tests/ui/unclosed-nodes.rs:16:12 | 16 | #[template(source = "{{ expr -}", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed block, missing "%}" + --> :1:0 + "{% let x" --> tests/ui/unclosed-nodes.rs:20:12 | 20 | #[template(source = "{% let x", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed block, missing "%}" + --> :1:0 + "{% let x " --> tests/ui/unclosed-nodes.rs:24:12 | 24 | #[template(source = "{% let x ", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed block, missing "%}" + --> :1:0 + "{% let x -" --> tests/ui/unclosed-nodes.rs:28:12 | 28 | #[template(source = "{% let x -", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: failed to parse template source + --> :1:10 + "%" --> tests/ui/unclosed-nodes.rs:32:12 | 32 | #[template(source = "{% let x -%", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed comment, missing "#}" + --> :1:2 + " comment" --> tests/ui/unclosed-nodes.rs:36:12 | 36 | #[template(source = "{# comment", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed comment, missing "#}" + --> :1:2 + " comment " --> tests/ui/unclosed-nodes.rs:40:12 | 40 | #[template(source = "{# comment ", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed comment, missing "#}" + --> :1:2 + " comment -" --> tests/ui/unclosed-nodes.rs:44:12 | 44 | #[template(source = "{# comment -", ext = "txt")] | ^^^^^^ -error: the previous template error derives from +error: unclosed comment, missing "#}" + --> :1:2 + " comment -#" --> tests/ui/unclosed-nodes.rs:48:12 | 48 | #[template(source = "{# comment -#", ext = "txt")] From 5e98580ae3ff720cfdfe855e775ffe57460caea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Tue, 30 Jul 2024 12:52:48 +0200 Subject: [PATCH 7/7] derive: highlight value, not key --- rinja_derive/src/input.rs | 8 +-- testing/tests/ui/as-primitive-type.stderr | 24 ++++----- testing/tests/ui/block_in_filter_block.stderr | 15 ++++-- .../tests/ui/blocks_below_top_level.stderr | 34 ++++++++---- testing/tests/ui/break_outside_of_loop.stderr | 4 +- testing/tests/ui/broken-config.stderr | 16 +++--- testing/tests/ui/char_literal.stderr | 32 +++++------ testing/tests/ui/cycle.stderr | 4 +- testing/tests/ui/cycle2.stderr | 4 +- testing/tests/ui/error_file_path.stderr | 12 ++--- testing/tests/ui/excessive_nesting.stderr | 15 ++++-- testing/tests/ui/extends.stderr | 8 +-- testing/tests/ui/filter-recursion.stderr | 4 +- testing/tests/ui/filter_block_ws.stderr | 10 ++-- testing/tests/ui/include-a-folder.stderr | 4 +- testing/tests/ui/incorrect_path.stderr | 4 +- testing/tests/ui/is_defined.stderr | 24 ++++----- testing/tests/ui/iso646.stderr | 12 ++--- testing/tests/ui/json-too-many-args.stderr | 4 +- .../ui/let_destructuring_has_rest.stderr | 47 ++++++++++------ testing/tests/ui/lit_on_assignment_lhs.stderr | 4 +- testing/tests/ui/loop_cycle_empty.stderr | 4 +- .../ui/loop_cycle_wrong_argument_count.stderr | 4 +- testing/tests/ui/macro-super.stderr | 4 +- testing/tests/ui/macro.stderr | 32 +++++++---- testing/tests/ui/macro_named_argument.stderr | 53 +++++++++++++------ testing/tests/ui/match_with_extra.stderr | 15 ++++-- testing/tests/ui/multiple_extends.stderr | 10 ++-- .../tests/ui/name_mismatch_endblock.stderr | 4 +- .../tests/ui/name_mismatch_endmacro.stderr | 4 +- testing/tests/ui/no-such-escaper.stderr | 12 ++--- testing/tests/ui/num-suffix.stderr | 12 ++--- testing/tests/ui/ref_deref.stderr | 4 +- testing/tests/ui/space-pipe.stderr | 8 +-- testing/tests/ui/transclude-missing.stderr | 8 +-- testing/tests/ui/typo_in_keyword.stderr | 4 +- testing/tests/ui/unclosed-nodes.stderr | 48 ++++++++--------- 37 files changed, 306 insertions(+), 209 deletions(-) diff --git a/rinja_derive/src/input.rs b/rinja_derive/src/input.rs index 046ea83c7..ea21215ef 100644 --- a/rinja_derive/src/input.rs +++ b/rinja_derive/src/input.rs @@ -366,7 +366,7 @@ impl TemplateArgs { if ident == "path" { source_or_path(ident, value, &mut args.source, Source::Path)?; - args.ext_span = Some(ident.span()); + args.ext_span = Some(value.span()); } else if ident == "source" { source_or_path(ident, value, &mut args.source, |s| Source::Source(s.into()))?; } else if ident == "block" { @@ -395,12 +395,12 @@ 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()); + args.ext_span = Some(value.span()); } else if ident == "syntax" { set_template_str_attr(ident, value, &mut args.syntax)?; } else if ident == "config" { set_template_str_attr(ident, value, &mut args.config)?; - args.config_span = Some(ident.span()) + args.config_span = Some(value.span()) } else if ident == "whitespace" { set_template_str_attr(ident, value, &mut args.whitespace)?; } else { @@ -439,7 +439,7 @@ fn source_or_path( Some(name.span()), )) } else if let syn::Lit::Str(s) = &value.lit { - *dest = Some((ctor(s.value()), Some(name.span()))); + *dest = Some((ctor(s.value()), Some(value.span()))); Ok(()) } else { Err(CompileError::no_file_info( diff --git a/testing/tests/ui/as-primitive-type.stderr b/testing/tests/ui/as-primitive-type.stderr index 0d715e109..86dba2305 100644 --- a/testing/tests/ui/as-primitive-type.stderr +++ b/testing/tests/ui/as-primitive-type.stderr @@ -1,47 +1,47 @@ error: `as` operator expects the name of a primitive type on its right-hand side --> :1:8 "as 4567 }}" - --> tests/ui/as-primitive-type.rs:4:12 + --> tests/ui/as-primitive-type.rs:4:21 | 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:8 "as ? }}" - --> tests/ui/as-primitive-type.rs:8:12 + --> tests/ui/as-primitive-type.rs:8:21 | 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:8 "as u1234 }}" - --> tests/ui/as-primitive-type.rs:12:12 + --> tests/ui/as-primitive-type.rs:12:21 | 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:8 "as core::primitive::u32 }}" - --> tests/ui/as-primitive-type.rs:16:12 + --> tests/ui/as-primitive-type.rs:16:21 | 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:8 "as int32_t }}" - --> tests/ui/as-primitive-type.rs:20:12 + --> tests/ui/as-primitive-type.rs:20:21 | 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:35 "as int32_t }}" - --> tests/ui/as-primitive-type.rs:24:12 + --> tests/ui/as-primitive-type.rs:24:21 | 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 ccd9fda71..89974337a 100644 --- a/testing/tests/ui/block_in_filter_block.stderr +++ b/testing/tests/ui/block_in_filter_block.stderr @@ -1,7 +1,14 @@ error: cannot have a block inside a filter block --> BlockInFilter.html:7:10 " block title %}New title{% endblock %}\n a b\n {% endfilter %}\n{%- endblock body %}\n" - --> tests/ui/block_in_filter_block.rs:5:5 - | -5 | source = r#"{% extends "html-base.html" %} - | ^^^^^^ + --> tests/ui/block_in_filter_block.rs:5:14 + | +5 | source = r#"{% extends "html-base.html" %} + | ______________^ +6 | | +7 | | {%- block body -%} +8 | |

Metadata

+... | +14 | | {%- endblock body %} +15 | | "#, + | |__^ diff --git a/testing/tests/ui/blocks_below_top_level.stderr b/testing/tests/ui/blocks_below_top_level.stderr index cab6e8a2b..653998a08 100644 --- a/testing/tests/ui/blocks_below_top_level.stderr +++ b/testing/tests/ui/blocks_below_top_level.stderr @@ -1,23 +1,39 @@ error: `extends` blocks are not allowed below top level --> MyTemplate1.txt:3:2 " extends \"bla.txt\" %}\n{% endblock %}\n" - --> tests/ui/blocks_below_top_level.rs:4:12 + --> tests/ui/blocks_below_top_level.rs:4:21 | -4 | #[template(source = r#" - | ^^^^^^ +4 | #[template(source = r#" + | _____________________^ +5 | | {% block bla %} +6 | | {% extends "bla.txt" %} +7 | | {% endblock %} +8 | | "#, ext = "txt")] + | |__^ error: `macro` blocks are not allowed below top level --> MyTemplate2.txt:3:2 " macro bla() %}\n{% endmacro %}\n{% endblock %}\n" - --> tests/ui/blocks_below_top_level.rs:12:12 + --> tests/ui/blocks_below_top_level.rs:12:21 | -12 | #[template(source = r#" - | ^^^^^^ +12 | #[template(source = r#" + | _____________________^ +13 | | {% block bla %} +14 | | {% macro bla() %} +15 | | {% endmacro %} +16 | | {% endblock %} +17 | | "#, ext = "txt")] + | |__^ error: `import` blocks are not allowed below top level --> MyTemplate3.txt:3:2 " import \"bla.txt\" as blue %}\n{% endblock %}\n" - --> tests/ui/blocks_below_top_level.rs:21:12 + --> tests/ui/blocks_below_top_level.rs:21:21 | -21 | #[template(source = r#" - | ^^^^^^ +21 | #[template(source = r#" + | _____________________^ +22 | | {% block bla %} +23 | | {% import "bla.txt" as blue %} +24 | | {% endblock %} +25 | | "#, ext = "txt")] + | |__^ diff --git a/testing/tests/ui/break_outside_of_loop.stderr b/testing/tests/ui/break_outside_of_loop.stderr index 1bffa3cbe..ba23ec45f 100644 --- a/testing/tests/ui/break_outside_of_loop.stderr +++ b/testing/tests/ui/break_outside_of_loop.stderr @@ -1,7 +1,7 @@ error: you can only `break` inside a `for` loop --> :1:9 "break%}, have a parsing error!" - --> tests/ui/break_outside_of_loop.rs:5:5 + --> tests/ui/break_outside_of_loop.rs:5:14 | 5 | source = "Have a {%break%}, have a parsing error!", - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/broken-config.stderr b/testing/tests/ui/broken-config.stderr index 8765b02b7..e6812a9c9 100644 --- a/testing/tests/ui/broken-config.stderr +++ b/testing/tests/ui/broken-config.stderr @@ -1,25 +1,25 @@ error: `$WORKSPACE/target/tests/trybuild/rinja_testing/no-such-config.toml` does not exist - --> tests/ui/broken-config.rs:4:38 + --> tests/ui/broken-config.rs:4:47 | 4 | #[template(source = "", ext = "txt", config = "no-such-config.toml")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ error: unable to read $WORKSPACE/target/tests/trybuild/rinja_testing/folder-config.toml: Is a directory (os error 21) - --> tests/ui/broken-config.rs:8:38 + --> tests/ui/broken-config.rs:8:47 | 8 | #[template(source = "", ext = "txt", config = "folder-config.toml")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ error: a delimiter may not be the prefix of another delimiter: "<<<" vs "<<<<" --> testing/delim-clash.toml - --> tests/ui/broken-config.rs:12:38 + --> tests/ui/broken-config.rs:12:47 | 12 | #[template(source = "", ext = "txt", config = "delim-clash.toml")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^ error: delimiters must be at least two characters long: "<" --> testing/delim-too-short.toml - --> tests/ui/broken-config.rs:16:38 + --> tests/ui/broken-config.rs:16:47 | 16 | #[template(source = "", ext = "txt", config = "delim-too-short.toml")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/char_literal.stderr b/testing/tests/ui/char_literal.stderr index 058a74497..5a116fc2d 100644 --- a/testing/tests/ui/char_literal.stderr +++ b/testing/tests/ui/char_literal.stderr @@ -1,63 +1,63 @@ error: invalid character --> testing/templates/char-literals/char-literal-1.txt:1:11 "'\\a' %}" - --> tests/ui/char_literal.rs:4:12 + --> tests/ui/char_literal.rs:4:19 | 4 | #[template(path = "char-literals/char-literal-1.txt")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-2.txt:1:11 "'\\x' %}" - --> tests/ui/char_literal.rs:8:12 + --> tests/ui/char_literal.rs:8:19 | 8 | #[template(path = "char-literals/char-literal-2.txt")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-3.txt:1:11 "'\\x1' %}" - --> tests/ui/char_literal.rs:12:12 + --> tests/ui/char_literal.rs:12:19 | 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:11 "'\\x80' %}" - --> tests/ui/char_literal.rs:16:12 + --> tests/ui/char_literal.rs:16:19 | 16 | #[template(path = "char-literals/char-literal-4.txt")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-5.txt:1:11 "'\\u' %}" - --> tests/ui/char_literal.rs:20:12 + --> tests/ui/char_literal.rs:20:19 | 20 | #[template(path = "char-literals/char-literal-5.txt")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid character --> testing/templates/char-literals/char-literal-6.txt:1:11 "'\\u{}' %}" - --> tests/ui/char_literal.rs:24:12 + --> tests/ui/char_literal.rs:24:19 | 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:11 "'\\u{110000}' %}" - --> tests/ui/char_literal.rs:28:12 + --> tests/ui/char_literal.rs:28:19 | 28 | #[template(path = "char-literals/char-literal-7.txt")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: invalid character --> :1:11 "'aaa' %}" - --> tests/ui/char_literal.rs:32:12 + --> tests/ui/char_literal.rs:32:21 | 32 | #[template(source = "{% let s = 'aaa' %}", ext = "html")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/cycle.stderr b/testing/tests/ui/cycle.stderr index ddff9a7dc..90f26b53c 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:12 + --> tests/ui/cycle.rs:4:19 | 4 | #[template(path = "cycle2.html")] - | ^^^^ + | ^^^^^^^^^^^^^ diff --git a/testing/tests/ui/cycle2.stderr b/testing/tests/ui/cycle2.stderr index c5415fbbb..08d135fe8 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:12 + --> tests/ui/cycle2.rs:4:19 | 4 | #[template(path = "cycle1.html")] - | ^^^^ + | ^^^^^^^^^^^^^ diff --git a/testing/tests/ui/error_file_path.stderr b/testing/tests/ui/error_file_path.stderr index 4de70066b..36facafd7 100644 --- a/testing/tests/ui/error_file_path.stderr +++ b/testing/tests/ui/error_file_path.stderr @@ -1,23 +1,23 @@ error: failed to parse template source --> testing/templates/invalid_syntax.html:1:14 "}" - --> tests/ui/error_file_path.rs:4:12 + --> tests/ui/error_file_path.rs:4:19 | 4 | #[template(path = "invalid_syntax.html")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^ error: failed to parse template source --> testing/templates/invalid_syntax.html:1:14 "}" - --> tests/ui/error_file_path.rs:8:12 + --> tests/ui/error_file_path.rs:8:19 | 8 | #[template(path = "include_invalid_syntax.html")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: failed to parse template source --> testing/templates/invalid_syntax.html:1:14 "}" - --> tests/ui/error_file_path.rs:12:12 + --> tests/ui/error_file_path.rs:12:21 | 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 46dd682d1..0fa8ebdef 100644 --- a/testing/tests/ui/excessive_nesting.stderr +++ b/testing/tests/ui/excessive_nesting.stderr @@ -1,7 +1,14 @@ error: your template code is too deeply nested, or last expression is too complex --> :14:42 "%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 200\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 300\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 400\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 500\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 600\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 700\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 800\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 900\n\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}\n {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 1000\n " - --> tests/ui/excessive_nesting.rs:5:5 - | -5 | source = " - | ^^^^^^ + --> tests/ui/excessive_nesting.rs:5:14 + | +5 | source = " + | ______________^ +6 | | {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} +7 | | {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} +8 | | {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} +... | +114 | | {%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%}{%if 1%} 1000 +115 | | ", + | |_____^ diff --git a/testing/tests/ui/extends.stderr b/testing/tests/ui/extends.stderr index 7a86ececf..71274cbbd 100644 --- a/testing/tests/ui/extends.stderr +++ b/testing/tests/ui/extends.stderr @@ -1,15 +1,15 @@ error: whitespace control is not allowed on `extends` --> :1:2 "- extends \"whatever.html\" %}" - --> tests/ui/extends.rs:5:5 + --> tests/ui/extends.rs:5:14 | 5 | source = r#"{%- extends "whatever.html" %}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: whitespace control is not allowed on `extends` --> :1:2 " extends \"whatever.html\" -%}" - --> tests/ui/extends.rs:12:5 + --> tests/ui/extends.rs:12:14 | 12 | source = r#"{% extends "whatever.html" -%}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/filter-recursion.stderr b/testing/tests/ui/filter-recursion.stderr index 6626e6f5f..581b41642 100644 --- a/testing/tests/ui/filter-recursion.stderr +++ b/testing/tests/ui/filter-recursion.stderr @@ -1,7 +1,7 @@ error: your template code is too deeply nested, or last expression is too complex --> testing/templates/filter-recursion.html:1:255 "|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|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A|A|A|A|AA|A" - --> tests/ui/filter-recursion.rs:4:12 + --> tests/ui/filter-recursion.rs:4:19 | 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 7487e98ed..f94c121b2 100644 --- a/testing/tests/ui/filter_block_ws.stderr +++ b/testing/tests/ui/filter_block_ws.stderr @@ -1,7 +1,11 @@ error: failed to parse template source --> :1:27 " %}\nHELLO\n{{v}}\n{%- endfilter %}" - --> tests/ui/filter_block_ws.rs:4:12 + --> tests/ui/filter_block_ws.rs:4:21 | -4 | #[template(source = "{% filter lower|indent(2) - %} - | ^^^^^^ +4 | #[template(source = "{% filter lower|indent(2) - %} + | _____________________^ +5 | | HELLO +6 | | {{v}} +7 | | {%- endfilter %}", ext = "html")] + | |_________________^ diff --git a/testing/tests/ui/include-a-folder.stderr b/testing/tests/ui/include-a-folder.stderr index d90135401..08a1cef84 100644 --- a/testing/tests/ui/include-a-folder.stderr +++ b/testing/tests/ui/include-a-folder.stderr @@ -1,7 +1,7 @@ error: unable to open template file '$WORKSPACE/target/tests/trybuild/rinja_testing/templates/a_file_that_is_actually_a_folder.html': Is a directory (os error 21) --> YouCannotIncludeFolders.txt:1:2 " include \"a_file_that_is_actually_a_folder.html\" %}" - --> tests/ui/include-a-folder.rs:4:25 + --> tests/ui/include-a-folder.rs:4:34 | 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 c57f49aa3..0519b1131 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:12 + --> tests/ui/incorrect_path.rs:4:19 | 4 | #[template(path = "thisdoesnotexist.html")] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/is_defined.stderr b/testing/tests/ui/is_defined.stderr index 9851d0f4c..3849fde89 100644 --- a/testing/tests/ui/is_defined.stderr +++ b/testing/tests/ui/is_defined.stderr @@ -1,47 +1,47 @@ error: `is defined` operator can only be used on variables, not on their fields --> :1:6 "x.y is defined %}{% endif %}" - --> tests/ui/is_defined.rs:6:5 + --> tests/ui/is_defined.rs:6:14 | 6 | source = r#"{% if x.y is defined %}{% endif %}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `is defined` operator can only be used on variables --> :1:6 "true is defined %}{% endif %}" - --> tests/ui/is_defined.rs:13:5 + --> tests/ui/is_defined.rs:13:14 | 13 | source = r#"{% if true is defined %}{% endif %}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:6 "true is %}{% endif %}" - --> tests/ui/is_defined.rs:20:5 + --> tests/ui/is_defined.rs:20:14 | 20 | source = r#"{% if true is %}{% endif %}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:6 "x is %}{% endif %}" - --> tests/ui/is_defined.rs:27:5 + --> tests/ui/is_defined.rs:27:14 | 27 | source = r#"{% if x is %}{% endif %}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:6 "x is blue %}{% endif %}" - --> tests/ui/is_defined.rs:34:5 + --> tests/ui/is_defined.rs:34:14 | 34 | source = r#"{% if x is blue %}{% endif %}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected `defined` or `not defined` after `is` --> :1:6 "x is blue.red %}{% endif %}" - --> tests/ui/is_defined.rs:41:5 + --> tests/ui/is_defined.rs:41:14 | 41 | source = r#"{% if x is blue.red %}{% endif %}"#, - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/iso646.stderr b/testing/tests/ui/iso646.stderr index f754c8ca0..57fd27970 100644 --- a/testing/tests/ui/iso646.stderr +++ b/testing/tests/ui/iso646.stderr @@ -1,24 +1,24 @@ error: the binary AND operator is called `bitand` in rinja --> :1:6 " b }}" - --> tests/ui/iso646.rs:4:25 + --> tests/ui/iso646.rs:4:34 | 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 --> :1:4 " | b }}" - --> tests/ui/iso646.rs:18:25 + --> tests/ui/iso646.rs:18:34 | 18 | #[template(ext = "txt", source = "{{ a | b }}")] - | ^^^^^^ + | ^^^^^^^^^^^^^ error: the binary XOR operator is called `xor` in rinja --> :1:6 " b }}" - --> tests/ui/iso646.rs:32:25 + --> tests/ui/iso646.rs:32:34 | 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 a69aea1e1..c2e59678c 100644 --- a/testing/tests/ui/json-too-many-args.stderr +++ b/testing/tests/ui/json-too-many-args.stderr @@ -1,7 +1,7 @@ error: unexpected argument(s) in `json` filter --> OneTwoThree.txt:1:3 "1|json(2, 3) }}" - --> tests/ui/json-too-many-args.rs:6:25 + --> tests/ui/json-too-many-args.rs:6:34 | 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 a53e0e273..61eb6efd6 100644 --- a/testing/tests/ui/let_destructuring_has_rest.stderr +++ b/testing/tests/ui/let_destructuring_has_rest.stderr @@ -2,41 +2,56 @@ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members --> :2:20 ", } = x -%}hello {{ a }}{%- endif -%}\n" - --> tests/ui/let_destructuring_has_rest.rs:9:12 - | -9 | #[template(source = " - | ^^^^^^ + --> tests/ui/let_destructuring_has_rest.rs:9:21 + | +9 | #[template(source = " + | _____________________^ +10 | | {%- if let X { a, .., } = x -%}hello {{ a }}{%- endif -%} +11 | | ", ext = "html")] + | |_^ error: expected `,` for more members, or `}` as terminator --> :2:17 ".. } = x -%}hello {{ a }}{%- endif -%}\n" - --> tests/ui/let_destructuring_has_rest.rs:17:12 + --> tests/ui/let_destructuring_has_rest.rs:17:21 | -17 | #[template(source = " - | ^^^^^^ +17 | #[template(source = " + | _____________________^ +18 | | {%- if let X { a .. } = x -%}hello {{ a }}{%- endif -%} +19 | | ", ext = "html")] + | |_^ error: expected member, or `}` as terminator --> :2:18 "1 } = x -%}hello {{ a }}{%- endif -%}\n" - --> tests/ui/let_destructuring_has_rest.rs:25:12 + --> tests/ui/let_destructuring_has_rest.rs:25:21 | -25 | #[template(source = " - | ^^^^^^ +25 | #[template(source = " + | _____________________^ +26 | | {%- if let X { a, 1 } = x -%}hello {{ a }}{%- endif -%} +27 | | ", ext = "html")] + | |_^ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members --> :2:20 ", b } = x -%}hello {{ a }}{%- endif -%}\n" - --> tests/ui/let_destructuring_has_rest.rs:33:12 + --> tests/ui/let_destructuring_has_rest.rs:33:21 | -33 | #[template(source = " - | ^^^^^^ +33 | #[template(source = " + | _____________________^ +34 | | {%- if let X { a, .., b } = x -%}hello {{ a }}{%- endif -%} +35 | | ", ext = "html")] + | |_^ error: unexpected `,` character after `..` note that in a named struct, `..` must come last to ignore other members --> :2:17 ", b } = x -%}hello {{ a }}{%- endif -%}\n" - --> tests/ui/let_destructuring_has_rest.rs:41:12 + --> tests/ui/let_destructuring_has_rest.rs:41:21 | -41 | #[template(source = " - | ^^^^^^ +41 | #[template(source = " + | _____________________^ +42 | | {%- if let X { .., b } = x -%}hello {{ a }}{%- endif -%} +43 | | ", ext = "html")] + | |_^ diff --git a/testing/tests/ui/lit_on_assignment_lhs.stderr b/testing/tests/ui/lit_on_assignment_lhs.stderr index fd7ab00cf..b49b22265 100644 --- a/testing/tests/ui/lit_on_assignment_lhs.stderr +++ b/testing/tests/ui/lit_on_assignment_lhs.stderr @@ -1,7 +1,7 @@ error: literals are not allowed on the left-hand side of an assignment --> MyTemplate.txt:1:2 "let 7=x%}" - --> tests/ui/lit_on_assignment_lhs.rs:5:5 + --> tests/ui/lit_on_assignment_lhs.rs:5:14 | 5 | source = "{%let 7=x%}", - | ^^^^^^ + | ^^^^^^^^^^^^^ diff --git a/testing/tests/ui/loop_cycle_empty.stderr b/testing/tests/ui/loop_cycle_empty.stderr index eda9a050a..fd5335216 100644 --- a/testing/tests/ui/loop_cycle_empty.stderr +++ b/testing/tests/ui/loop_cycle_empty.stderr @@ -1,7 +1,7 @@ error: loop.cycle(…) cannot use an empty array --> ForCycleEmpty.txt:1:35 "[]) }}{{ v }},{% endfor %}" - --> tests/ui/loop_cycle_empty.rs:5:5 + --> tests/ui/loop_cycle_empty.rs:5:14 | 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 9be0c6ba5..27b489cfc 100644 --- a/testing/tests/ui/loop_cycle_wrong_argument_count.stderr +++ b/testing/tests/ui/loop_cycle_wrong_argument_count.stderr @@ -1,7 +1,7 @@ error: loop.cycle(…) cannot use an empty array --> ForCycle.txt:1:28 ".cycle(\"r\", \"g\", \"b\") }}{{ v }},{% endfor %}" - --> tests/ui/loop_cycle_wrong_argument_count.rs:5:5 + --> tests/ui/loop_cycle_wrong_argument_count.rs:5:14 | 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 5ac86a467..c03acad59 100644 --- a/testing/tests/ui/macro-super.stderr +++ b/testing/tests/ui/macro-super.stderr @@ -1,7 +1,7 @@ error: 'super' is not a valid name for a macro --> :1:2 "- macro super() -%}{%- endmacro -%}" - --> tests/ui/macro-super.rs:4:12 + --> tests/ui/macro-super.rs:4:21 | 4 | #[template(source = "{%- macro super() -%}{%- endmacro -%}", ext = "html")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/macro.stderr b/testing/tests/ui/macro.stderr index 6b2a93752..3539e4325 100644 --- a/testing/tests/ui/macro.stderr +++ b/testing/tests/ui/macro.stderr @@ -1,23 +1,37 @@ error: macro "thrice" expected 1 argument, found 2 --> InvalidNumberOfArgs.html:5:2 "- call thrice(2, 3) -%}" - --> tests/ui/macro.rs:4:12 + --> tests/ui/macro.rs:4:21 | -4 | #[template(source = "{%- macro thrice(param) -%} - | ^^^^^^ +4 | #[template(source = "{%- macro thrice(param) -%} + | _____________________^ +5 | | {{ param }} +6 | | {%- endmacro -%} +7 | | +8 | | {%- call thrice(2, 3) -%}", ext = "html")] + | |__________________________^ error: macro "thrice" expected 2 arguments, found 0 --> InvalidNumberOfArgs2.html:5:2 "- call thrice() -%}" - --> tests/ui/macro.rs:12:12 + --> tests/ui/macro.rs:12:21 | -12 | #[template(source = "{%- macro thrice(param, param2) -%} - | ^^^^^^ +12 | #[template(source = "{%- macro thrice(param, param2) -%} + | _____________________^ +13 | | {{ param }} {{ param2 }} +14 | | {%- endmacro -%} +15 | | +16 | | {%- call thrice() -%}", ext = "html")] + | |______________________^ error: macro "thrice" expected 0 arguments, found 2 --> InvalidNumberOfArgs3.html:4:2 "- call thrice(1, 2) -%}" - --> tests/ui/macro.rs:20:12 + --> tests/ui/macro.rs:20:21 | -20 | #[template(source = "{%- macro thrice() -%} - | ^^^^^^ +20 | #[template(source = "{%- macro thrice() -%} + | _____________________^ +21 | | {%- endmacro -%} +22 | | +23 | | {%- call thrice(1, 2) -%}", ext = "html")] + | |__________________________^ diff --git a/testing/tests/ui/macro_named_argument.stderr b/testing/tests/ui/macro_named_argument.stderr index e132c6696..8a5e4d7fc 100644 --- a/testing/tests/ui/macro_named_argument.stderr +++ b/testing/tests/ui/macro_named_argument.stderr @@ -1,39 +1,62 @@ error: no argument named `param3` in macro "thrice" --> InvalidNamedArg.html:5:2 "- call thrice(param1=2, param3=3) -%}" - --> tests/ui/macro_named_argument.rs:4:12 + --> tests/ui/macro_named_argument.rs:4:21 | -4 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^ +4 | #[template(source = "{%- macro thrice(param1, param2) -%} + | _____________________^ +5 | | {{ param1 }} {{ param2 }} +6 | | {%- endmacro -%} +7 | | +8 | | {%- call thrice(param1=2, param3=3) -%}", ext = "html")] + | |________________________________________^ error: named argument `param1` was passed more than once --> :5:15 "(param1=2, param1=3) -%}" - --> tests/ui/macro_named_argument.rs:12:12 + --> tests/ui/macro_named_argument.rs:12:21 | -12 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^ +12 | #[template(source = "{%- macro thrice(param1, param2) -%} + | _____________________^ +13 | | {{ param1 }} {{ param2 }} +14 | | {%- endmacro -%} +15 | | +16 | | {%- call thrice(param1=2, param1=3) -%}", ext = "html")] + | |________________________________________^ error: failed to parse template source --> :5:29 "| filter(param1=12) -%}" - --> tests/ui/macro_named_argument.rs:21:12 + --> tests/ui/macro_named_argument.rs:21:21 | -21 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^ +21 | #[template(source = "{%- macro thrice(param1, param2) -%} + | _____________________^ +22 | | {{ param1 }} {{ param2 }} +23 | | {%- endmacro -%} +24 | | +25 | | {%- call thrice(3, param1=2) | filter(param1=12) -%}", ext = "html")] + | |_____________________________________________________^ error: named arguments must always be passed last --> :4:15 "(param1=2, 3) -%}" - --> tests/ui/macro_named_argument.rs:30:12 + --> tests/ui/macro_named_argument.rs:30:21 | -30 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^ +30 | #[template(source = "{%- macro thrice(param1, param2) -%} + | _____________________^ +31 | | {{ param1 }} {{ param2 }} +32 | | {%- endmacro -%} +33 | | {%- call thrice(param1=2, 3) -%}", ext = "html")] + | |_________________________________^ error: cannot have unnamed argument (`param2`) after named argument in macro "thrice" --> InvalidNamedArg5.html:4:2 "- call thrice(3, param1=2) -%}" - --> tests/ui/macro_named_argument.rs:38:12 + --> tests/ui/macro_named_argument.rs:38:21 | -38 | #[template(source = "{%- macro thrice(param1, param2) -%} - | ^^^^^^ +38 | #[template(source = "{%- macro thrice(param1, param2) -%} + | _____________________^ +39 | | {{ param1 }} {{ param2 }} +40 | | {%- endmacro -%} +41 | | {%- call thrice(3, param1=2) -%}", ext = "html")] + | |_________________________________^ diff --git a/testing/tests/ui/match_with_extra.stderr b/testing/tests/ui/match_with_extra.stderr index 9f5bdae7d..16c80b56d 100644 --- a/testing/tests/ui/match_with_extra.stderr +++ b/testing/tests/ui/match_with_extra.stderr @@ -1,7 +1,14 @@ error: failed to parse template source --> :3:4 "// Help, I forgot how to write comments!\n {%- when true %}\n good\n {%- when _ -%}\n bad\n{%- endmatch -%}" - --> tests/ui/match_with_extra.rs:6:5 - | -6 | source = r#" - | ^^^^^^ + --> tests/ui/match_with_extra.rs:6:14 + | +6 | source = r#" + | ______________^ +7 | | {%- match good -%} +8 | | // Help, I forgot how to write comments! +9 | | {%- when true %} +... | +12 | | bad +13 | | {%- endmatch -%}"# + | |__________________^ diff --git a/testing/tests/ui/multiple_extends.stderr b/testing/tests/ui/multiple_extends.stderr index 241279505..8b1960295 100644 --- a/testing/tests/ui/multiple_extends.stderr +++ b/testing/tests/ui/multiple_extends.stderr @@ -1,7 +1,11 @@ error: multiple extend blocks found --> MyTemplate4.txt:3:2 " extends \"foo.html\" %}\n" - --> tests/ui/multiple_extends.rs:4:12 + --> tests/ui/multiple_extends.rs:4:21 | -4 | #[template(source = r#" - | ^^^^^^ +4 | #[template(source = r#" + | _____________________^ +5 | | {% extends "let.html" %} +6 | | {% extends "foo.html" %} +7 | | "#, ext = "txt")] + | |__^ diff --git a/testing/tests/ui/name_mismatch_endblock.stderr b/testing/tests/ui/name_mismatch_endblock.stderr index 156ef683a..3ae992aee 100644 --- a/testing/tests/ui/name_mismatch_endblock.stderr +++ b/testing/tests/ui/name_mismatch_endblock.stderr @@ -1,7 +1,7 @@ error: expected name `foo` in `endblock` tag, found `not_foo` --> :1:27 "not_foo %}" - --> tests/ui/name_mismatch_endblock.rs:4:12 + --> tests/ui/name_mismatch_endblock.rs:4:21 | 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 bf160c305..ed0985f10 100644 --- a/testing/tests/ui/name_mismatch_endmacro.stderr +++ b/testing/tests/ui/name_mismatch_endmacro.stderr @@ -1,7 +1,7 @@ error: expected name `foo` in `endmacro` tag, found `not_foo` --> :1:41 "not_foo %}" - --> tests/ui/name_mismatch_endmacro.rs:4:12 + --> tests/ui/name_mismatch_endmacro.rs:4:21 | 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 42f5db27f..7952c0783 100644 --- a/testing/tests/ui/no-such-escaper.stderr +++ b/testing/tests/ui/no-such-escaper.stderr @@ -1,19 +1,19 @@ error: invalid escaper 'latex' for `escape` filter. The available extensions are: "", "htm", "html", "j2", "jinja", "jinja2", "md", "none", "svg", "txt", "xml", "yml" --> LocalEscaper.html:1:38 "text|escape(\"latex\")}}`." - --> tests/ui/no-such-escaper.rs:6:5 + --> tests/ui/no-such-escaper.rs:6:14 | 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:14:5 + --> tests/ui/no-such-escaper.rs:14:11 | 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 + --> tests/ui/no-such-escaper.rs:22:19 | 22 | #[template(path = "latex-file.tex")] - | ^^^^ + | ^^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/num-suffix.stderr b/testing/tests/ui/num-suffix.stderr index c4a0726f9..2e1446288 100644 --- a/testing/tests/ui/num-suffix.stderr +++ b/testing/tests/ui/num-suffix.stderr @@ -1,23 +1,23 @@ error: unknown integer suffix `x` --> :1:3 "0x0x }}" - --> tests/ui/num-suffix.rs:7:5 + --> tests/ui/num-suffix.rs:7:14 | 7 | source = "{{ 0x0x }}", - | ^^^^^^ + | ^^^^^^^^^^^^ error: unknown float suffix `f127` --> :1:3 "0.0_f127 }}" - --> tests/ui/num-suffix.rs:14:5 + --> tests/ui/num-suffix.rs:14:14 | 14 | source = "{{ 0.0_f127 }}", - | ^^^^^^ + | ^^^^^^^^^^^^^^^^ error: unknown number suffix `u321` --> :1:3 "654u321 }}" - --> tests/ui/num-suffix.rs:21:5 + --> tests/ui/num-suffix.rs:21:14 | 21 | source = "{{ 654u321 }}", - | ^^^^^^ + | ^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/ref_deref.stderr b/testing/tests/ui/ref_deref.stderr index 347f3c6ef..eb93a2121 100644 --- a/testing/tests/ui/ref_deref.stderr +++ b/testing/tests/ui/ref_deref.stderr @@ -1,7 +1,7 @@ error: failed to parse template source --> :1:7 "*x = 2 %}" - --> tests/ui/ref_deref.rs:4:12 + --> tests/ui/ref_deref.rs:4:21 | 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 6fb8f7504..ca16646ad 100644 --- a/testing/tests/ui/space-pipe.stderr +++ b/testing/tests/ui/space-pipe.stderr @@ -2,16 +2,16 @@ error: the filter operator `|` must not be preceded by any whitespace characters the binary OR operator is called `bitor` in rinja --> :1:3 " |lower}}" - --> tests/ui/space-pipe.rs:10:25 + --> tests/ui/space-pipe.rs:10:34 | 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 --> :1:3 " | lower}}" - --> tests/ui/space-pipe.rs:22:25 + --> tests/ui/space-pipe.rs:22:34 | 22 | #[template(ext = "txt", source = "{{a | lower}}")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^ diff --git a/testing/tests/ui/transclude-missing.stderr b/testing/tests/ui/transclude-missing.stderr index 3d4e110ab..70ae829cf 100644 --- a/testing/tests/ui/transclude-missing.stderr +++ b/testing/tests/ui/transclude-missing.stderr @@ -1,15 +1,15 @@ error: template "transclude-missing.html" not found in directories ["$WORKSPACE/target/tests/trybuild/rinja_testing/templates"] --> testing/templates/transclude-there.html:1:2 " include \"transclude-missing.html\" %}" - --> tests/ui/transclude-missing.rs:4:12 + --> tests/ui/transclude-missing.rs:4:19 | 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:2 " include \"transclude-missing.html\" %}" - --> tests/ui/transclude-missing.rs:8:12 + --> tests/ui/transclude-missing.rs:8:21 | 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 0bb2e3745..b18eccee7 100644 --- a/testing/tests/ui/typo_in_keyword.stderr +++ b/testing/tests/ui/typo_in_keyword.stderr @@ -1,7 +1,7 @@ error: failed to parse template source --> :1:26 "endfo%}\n1234567890123456789012345678901234567890" - --> tests/ui/typo_in_keyword.rs:5:5 + --> tests/ui/typo_in_keyword.rs:5:14 | 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 cf5b19eb9..7f81e25d2 100644 --- a/testing/tests/ui/unclosed-nodes.stderr +++ b/testing/tests/ui/unclosed-nodes.stderr @@ -1,95 +1,95 @@ error: unclosed expression, missing "}}" --> :1:0 "{{ expr" - --> tests/ui/unclosed-nodes.rs:4:12 + --> tests/ui/unclosed-nodes.rs:4:21 | 4 | #[template(source = "{{ expr", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^ error: unclosed expression, missing "}}" --> :1:0 "{{ expr " - --> tests/ui/unclosed-nodes.rs:8:12 + --> tests/ui/unclosed-nodes.rs:8:21 | 8 | #[template(source = "{{ expr ", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^ error: unclosed expression, missing "}}" --> :1:0 "{{ expr -" - --> tests/ui/unclosed-nodes.rs:12:12 + --> tests/ui/unclosed-nodes.rs:12:21 | 12 | #[template(source = "{{ expr -", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^ error: failed to parse template source --> :1:9 "}" - --> tests/ui/unclosed-nodes.rs:16:12 + --> tests/ui/unclosed-nodes.rs:16:21 | 16 | #[template(source = "{{ expr -}", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^^ error: unclosed block, missing "%}" --> :1:0 "{% let x" - --> tests/ui/unclosed-nodes.rs:20:12 + --> tests/ui/unclosed-nodes.rs:20:21 | 20 | #[template(source = "{% let x", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^ error: unclosed block, missing "%}" --> :1:0 "{% let x " - --> tests/ui/unclosed-nodes.rs:24:12 + --> tests/ui/unclosed-nodes.rs:24:21 | 24 | #[template(source = "{% let x ", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^ error: unclosed block, missing "%}" --> :1:0 "{% let x -" - --> tests/ui/unclosed-nodes.rs:28:12 + --> tests/ui/unclosed-nodes.rs:28:21 | 28 | #[template(source = "{% let x -", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^^ error: failed to parse template source --> :1:10 "%" - --> tests/ui/unclosed-nodes.rs:32:12 + --> tests/ui/unclosed-nodes.rs:32:21 | 32 | #[template(source = "{% let x -%", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^^^ error: unclosed comment, missing "#}" --> :1:2 " comment" - --> tests/ui/unclosed-nodes.rs:36:12 + --> tests/ui/unclosed-nodes.rs:36:21 | 36 | #[template(source = "{# comment", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^^ error: unclosed comment, missing "#}" --> :1:2 " comment " - --> tests/ui/unclosed-nodes.rs:40:12 + --> tests/ui/unclosed-nodes.rs:40:21 | 40 | #[template(source = "{# comment ", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^^^ error: unclosed comment, missing "#}" --> :1:2 " comment -" - --> tests/ui/unclosed-nodes.rs:44:12 + --> tests/ui/unclosed-nodes.rs:44:21 | 44 | #[template(source = "{# comment -", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^^^^ error: unclosed comment, missing "#}" --> :1:2 " comment -#" - --> tests/ui/unclosed-nodes.rs:48:12 + --> tests/ui/unclosed-nodes.rs:48:21 | 48 | #[template(source = "{# comment -#", ext = "txt")] - | ^^^^^^ + | ^^^^^^^^^^^^^^^