Skip to content

Commit a495bae

Browse files
ojedaKaz205
authored andcommitted
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 <bjorn3_gh@protonmail.com> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Tested-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 8eed401 commit a495bae

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
@@ -67,7 +67,8 @@ macro_rules! build_error {
6767
/// assert!(n > 1); // Run-time check
6868
/// }
6969
/// ```
70-
#[allow(rustdoc::broken_intra_doc_links)]
70+
///
71+
/// [`static_assert!`]: crate::static_assert!
7172
#[macro_export]
7273
macro_rules! build_assert {
7374
($cond:expr $(,)?) => {{

rust/kernel/device.rs

+16-8
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ pub unsafe trait RawDevice {
121121
/// Prints an emergency-level message (level 0) prefixed with device information.
122122
///
123123
/// More details are available from [`dev_emerg`].
124-
#[allow(rustdoc::broken_intra_doc_links)]
124+
///
125+
/// [`dev_emerg`]: crate::dev_emerg
125126
fn pr_emerg(&self, args: fmt::Arguments<'_>) {
126127
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
127128
unsafe { self.printk(bindings::KERN_EMERG, args) };
@@ -130,7 +131,8 @@ pub unsafe trait RawDevice {
130131
/// Prints an alert-level message (level 1) prefixed with device information.
131132
///
132133
/// More details are available from [`dev_alert`].
133-
#[allow(rustdoc::broken_intra_doc_links)]
134+
///
135+
/// [`dev_alert`]: crate::dev_alert
134136
fn pr_alert(&self, args: fmt::Arguments<'_>) {
135137
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
136138
unsafe { self.printk(bindings::KERN_ALERT, args) };
@@ -139,7 +141,8 @@ pub unsafe trait RawDevice {
139141
/// Prints a critical-level message (level 2) prefixed with device information.
140142
///
141143
/// More details are available from [`dev_crit`].
142-
#[allow(rustdoc::broken_intra_doc_links)]
144+
///
145+
/// [`dev_crit`]: crate::dev_crit
143146
fn pr_crit(&self, args: fmt::Arguments<'_>) {
144147
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
145148
unsafe { self.printk(bindings::KERN_CRIT, args) };
@@ -148,7 +151,8 @@ pub unsafe trait RawDevice {
148151
/// Prints an error-level message (level 3) prefixed with device information.
149152
///
150153
/// More details are available from [`dev_err`].
151-
#[allow(rustdoc::broken_intra_doc_links)]
154+
///
155+
/// [`dev_err`]: crate::dev_err
152156
fn pr_err(&self, args: fmt::Arguments<'_>) {
153157
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
154158
unsafe { self.printk(bindings::KERN_ERR, args) };
@@ -157,7 +161,8 @@ pub unsafe trait RawDevice {
157161
/// Prints a warning-level message (level 4) prefixed with device information.
158162
///
159163
/// More details are available from [`dev_warn`].
160-
#[allow(rustdoc::broken_intra_doc_links)]
164+
///
165+
/// [`dev_warn`]: crate::dev_warn
161166
fn pr_warn(&self, args: fmt::Arguments<'_>) {
162167
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
163168
unsafe { self.printk(bindings::KERN_WARNING, args) };
@@ -166,7 +171,8 @@ pub unsafe trait RawDevice {
166171
/// Prints a notice-level message (level 5) prefixed with device information.
167172
///
168173
/// More details are available from [`dev_notice`].
169-
#[allow(rustdoc::broken_intra_doc_links)]
174+
///
175+
/// [`dev_notice`]: crate::dev_notice
170176
fn pr_notice(&self, args: fmt::Arguments<'_>) {
171177
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
172178
unsafe { self.printk(bindings::KERN_NOTICE, args) };
@@ -175,7 +181,8 @@ pub unsafe trait RawDevice {
175181
/// Prints an info-level message (level 6) prefixed with device information.
176182
///
177183
/// More details are available from [`dev_info`].
178-
#[allow(rustdoc::broken_intra_doc_links)]
184+
///
185+
/// [`dev_info`]: crate::dev_info
179186
fn pr_info(&self, args: fmt::Arguments<'_>) {
180187
// SAFETY: `klevel` is null-terminated, uses one of the kernel constants.
181188
unsafe { self.printk(bindings::KERN_INFO, args) };
@@ -184,7 +191,8 @@ pub unsafe trait RawDevice {
184191
/// Prints a debug-level message (level 7) prefixed with device information.
185192
///
186193
/// More details are available from [`dev_dbg`].
187-
#[allow(rustdoc::broken_intra_doc_links)]
194+
///
195+
/// [`dev_dbg`]: crate::dev_dbg
188196
fn pr_dbg(&self, args: fmt::Arguments<'_>) {
189197
if cfg!(debug_assertions) {
190198
// 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
@@ -135,9 +135,9 @@
135135
/// ```
136136
///
137137
/// [`std::dbg`]: https://doc.rust-lang.org/std/macro.dbg.html
138+
/// [`pr_info`]: crate::pr_info
138139
/// [`eprintln`]: https://doc.rust-lang.org/std/macro.eprintln.html
139140
/// [`printk`]: https://www.kernel.org/doc/html/latest/core-api/printk-basics.html
140-
#[allow(rustdoc::broken_intra_doc_links)]
141141
#[macro_export]
142142
macro_rules! dbg {
143143
// NOTE: We cannot use `concat!` to make a static string as a format argument

0 commit comments

Comments
 (0)