mirror of
https://github.com/askama-rs/askama.git
synced 2025-10-02 23:35:07 +00:00
Remove intermediate allocations for error messages
This commit is contained in:
parent
cae09c50f4
commit
d0dcc1c0ce
@ -148,7 +148,7 @@ impl Config {
|
|||||||
|
|
||||||
if !syntaxes.contains_key(default_syntax) {
|
if !syntaxes.contains_key(default_syntax) {
|
||||||
return Err(CompileError::new(
|
return Err(CompileError::new(
|
||||||
format!("default syntax \"{default_syntax}\" not found"),
|
format_args!("default syntax \"{default_syntax}\" not found"),
|
||||||
file_info,
|
file_info,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -342,13 +342,13 @@ pub(crate) fn read_config_file(
|
|||||||
if filename.exists() {
|
if filename.exists() {
|
||||||
fs::read_to_string(&filename).map_err(|err| {
|
fs::read_to_string(&filename).map_err(|err| {
|
||||||
CompileError::no_file_info(
|
CompileError::no_file_info(
|
||||||
format!("unable to read {}: {err}", filename.display()),
|
format_args!("unable to read {}: {err}", filename.display()),
|
||||||
span,
|
span,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else if config_path.is_some() {
|
} else if config_path.is_some() {
|
||||||
Err(CompileError::no_file_info(
|
Err(CompileError::no_file_info(
|
||||||
format!("`{}` does not exist", filename.display()),
|
format_args!("`{}` does not exist", filename.display()),
|
||||||
span,
|
span,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
@ -754,8 +754,9 @@ impl State<'_, '_> {
|
|||||||
.parse_next(i)?;
|
.parse_next(i)?;
|
||||||
if let Some(control) = control {
|
if let Some(control) = control {
|
||||||
let message = format!(
|
let message = format!(
|
||||||
"unclosed block, you likely meant to apply whitespace control: {:?}",
|
"unclosed block, you likely meant to apply whitespace control: \"{}{}\"",
|
||||||
format!("{control}{}", self.syntax.block_end),
|
control.escape_default(),
|
||||||
|
self.syntax.block_end.escape_default(),
|
||||||
);
|
);
|
||||||
Err(ParseErr::backtrack(ErrorContext::new(message, *i).into()))
|
Err(ParseErr::backtrack(ErrorContext::new(message, *i).into()))
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user