summaryrefslogtreecommitdiffstats
path: root/rust/kernel/lib.rs
diff options
context:
space:
mode:
authorNiklas Mohrin <dev@niklasmohrin.de>2022-11-10 17:41:35 +0100
committerMiguel Ojeda <ojeda@kernel.org>2022-12-04 01:59:16 +0100
commitbee1688940b9264a9960e6afdac36a4af35f1f4b (patch)
tree3eeabe64b06a6159574abc753c9546fbee63cb4c /rust/kernel/lib.rs
parentef32054942ee8d78cbcc2c97212e55b6f5f668f7 (diff)
downloadlinux-bee1688940b9264a9960e6afdac36a4af35f1f4b.tar.bz2
rust: std_vendor: add `dbg!` macro based on `std`'s one
The Rust standard library has a really handy macro, `dbg!` [1,2]. It prints the source location (filename and line) along with the raw source code that is invoked with and the `Debug` representation of the given expression, e.g.: let a = 2; let b = dbg!(a * 2) + 1; // ^-- prints: [src/main.rs:2] a * 2 = 4 assert_eq!(b, 5); Port the macro over to the `kernel` crate inside a new module called `std_vendor`, using `pr_info!` instead of `eprintln!` and make the rules about committing uses of `dbg!` into version control more concrete (i.e. tailored for the kernel). Since the source code for the macro is taken from the standard library source (with only minor adjustments), the new file is licensed under `Apache 2.0 OR MIT`, just like the original [3,4]. Link: https://doc.rust-lang.org/std/macro.dbg.html [1] Link: https://github.com/rust-lang/rust/blob/master/library/std/src/macros.rs#L212 [2] Link: https://github.com/rust-lang/rust/blob/master/library/std/Cargo.toml [3] Link: https://github.com/rust-lang/rust/blob/master/COPYRIGHT [4] Signed-off-by: Niklas Mohrin <dev@niklasmohrin.de> [Reworded, adapted for upstream and applied latest changes] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust/kernel/lib.rs')
-rw-r--r--rust/kernel/lib.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs
index ffc6626a6d29..d6371c9c8453 100644
--- a/rust/kernel/lib.rs
+++ b/rust/kernel/lib.rs
@@ -26,6 +26,8 @@ mod allocator;
pub mod error;
pub mod prelude;
pub mod print;
+#[doc(hidden)]
+pub mod std_vendor;
pub mod str;
#[doc(hidden)]