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)]