Skip to content

Commit 8122cdf

Browse files
committed
rust: kernel: clean Rust 1.66.0 rustdoc::broken_intra_doc_links warnings
Since Rust 1.63.0, `rustdoc` complains with `broken_intra_doc_links` about intra-doc links pointing to exported `macro_rules`, e.g.: error: unresolved link to `dev_info` --> rust/kernel/device.rs:135:43 | 135 | /// More details are available from [`dev_info`]. | ^^^^^^^^ no item named `dev_info` in scope | = note: `macro_rules` named `dev_info` exists in this crate, but it is not in scope at this link's location = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings` error: aborting due to previous error The text is confusing, because the link still gets generated, and previous versions (<= 1.62) did not warn and also generated the link. This was reported upstream at [1], and it turns out that the link still being generated was a compatibility measure for docs.rs, which may get removed soon. Thus the intended behavior is that the user specifies the proper path. Therefore, clean up the `allow()`s introduced earlier to satisfy `rustdoc` and the new behavior. Link: rust-lang/rust#106142 [1] Reviewed-by: Björn Roy Baron <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Tested-by: Martin Rodriguez Reboredo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Reviewed-by: Alice Ferrazzi <[email protected]> Tested-by: Alice Ferrazzi <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Tested-by: Neal Gompa <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 3f893e1 commit 8122cdf

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

rust/kernel/build_assert.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ macro_rules! build_error {
6868
/// assert!(n > 1); // Run-time check
6969
/// }
7070
/// ```
71-
#[allow(rustdoc::broken_intra_doc_links)]
71+
///
72+
/// [`static_assert!`]: crate::static_assert!
7273
#[macro_export]
7374
macro_rules! build_assert {
7475
($cond:expr $(,)?) => {{

rust/kernel/device.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ pub unsafe trait RawDevice {
7373
/// Prints an emergency-level message (level 0) prefixed with device information.
7474
///
7575
/// More details are available from [`dev_emerg`].
76-
#[allow(rustdoc::broken_intra_doc_links)]
76+
///
77+
/// [`dev_emerg`]: crate::dev_emerg
7778
fn pr_emerg(&self, args: fmt::Arguments<'_>) {
7879
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
7980
unsafe { self.printk(bindings::KERN_EMERG, args) };
@@ -82,7 +83,8 @@ pub unsafe trait RawDevice {
8283
/// Prints an alert-level message (level 1) prefixed with device information.
8384
///
8485
/// More details are available from [`dev_alert`].
85-
#[allow(rustdoc::broken_intra_doc_links)]
86+
///
87+
/// [`dev_alert`]: crate::dev_alert
8688
fn pr_alert(&self, args: fmt::Arguments<'_>) {
8789
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
8890
unsafe { self.printk(bindings::KERN_ALERT, args) };
@@ -91,7 +93,8 @@ pub unsafe trait RawDevice {
9193
/// Prints a critical-level message (level 2) prefixed with device information.
9294
///
9395
/// More details are available from [`dev_crit`].
94-
#[allow(rustdoc::broken_intra_doc_links)]
96+
///
97+
/// [`dev_crit`]: crate::dev_crit
9598
fn pr_crit(&self, args: fmt::Arguments<'_>) {
9699
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
97100
unsafe { self.printk(bindings::KERN_CRIT, args) };
@@ -100,7 +103,8 @@ pub unsafe trait RawDevice {
100103
/// Prints an error-level message (level 3) prefixed with device information.
101104
///
102105
/// More details are available from [`dev_err`].
103-
#[allow(rustdoc::broken_intra_doc_links)]
106+
///
107+
/// [`dev_err`]: crate::dev_err
104108
fn pr_err(&self, args: fmt::Arguments<'_>) {
105109
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
106110
unsafe { self.printk(bindings::KERN_ERR, args) };
@@ -109,7 +113,8 @@ pub unsafe trait RawDevice {
109113
/// Prints a warning-level message (level 4) prefixed with device information.
110114
///
111115
/// More details are available from [`dev_warn`].
112-
#[allow(rustdoc::broken_intra_doc_links)]
116+
///
117+
/// [`dev_warn`]: crate::dev_warn
113118
fn pr_warn(&self, args: fmt::Arguments<'_>) {
114119
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
115120
unsafe { self.printk(bindings::KERN_WARNING, args) };
@@ -118,7 +123,8 @@ pub unsafe trait RawDevice {
118123
/// Prints a notice-level message (level 5) prefixed with device information.
119124
///
120125
/// More details are available from [`dev_notice`].
121-
#[allow(rustdoc::broken_intra_doc_links)]
126+
///
127+
/// [`dev_notice`]: crate::dev_notice
122128
fn pr_notice(&self, args: fmt::Arguments<'_>) {
123129
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
124130
unsafe { self.printk(bindings::KERN_NOTICE, args) };
@@ -127,7 +133,8 @@ pub unsafe trait RawDevice {
127133
/// Prints an info-level message (level 6) prefixed with device information.
128134
///
129135
/// More details are available from [`dev_info`].
130-
#[allow(rustdoc::broken_intra_doc_links)]
136+
///
137+
/// [`dev_info`]: crate::dev_info
131138
fn pr_info(&self, args: fmt::Arguments<'_>) {
132139
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
133140
unsafe { self.printk(bindings::KERN_INFO, args) };
@@ -136,7 +143,8 @@ pub unsafe trait RawDevice {
136143
/// Prints a debug-level message (level 7) prefixed with device information.
137144
///
138145
/// More details are available from [`dev_dbg`].
139-
#[allow(rustdoc::broken_intra_doc_links)]
146+
///
147+
/// [`dev_dbg`]: crate::dev_dbg
140148
fn pr_dbg(&self, args: fmt::Arguments<'_>) {
141149
if cfg!(debug_assertions) {
142150
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.

rust/kernel/fs/param.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ impl<const N: usize, S: 'static> SpecArray<N, S> {
275275
/// The type of the elements in `handlers` must be compatible with the types in specs. For
276276
/// example, if `specs` declares that the i-th element is a bool then the i-th handler
277277
/// should be for a bool.
278-
#[allow(rustdoc::broken_intra_doc_links)]
278+
///
279+
/// [`define_fs_params`]: crate::define_fs_params
279280
pub const unsafe fn new(specs: [Spec; N], handlers: [&'static dyn Handler<S>; N]) -> Self {
280281
let mut array = Self {
281282
specs: [ZERO_SPEC; N],
@@ -314,7 +315,8 @@ impl<const N: usize, S: 'static> SpecArray<N, S> {
314315
///
315316
/// Users are encouraged to use the [`define_fs_params`] macro to define the
316317
/// [`super::Context::PARAMS`] constant.
317-
#[allow(rustdoc::broken_intra_doc_links)]
318+
///
319+
/// [`define_fs_params`]: crate::define_fs_params
318320
pub struct SpecTable<'a, S: 'static> {
319321
pub(super) first: &'a bindings::fs_parameter_spec,
320322
pub(super) handlers: &'a [&'static dyn Handler<S>],
@@ -343,7 +345,8 @@ impl<const N: usize> ConstantArray<N> {
343345
///
344346
/// Users are encouraged to use the [`define_fs_params`] macro to define the
345347
/// [`super::Context::PARAMS`] constant.
346-
#[allow(rustdoc::broken_intra_doc_links)]
348+
///
349+
/// [`define_fs_params`]: crate::define_fs_params
347350
pub const fn new(consts: [(&'static CStr, u32); N]) -> Self {
348351
const ZERO: bindings::constant_table = bindings::constant_table {
349352
name: core::ptr::null(),

rust/kernel/gpio.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ impl<T: Chip> Registration<T> {
120120
///
121121
/// Users are encouraged to use the [`gpio_chip_register`] macro because it automatically
122122
/// defines the lock classes and calls the registration function.
123-
#[allow(rustdoc::broken_intra_doc_links)]
123+
///
124+
/// [`gpio_chip_register`]: crate::gpio_chip_register
124125
pub fn register(
125126
self: Pin<&mut Self>,
126127
gpio_count: u16,
@@ -343,7 +344,8 @@ mod irqchip {
343344
///
344345
/// Users are encouraged to use the [`gpio_irq_chip_register`] macro because it
345346
/// automatically defines the lock classes and calls the registration function.
346-
#[allow(rustdoc::broken_intra_doc_links)]
347+
///
348+
/// [`gpio_irq_chip_register`]: crate::gpio_irq_chip_register
347349
pub fn register<U: irq::Chip<Data = T::Data>>(
348350
mut self: Pin<&mut Self>,
349351
gpio_count: u16,

rust/kernel/std_vendor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@
133133
/// ```
134134
///
135135
/// [`std::dbg`]: https://doc.rust-lang.org/std/macro.dbg.html
136+
/// [`pr_info`]: crate::pr_info
136137
/// [`eprintln`]: https://doc.rust-lang.org/std/macro.eprintln.html
137138
/// [`printk`]: https://www.kernel.org/doc/html/latest/core-api/printk-basics.html
138-
#[allow(rustdoc::broken_intra_doc_links)]
139139
#[macro_export]
140140
macro_rules! dbg {
141141
// NOTE: We cannot use `concat!` to make a static string as a format argument

0 commit comments

Comments
 (0)