Skip to content

Commit fae4525

Browse files
iapainojeda
authored andcommitted
rust: std_vendor: update dbg macro from Rust upstream
`dbg!` contains adapted code from Rust upstream. Compare the kernel code with the Rust upstream one and update missing column numbers in `dbg!` outputs. Column numbers are not copied but adjusted for the kernel's examples. Suggested-by: Miguel Ojeda <[email protected]> Link: #1124 Signed-off-by: Deepak Thukral <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Fixed typo and slightly reworded. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 1f0433d commit fae4525

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

rust/kernel/std_vendor.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/// let a = 2;
1919
/// # #[expect(clippy::disallowed_macros)]
2020
/// let b = dbg!(a * 2) + 1;
21-
/// // ^-- prints: [src/main.rs:2] a * 2 = 4
21+
/// // ^-- prints: [src/main.rs:3:9] a * 2 = 4
2222
/// assert_eq!(b, 5);
2323
/// ```
2424
///
@@ -67,7 +67,7 @@
6767
/// This prints to the kernel log:
6868
///
6969
/// ```text,ignore
70-
/// [src/main.rs:4] n.checked_sub(4) = None
70+
/// [src/main.rs:3:8] n.checked_sub(4) = None
7171
/// ```
7272
///
7373
/// Naive factorial implementation:
@@ -88,15 +88,15 @@
8888
/// This prints to the kernel log:
8989
///
9090
/// ```text,ignore
91-
/// [src/main.rs:3] n <= 1 = false
92-
/// [src/main.rs:3] n <= 1 = false
93-
/// [src/main.rs:3] n <= 1 = false
94-
/// [src/main.rs:3] n <= 1 = true
95-
/// [src/main.rs:4] 1 = 1
96-
/// [src/main.rs:5] n * factorial(n - 1) = 2
97-
/// [src/main.rs:5] n * factorial(n - 1) = 6
98-
/// [src/main.rs:5] n * factorial(n - 1) = 24
99-
/// [src/main.rs:11] factorial(4) = 24
91+
/// [src/main.rs:3:8] n <= 1 = false
92+
/// [src/main.rs:3:8] n <= 1 = false
93+
/// [src/main.rs:3:8] n <= 1 = false
94+
/// [src/main.rs:3:8] n <= 1 = true
95+
/// [src/main.rs:4:9] 1 = 1
96+
/// [src/main.rs:5:9] n * factorial(n - 1) = 2
97+
/// [src/main.rs:5:9] n * factorial(n - 1) = 6
98+
/// [src/main.rs:5:9] n * factorial(n - 1) = 24
99+
/// [src/main.rs:11:1] factorial(4) = 24
100100
/// ```
101101
///
102102
/// The `dbg!(..)` macro moves the input:

0 commit comments

Comments
 (0)