[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240417145058.7bad0df9@eugeo>
Date: Wed, 17 Apr 2024 14:50:58 +0100
From: Gary Guo <gary@...yguo.net>
To: <dev@...yte.com>
Cc: <ojeda@...nel.org>, <alex.gaynor@...il.com>, <wedsonaf@...il.com>,
<boqun.feng@...il.com>, <bjorn3_gh@...tonmail.com>,
<benno.lossin@...ton.me>, <a.hindborg@...sung.com>, <aliceryhl@...gle.com>,
<rust-for-linux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] rust: update `dbg!()` to format column number
On Sun, 14 Apr 2024 18:49:28 +0530
<dev@...yte.com> wrote:
> In Rust 1.76.0, the `dbg!()` macro was updated to also format the column
> number. The reason cited was usage of a few characters worth of
> horizontal space while allowing direct jumps to the source location. [1]
>
> Link: https://github.com/rust-lang/rust/pull/114962 [1]
> Link: https://github.com/Rust-for-Linux/linux/issues/1065
>
> Signed-off-by: Raghav Narang <dev@...yte.com>
Reviewed-by: Gary Guo <gary@...yguo.net>
> ---
> Branch rust-next
>
> rust/kernel/std_vendor.rs | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/rust/kernel/std_vendor.rs b/rust/kernel/std_vendor.rs
> index 388d6a514..39679a960 100644
> --- a/rust/kernel/std_vendor.rs
> +++ b/rust/kernel/std_vendor.rs
> @@ -146,15 +146,16 @@ macro_rules! dbg {
> // `$val` expression could be a block (`{ .. }`), in which case the `pr_info!`
> // will be malformed.
> () => {
> - $crate::pr_info!("[{}:{}]\n", ::core::file!(), ::core::line!())
> + $crate::pr_info!("[{}:{}:{}]\n", ::core::file!(), ::core::line!(), ::core::column!())
> };
> ($val:expr $(,)?) => {
> // Use of `match` here is intentional because it affects the lifetimes
> // of temporaries - https://stackoverflow.com/a/48732525/1063961
> match $val {
> tmp => {
> - $crate::pr_info!("[{}:{}] {} = {:#?}\n",
> - ::core::file!(), ::core::line!(), ::core::stringify!($val), &tmp);
> + $crate::pr_info!("[{}:{}:{}] {} = {:#?}\n",
> + ::core::file!(), ::core::line!(), ::core::column!(),
> + ::core::stringify!($val), &tmp);
> tmp
> }
> }
>
> base-commit: 8db31d3f3bd5dbc8cf3a22bba04b4b4add7f984e
Powered by blists - more mailing lists