Skip to content

Commit bdff1da

Browse files
committed
Enable rustfmt formatting of code in doc comments
It is not enabled by default, but it is quite an important feature! Signed-off-by: Miguel Ojeda <[email protected]>
1 parent de33f8a commit bdff1da

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
edition = "2018"
2+
format_code_in_doc_comments = true

rust/kernel/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn panic(_info: &PanicInfo) -> ! {
154154
/// // This prints `8`.
155155
/// println!("{}", offset_of!(Test, b));
156156
/// }
157-
///```
157+
/// ```
158158
#[macro_export]
159159
macro_rules! offset_of {
160160
($type:ty, $($f:tt)*) => {{
@@ -189,14 +189,13 @@ macro_rules! offset_of {
189189
/// }
190190
///
191191
/// fn test() {
192-
/// let test = Test{a: 10, b: 20};
192+
/// let test = Test { a: 10, b: 20 };
193193
/// let b_ptr = &test.b;
194194
/// let test_alias = unsafe { container_of!(b_ptr, Test, b) };
195195
/// // This prints `true`.
196196
/// println!("{}", core::ptr::eq(&test, test_alias));
197197
/// }
198-
///```
199-
///
198+
/// ```
200199
#[macro_export]
201200
macro_rules! container_of {
202201
($ptr:expr, $type:ty, $($f:tt)*) => {{

rust/kernel/module_param.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ macro_rules! impl_module_param {
211211
/// make_param_ops!(
212212
/// /// Documentation for new param ops.
213213
/// PARAM_OPS_MYTYPE, // Name for the static.
214-
/// MyType // A type which implements [`ModuleParam`].
214+
/// MyType // A type which implements [`ModuleParam`].
215215
/// );
216216
/// ```
217217
macro_rules! make_param_ops {

rust/kernel/static_assert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/// static_assert!(X[1] == 'a' as u8);
2323
///
2424
/// const fn f(x: i32) -> i32 {
25-
/// x + 2
25+
/// x + 2
2626
/// }
2727
/// static_assert!(f(40) == 42);
2828
/// ```

rust/kernel/sync/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!```
1111
//! fn test() {
1212
//! // SAFETY: `init` is called below.
13-
//! let data = alloc::sync::Arc::pin(unsafe{ Mutex::new(0) });
13+
//! let data = alloc::sync::Arc::pin(unsafe { Mutex::new(0) });
1414
//! mutex_init!(data.as_ref(), "test::data");
1515
//! *data.lock() = 10;
1616
//! kernel::println!("{}", *data.lock());

0 commit comments

Comments
 (0)