From d0c1405564024d109ec22b130584d74fcb82d153 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 21 Jan 2021 01:42:37 +0000 Subject: [PATCH] Document why cannot use concat! in dbg! Co-authored-by: Miguel Ojeda --- library/std/src/macros.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs index 5a70aa070e870..e466f3151524c 100644 --- a/library/std/src/macros.rs +++ b/library/std/src/macros.rs @@ -282,6 +282,10 @@ macro_rules! eprintln { #[macro_export] #[stable(feature = "dbg_macro", since = "1.32.0")] macro_rules! dbg { + // NOTE: We cannot use `concat!` to make a static string as a format argument + // of `eprintln!` because `file!` could contain a `{` or + // `$val` expression could be a block (`{ .. }`), in which case the `eprintln!` + // will be malformed. () => { $crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!()); };