Skip to content

Commit ae7851c

Browse files
AmateurECEojeda
authored andcommitted
rust: macros: enable the rest of the tests
Now that the rusttest target for the macros crate is compiled with the kernel crate as a dependency, the rest of the rustdoc tests can be enabled. Signed-off-by: Ethan D. Twardy <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Link: #1076 Link: https://lore.kernel.org/r/[email protected] [ Rebased (use `K{Box,Vec}` instead, enable `lint_reasons` feature). Remove unneeded `rust` as language in examples, as well as `#[macro_use]` `extern`s. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 7e06561 commit ae7851c

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

rust/macros/lib.rs

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub fn module(ts: TokenStream) -> TokenStream {
137137
///
138138
/// # Examples
139139
///
140-
/// ```ignore
140+
/// ```
141141
/// use kernel::error::VTABLE_DEFAULT_ERROR;
142142
/// use kernel::prelude::*;
143143
///
@@ -182,12 +182,27 @@ pub fn vtable(attr: TokenStream, ts: TokenStream) -> TokenStream {
182182
///
183183
/// # Examples
184184
///
185-
/// ```ignore
186-
/// use kernel::macro::concat_idents;
185+
/// ```
186+
/// # const binder_driver_return_protocol_BR_OK: u32 = 0;
187+
/// # const binder_driver_return_protocol_BR_ERROR: u32 = 1;
188+
/// # const binder_driver_return_protocol_BR_TRANSACTION: u32 = 2;
189+
/// # const binder_driver_return_protocol_BR_REPLY: u32 = 3;
190+
/// # const binder_driver_return_protocol_BR_DEAD_REPLY: u32 = 4;
191+
/// # const binder_driver_return_protocol_BR_TRANSACTION_COMPLETE: u32 = 5;
192+
/// # const binder_driver_return_protocol_BR_INCREFS: u32 = 6;
193+
/// # const binder_driver_return_protocol_BR_ACQUIRE: u32 = 7;
194+
/// # const binder_driver_return_protocol_BR_RELEASE: u32 = 8;
195+
/// # const binder_driver_return_protocol_BR_DECREFS: u32 = 9;
196+
/// # const binder_driver_return_protocol_BR_NOOP: u32 = 10;
197+
/// # const binder_driver_return_protocol_BR_SPAWN_LOOPER: u32 = 11;
198+
/// # const binder_driver_return_protocol_BR_DEAD_BINDER: u32 = 12;
199+
/// # const binder_driver_return_protocol_BR_CLEAR_DEATH_NOTIFICATION_DONE: u32 = 13;
200+
/// # const binder_driver_return_protocol_BR_FAILED_REPLY: u32 = 14;
201+
/// use kernel::macros::concat_idents;
187202
///
188203
/// macro_rules! pub_no_prefix {
189204
/// ($prefix:ident, $($newname:ident),+) => {
190-
/// $(pub(crate) const $newname: u32 = kernel::macros::concat_idents!($prefix, $newname);)+
205+
/// $(pub(crate) const $newname: u32 = concat_idents!($prefix, $newname);)+
191206
/// };
192207
/// }
193208
///
@@ -233,7 +248,11 @@ pub fn concat_idents(ts: TokenStream) -> TokenStream {
233248
///
234249
/// # Examples
235250
///
236-
/// ```rust,ignore
251+
/// ```
252+
/// # #![feature(lint_reasons)]
253+
/// # use kernel::prelude::*;
254+
/// # use std::{sync::Mutex, process::Command};
255+
/// # use kernel::macros::pin_data;
237256
/// #[pin_data]
238257
/// struct DriverData {
239258
/// #[pin]
@@ -242,7 +261,17 @@ pub fn concat_idents(ts: TokenStream) -> TokenStream {
242261
/// }
243262
/// ```
244263
///
245-
/// ```rust,ignore
264+
/// ```
265+
/// # #![feature(lint_reasons)]
266+
/// # use kernel::prelude::*;
267+
/// # use std::{sync::Mutex, process::Command};
268+
/// # use core::pin::Pin;
269+
/// # pub struct Info;
270+
/// # mod bindings {
271+
/// # pub unsafe fn destroy_info(_ptr: *mut super::Info) {}
272+
/// # }
273+
/// use kernel::macros::{pin_data, pinned_drop};
274+
///
246275
/// #[pin_data(PinnedDrop)]
247276
/// struct DriverData {
248277
/// #[pin]
@@ -257,6 +286,7 @@ pub fn concat_idents(ts: TokenStream) -> TokenStream {
257286
/// unsafe { bindings::destroy_info(self.raw_info) };
258287
/// }
259288
/// }
289+
/// # fn main() {}
260290
/// ```
261291
///
262292
/// [`pin_init!`]: ../kernel/macro.pin_init.html
@@ -272,13 +302,22 @@ pub fn pin_data(inner: TokenStream, item: TokenStream) -> TokenStream {
272302
///
273303
/// # Examples
274304
///
275-
/// ```rust,ignore
305+
/// ```
306+
/// # #![feature(lint_reasons)]
307+
/// # use kernel::prelude::*;
308+
/// # use macros::{pin_data, pinned_drop};
309+
/// # use std::{sync::Mutex, process::Command};
310+
/// # use core::pin::Pin;
311+
/// # mod bindings {
312+
/// # pub struct Info;
313+
/// # pub unsafe fn destroy_info(_ptr: *mut Info) {}
314+
/// # }
276315
/// #[pin_data(PinnedDrop)]
277316
/// struct DriverData {
278317
/// #[pin]
279318
/// queue: Mutex<KVec<Command>>,
280319
/// buf: KBox<[u8; 1024 * 1024]>,
281-
/// raw_info: *mut Info,
320+
/// raw_info: *mut bindings::Info,
282321
/// }
283322
///
284323
/// #[pinned_drop]
@@ -439,7 +478,9 @@ pub fn paste(input: TokenStream) -> TokenStream {
439478
///
440479
/// # Examples
441480
///
442-
/// ```rust,ignore
481+
/// ```
482+
/// use kernel::macros::Zeroable;
483+
///
443484
/// #[derive(Zeroable)]
444485
/// pub struct DriverData {
445486
/// id: i64,

0 commit comments

Comments
 (0)