derive: way less noisy error messages

This commit is contained in:
René Kijewski 2024-07-29 13:42:45 +02:00
parent 380ecc1d8e
commit fa8c936cff
39 changed files with 437 additions and 583 deletions

View File

@ -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<Syntax<'a>> 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<Syntax<'a>> 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<RawConfig<'_>, 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<RawConfig<'_>, 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<String, Comp
if filename.exists() {
fs::read_to_string(&filename).map_err(|_| {
CompileError::no_file_info(format!("unable to read {:?}", filename.to_str().unwrap()))
CompileError::no_file_info(format!("unable to read {}", filename.display()), None)
})
} else if config_path.is_some() {
Err(CompileError::no_file_info(format!(
"`{}` does not exist",
root.display()
)))
Err(CompileError::no_file_info(
format!("`{}` does not exist", root.display()),
None,
))
} else {
Ok("".to_string())
}

View File

@ -2,14 +2,13 @@ use std::borrow::Cow;
use std::collections::hash_map::{Entry, HashMap};
use std::fs::read_to_string;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::{Arc, OnceLock};
use mime::Mime;
use once_map::OnceMap;
use parser::{Node, Parsed};
use quote::ToTokens;
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use crate::config::{Config, SyntaxAndCache};
use crate::{CompileError, FileInfo, MsgValidEscapers};
@ -61,6 +60,7 @@ impl TemplateInput<'_> {
(&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<String>,
config: Option<String>,
pub(crate) whitespace: Option<String>,
pub(crate) span: Option<proc_macro2::Span>,
}
impl TemplateArgs {
pub(crate) fn new(ast: &'_ syn::DeriveInput) -> Result<Self, CompileError> {
// 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::<syn::Meta, syn::Token![,]>::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:?}"
)));
v => {
return Err(CompileError::no_file_info(
format!("unsupported argument value type for `{ident}`"),
Some(v.span()),
));
}
},
_ => {
return Err(CompileError::no_file_info(format!(
"unsupported argument value type for {ident:?}"
)));
v => {
return Err(CompileError::no_file_info(
format!("unsupported argument value type for `{ident}`"),
Some(v.span()),
));
}
};
if ident == "path" {
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::Path(s.value()));
} else {
return Err(CompileError::no_file_info(
"template path must be string literal",
));
}
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<Source>,
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<String>,
) -> 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<Print, Self::Err> {
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<Path>, Arc<Path>)]) -> Result<(), CompileError> {
Err(CompileError::no_file_info(format!(
"cyclic dependency in graph {:#?}",
dependency_graph
.iter()
.map(|e| format!("{:#?} --> {:#?}", e.0, e.1))
.collect::<Vec<String>>()
)))
Err(CompileError::no_file_info(
format!(
"cyclic dependency in graph {:#?}",
dependency_graph
.iter()
.map(|e| format!("{:#?} --> {:#?}", e.0, e.1))
.collect::<Vec<String>>()
),
None,
))
}
pub(crate) fn get_template_source(

View File

@ -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<String, CompileError> {
/// value as passed to the `template()` attribute.
pub(crate) fn build_template(ast: &syn::DeriveInput) -> Result<String, CompileError> {
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<String, CompileError> {
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<String, CompileEr
if let Some(block_name) = input.block {
if !heritage.blocks.contains_key(&block_name) {
return Err(CompileError::no_file_info(format!(
"cannot find block {}",
block_name
)));
return Err(CompileError::no_file_info(
format!("cannot find block {}", block_name),
None,
));
}
}
@ -184,12 +200,12 @@ pub(crate) fn build_template(ast: &syn::DeriveInput) -> Result<String, CompileEr
#[derive(Debug, Clone)]
struct CompileError {
msg: String,
span: Span,
span: Option<Span>,
}
impl CompileError {
fn new<S: fmt::Display>(msg: S, file_info: Option<FileInfo<'_>>) -> 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<S: fmt::Display>(msg: S) -> Self {
fn no_file_info<S: fmt::Display>(msg: S, span: Option<Span>) -> 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()
}
}

View File

@ -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
--> <source attribute>: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
--> tests/ui/as-primitive-type.rs:8:3
|
7 | #[derive(Template)]
| ^^^^^^^^
|
= 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`
--> <source attribute>: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
--> tests/ui/as-primitive-type.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(source = r#"{{ 1234 as u1234 }}"#, ext = "html")]
| ^^^^^^^^
error: `as` operator expects the name of a primitive type on its right-hand side, found `core`
--> <source attribute>: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`
--> <source attribute>: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
--> tests/ui/as-primitive-type.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(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`
--> <source attribute>: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
--> tests/ui/as-primitive-type.rs:24:3
|
23 | #[derive(Template)]
| ^^^^^^^^
|
= 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")]
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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
--> tests/ui/blocks_below_top_level.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(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
--> tests/ui/blocks_below_top_level.rs:21:3
|
20 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
21 | #[template(source = r#"
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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
--> tests/ui/char_literal.rs:8:3
|
7 | #[derive(Template)]
| ^^^^^^^^
|
= 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
--> tests/ui/char_literal.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(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
--> tests/ui/char_literal.rs:24:3
|
23 | #[derive(Template)]
| ^^^^^^^^
|
= 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
--> <source attribute>:1:12
@ -95,9 +81,7 @@ error: invalid character
1 | {% let s = 'aaa' %}
| ^ close to this token
|
--> tests/ui/char_literal.rs:31:10
--> tests/ui/char_literal.rs:32:3
|
31 | #[derive(Template)]
| ^^^^^^^^
|
= 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")]
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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
--> tests/ui/error_file_path.rs:8:3
|
7 | #[derive(Template)]
| ^^^^^^^^
|
= 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
--> tests/ui/error_file_path.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(source = r#"{% extends "include_invalid_syntax.html" %}"#, ext = "txt")]
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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`
--> <source attribute>: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
--> tests/ui/extends.rs:11:3
|
10 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
11 | #[template(
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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) - %}
| ^^^^^^^^

View File

@ -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" %}"#)]
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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
--> <source attribute>: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
--> tests/ui/is_defined.rs:11:3
|
10 | #[derive(Template)]
| ^^^^^^^^
|
= 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`
--> <source attribute>: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
--> tests/ui/is_defined.rs:18:3
|
17 | #[derive(Template)]
| ^^^^^^^^
|
= 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`
--> <source attribute>: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`
--> <source attribute>: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
--> tests/ui/is_defined.rs:32:3
|
31 | #[derive(Template)]
| ^^^^^^^^
|
= 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`
--> <source attribute>: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
--> tests/ui/is_defined.rs:39:3
|
38 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
39 | #[template(
| ^^^^^^^^

View File

@ -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
--> tests/ui/iso646.rs:18:3
|
17 | #[derive(Template)]
| ^^^^^^^^
|
= 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
--> <source attribute>: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
--> tests/ui/iso646.rs:32:3
|
31 | #[derive(Template)]
| ^^^^^^^^
|
= 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 }}")]
| ^^^^^^^^

View File

@ -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) }}")]
| ^^^^^^^^

View File

@ -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
--> <source attribute>: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
--> tests/ui/let_destructuring_has_rest.rs:17:3
|
16 | #[derive(Template)]
| ^^^^^^^^
|
= 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
--> <source attribute>: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
--> tests/ui/let_destructuring_has_rest.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(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
--> tests/ui/let_destructuring_has_rest.rs:41:3
|
40 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
41 | #[template(source = "
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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
--> tests/ui/macro.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(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
--> tests/ui/macro.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(source = "{%- macro thrice() -%}
| ^^^^^^^^

View File

@ -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
--> <source attribute>: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
--> tests/ui/macro_named_argument.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(source = "{%- macro thrice(param1, param2) -%}
| ^^^^^^^^
error: failed to parse template source
--> <source attribute>: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
--> tests/ui/macro_named_argument.rs:21:3
|
20 | #[derive(Template)]
| ^^^^^^^^
|
= 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
--> <source attribute>: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
--> tests/ui/macro_named_argument.rs:38:3
|
37 | #[derive(Template)]
| ^^^^^^^^
|
= 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) -%}
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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#"
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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
--> tests/ui/no-such-escaper.rs:13:3
|
12 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
13 | #[template(
| ^^^^^^^^

View File

@ -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;
| ^^^^^^^^^^

View File

@ -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`
--> <source attribute>: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
--> tests/ui/num-suffix.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(
| ^^^^^^^^
error: unknown number suffix `u321`
--> <source attribute>:1:4
@ -30,9 +26,7 @@ error: unknown number suffix `u321`
1 | {{ 654u321 }}
| ^ close to this token
|
--> tests/ui/num-suffix.rs:18:10
--> tests/ui/num-suffix.rs:19:3
|
18 | #[derive(Template)]
| ^^^^^^^^
|
= note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)
19 | #[template(
| ^^^^^^^^

View File

@ -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")]
| ^^^^^^^^

View File

@ -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
--> tests/ui/space-pipe.rs:22:3
|
21 | #[derive(Template)]
| ^^^^^^^^
|
= 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}}")]
| ^^^^^^^^

View File

@ -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(
| ^^^^^^^^

View File

@ -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 "}}"
--> <source attribute>:1:1
@ -17,12 +15,10 @@ error: unclosed expression, missing "}}"
1 | {{ expr
| ^ close to this token
|
--> tests/ui/unclosed-nodes.rs:7:10
--> tests/ui/unclosed-nodes.rs:8:3
|
7 | #[derive(Template)]
| ^^^^^^^^
|
= 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 "}}"
--> <source attribute>:1:1
@ -30,12 +26,10 @@ error: unclosed expression, missing "}}"
1 | {{ expr -
| ^ close to this token
|
--> tests/ui/unclosed-nodes.rs:11:10
--> tests/ui/unclosed-nodes.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(source = "{{ expr -", ext = "txt")]
| ^^^^^^^^
error: failed to parse template source
--> <source attribute>: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 "%}"
--> <source attribute>:1:1
@ -56,12 +48,10 @@ error: unclosed block, missing "%}"
1 | {% let x
| ^ close to this token
|
--> tests/ui/unclosed-nodes.rs:19:10
--> tests/ui/unclosed-nodes.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(source = "{% let x", ext = "txt")]
| ^^^^^^^^
error: unclosed block, missing "%}"
--> <source attribute>:1:1
@ -69,12 +59,10 @@ error: unclosed block, missing "%}"
1 | {% let x
| ^ close to this token
|
--> tests/ui/unclosed-nodes.rs:23:10
--> tests/ui/unclosed-nodes.rs:24:3
|
23 | #[derive(Template)]
| ^^^^^^^^
|
= 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 "%}"
--> <source attribute>: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
--> <source attribute>: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
--> tests/ui/unclosed-nodes.rs:32:3
|
31 | #[derive(Template)]
| ^^^^^^^^
|
= 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 "#}"
--> <source attribute>:1:3
@ -108,12 +92,10 @@ error: unclosed comment, missing "#}"
1 | {# comment
| ^ close to this token
|
--> tests/ui/unclosed-nodes.rs:35:10
--> tests/ui/unclosed-nodes.rs:36:3
|
35 | #[derive(Template)]
| ^^^^^^^^
|
= 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 "#}"
--> <source attribute>: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 "#}"
--> <source attribute>:1:3
@ -134,12 +114,10 @@ error: unclosed comment, missing "#}"
1 | {# comment -
| ^ close to this token
|
--> tests/ui/unclosed-nodes.rs:43:10
--> tests/ui/unclosed-nodes.rs:44:3
|
43 | #[derive(Template)]
| ^^^^^^^^
|
= 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 "#}"
--> <source attribute>:1:3
@ -147,9 +125,7 @@ error: unclosed comment, missing "#}"
1 | {# comment -#
| ^ close to this token
|
--> tests/ui/unclosed-nodes.rs:47:10
--> tests/ui/unclosed-nodes.rs:48:3
|
47 | #[derive(Template)]
| ^^^^^^^^
|
= 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")]
| ^^^^^^^^