Skip to content

Commit e418834

Browse files
Merge pull request askama-rs#322 from Kijewski/pr-c37ee6c72e8c9ba008e5090bb3eedfad1a2ae802
Remove intermediate allocations for error messages
2 parents 836046a + d0dcc1c commit e418834

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

rinja_derive/src/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl Config {
148148

149149
if !syntaxes.contains_key(default_syntax) {
150150
return Err(CompileError::new(
151-
format!("default syntax \"{default_syntax}\" not found"),
151+
format_args!("default syntax \"{default_syntax}\" not found"),
152152
file_info,
153153
));
154154
}
@@ -342,13 +342,13 @@ pub(crate) fn read_config_file(
342342
if filename.exists() {
343343
fs::read_to_string(&filename).map_err(|err| {
344344
CompileError::no_file_info(
345-
format!("unable to read {}: {err}", filename.display()),
345+
format_args!("unable to read {}: {err}", filename.display()),
346346
span,
347347
)
348348
})
349349
} else if config_path.is_some() {
350350
Err(CompileError::no_file_info(
351-
format!("`{}` does not exist", filename.display()),
351+
format_args!("`{}` does not exist", filename.display()),
352352
span,
353353
))
354354
} else {

rinja_parser/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -754,8 +754,9 @@ impl State<'_, '_> {
754754
.parse_next(i)?;
755755
if let Some(control) = control {
756756
let message = format!(
757-
"unclosed block, you likely meant to apply whitespace control: {:?}",
758-
format!("{control}{}", self.syntax.block_end),
757+
"unclosed block, you likely meant to apply whitespace control: \"{}{}\"",
758+
control.escape_default(),
759+
self.syntax.block_end.escape_default(),
759760
);
760761
Err(ParseErr::backtrack(ErrorContext::new(message, *i).into()))
761762
} else {

0 commit comments

Comments
 (0)