Skip to content

Commit d0c1405

Browse files
tesujiojeda
andcommitted
Document why cannot use concat! in dbg!
Co-authored-by: Miguel Ojeda <[email protected]>
1 parent a4cbb44 commit d0c1405

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/std/src/macros.rs

+4
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ macro_rules! eprintln {
282282
#[macro_export]
283283
#[stable(feature = "dbg_macro", since = "1.32.0")]
284284
macro_rules! dbg {
285+
// NOTE: We cannot use `concat!` to make a static string as a format argument
286+
// of `eprintln!` because `file!` could contain a `{` or
287+
// `$val` expression could be a block (`{ .. }`), in which case the `eprintln!`
288+
// will be malformed.
285289
() => {
286290
$crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!());
287291
};

0 commit comments

Comments
 (0)