From 4d860564cc8f6fe5b29559ecaccbc9d96bbc77fc Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 18 Nov 2026 11:58:57 +0100 Subject: [PATCH] Remove `#[allow(missing_docs)]` where possible --- .../alloc/src/collections/binary_heap/mod.rs | 2 +- library/alloc/src/io/buffered/bufreader.rs | 1 - library/core/src/alloc/layout.rs | 1 + library/core/src/error.rs | 2 +- library/core/src/intrinsics/mod.rs | 6 +++++- library/core/src/lib.rs | 1 - library/core/src/panicking.rs | 17 ++++++++++------- library/std/src/net/tcp.rs | 8 ++++++-- library/std/src/num/f32.rs | 1 - library/std/src/num/f64.rs | 1 - library/std/src/num/mod.rs | 1 - library/std/src/sys/pal/unix/mod.rs | 2 +- 12 files changed, 25 insertions(+), 18 deletions(-) diff --git a/library/alloc/src/collections/binary_heap/mod.rs b/library/alloc/src/collections/binary_heap/mod.rs index 1d7e6ad89a469..2c69b40eb5394 100644 --- a/library/alloc/src/collections/binary_heap/mod.rs +++ b/library/alloc/src/collections/binary_heap/mod.rs @@ -140,7 +140,6 @@ //! } //! ``` -#![allow(missing_docs)] #![stable(feature = "rust1", since = "1.0.0")] use core::alloc::Allocator; @@ -1797,6 +1796,7 @@ unsafe impl AsVecIntoIter for IntoIter { } } +/// Iterator which retrieves elements in heap order. #[must_use = "iterators are lazy and do nothing unless consumed"] #[unstable(feature = "binary_heap_into_iter_sorted", issue = "59278")] #[derive(Clone, Debug)] diff --git a/library/alloc/src/io/buffered/bufreader.rs b/library/alloc/src/io/buffered/bufreader.rs index c911746c2a611..a6f264bf29646 100644 --- a/library/alloc/src/io/buffered/bufreader.rs +++ b/library/alloc/src/io/buffered/bufreader.rs @@ -299,7 +299,6 @@ impl BufReader { impl BufReader { #[doc(hidden)] #[unstable(feature = "core_io_internals", reason = "exposed only for libstd", issue = "none")] - #[allow(missing_docs)] pub fn initialized(&self) -> bool { self.buf.initialized() } diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index 31b20e5967270..2f4ce37e9e41d 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -600,6 +600,7 @@ impl Layout { note = "Name does not follow std convention, use LayoutError", suggestion = "LayoutError" )] +/// Old name of [`LayoutError`]. pub type LayoutErr = LayoutError; /// The `LayoutError` is returned when the parameters given diff --git a/library/core/src/error.rs b/library/core/src/error.rs index b6de3eb1b44e5..9504236cad2dc 100644 --- a/library/core/src/error.rs +++ b/library/core/src/error.rs @@ -143,7 +143,7 @@ pub trait Error: Debug + Display { since = "1.33.0", note = "replaced by Error::source, which can support downcasting" )] - #[allow(missing_docs)] + /// Replaced by [`Error::source`]. fn cause(&self) -> Option<&dyn Error> { self.source() } diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 0a170fae1e186..5c20f4a93fb2e 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -103,15 +103,19 @@ use crate::sync::atomic::{ /// A type for atomic ordering parameters for intrinsics. This is a separate type from /// `atomic::Ordering` so that we can make it `ConstParamTy` and fix the values used here without a /// risk of leaking that to stable code. -#[allow(missing_docs)] #[derive(Debug, ConstParamTy, PartialEq, Eq)] pub enum AtomicOrdering { // These values must match the compiler's `AtomicOrdering` defined in // `rustc_middle/src/ty/consts/int.rs`! + /// [`Ordering::Relaxed`][`crate::sync::atomic::Ordering::Relaxed`] Relaxed = 0, + /// [`Ordering::Release`][`crate::sync::atomic::Ordering::Release`] Release = 1, + /// [`Ordering::Acquire`][`crate::sync::atomic::Ordering::Acquire`] Acquire = 2, + /// [`Ordering::AcqRel`][`crate::sync::atomic::Ordering::AcqRel`] AcqRel = 3, + /// [`Ordering::SeqCst`][`crate::sync::atomic::Ordering::SeqCst`] SeqCst = 4, } diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 15d0640bd0aaa..7f0f250a96486 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -343,7 +343,6 @@ pub mod future; pub mod task; /* Heap memory allocator trait */ -#[allow(missing_docs)] pub mod alloc; // note: does not need to be public diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 8a5e0f035d775..767707458d6a9 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -21,7 +21,7 @@ //! necessary lang items for the compiler. All panics are funneled through this //! one function. The actual symbol is declared through the `#[panic_handler]` attribute. -#![allow(dead_code, missing_docs)] +#![allow(dead_code)] #![unstable( feature = "panic_internals", reason = "internal details of the implementation of the `panic!` and related macros", @@ -182,6 +182,7 @@ macro_rules! panic_const { // slightly different forms. It's not clear if there's a good way to deduplicate without adding // special cases to the compiler (e.g., a const generic function wouldn't have a single definition // shared across crates, which is exactly what we want here). +#[allow(missing_docs)] pub mod panic_const { use super::*; panic_const! { @@ -233,9 +234,10 @@ pub fn panic_nounwind_nobacktrace(expr: &'static str) -> ! { panic_nounwind_fmt(fmt::Arguments::from_str(expr), /* force_no_backtrace */ true); } +/// Needed by `non-fmt-panics` lint. #[inline] #[track_caller] -#[rustc_diagnostic_item = "unreachable_display"] // needed for `non-fmt-panics` lint +#[rustc_diagnostic_item = "unreachable_display"] pub fn unreachable_display(x: &T) -> ! { panic_fmt(format_args!("internal error: entered unreachable code: {}", *x)); } @@ -250,9 +252,10 @@ pub const fn panic_str_2015(expr: &str) -> ! { panic_display(&expr); } +/// Needed for const-evaluated panics. #[inline] #[track_caller] -#[lang = "panic_display"] // needed for const-evaluated panics +#[lang = "panic_display"] #[rustc_do_not_const_check] // hooked by const-eval #[rustc_const_stable_indirect] // must follow stable const rules since it is exposed to stable pub const fn panic_display(x: &T) -> ! { @@ -457,7 +460,7 @@ fn assert_failed_inner( } } -// panic!() without args expands to this, to generate slightly less code +/// `panic!()` without args expands to this, to generate slightly less code. #[cfg_attr(not(panic = "immediate-abort"), inline(never), cold)] #[cfg_attr(panic = "immediate-abort", inline)] #[track_caller] @@ -465,7 +468,7 @@ pub const fn panic_default_msg() -> ! { panic("explicit panic") } -// unreachable!() without args expands to this, to generate slightly less code +/// `unreachable!()` without args expands to this, to generate slightly less code. #[cfg_attr(not(panic = "immediate-abort"), inline(never), cold)] #[cfg_attr(panic = "immediate-abort", inline)] #[track_caller] @@ -473,7 +476,7 @@ pub const fn unreachable_default_msg() -> ! { panic("internal error: entered unreachable code") } -// unimplemented!() without args expands to this, to generate slightly less code +/// `unimplemented!()` without args expands to this, to generate slightly less code. #[cfg_attr(not(panic = "immediate-abort"), inline(never), cold)] #[cfg_attr(panic = "immediate-abort", inline)] #[track_caller] @@ -481,7 +484,7 @@ pub const fn unimplemented_default_msg() -> ! { panic("not implemented") } -// todo!() without args expands to this, to generate slightly less code +/// `todo!()` without args expands to this, to generate slightly less code. #[cfg_attr(not(panic = "immediate-abort"), inline(never), cold)] #[cfg_attr(panic = "immediate-abort", inline)] #[track_caller] diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 7f3b00a315862..ae1bf03eb28b5 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -1110,16 +1110,20 @@ impl TcpListener { self.0.hop_limit_v6() } + /// Only allow v6 for this socket. + /// + /// ⚠️: This option can only be set before the socket is bound. #[stable(feature = "net2_mutators", since = "1.9.0")] #[deprecated(since = "1.16.0", note = "this option can only be set before the socket is bound")] - #[allow(missing_docs)] pub fn set_only_v6(&self, only_v6: bool) -> io::Result<()> { self.0.set_only_v6(only_v6) } + /// Checks if this socket only allow v6. + /// + /// ⚠️: This option can only be set before the socket is bound. #[stable(feature = "net2_mutators", since = "1.9.0")] #[deprecated(since = "1.16.0", note = "this option can only be set before the socket is bound")] - #[allow(missing_docs)] pub fn only_v6(&self) -> io::Result { self.0.only_v6() } diff --git a/library/std/src/num/f32.rs b/library/std/src/num/f32.rs index 67d72e8ecd638..738b6e1964cdd 100644 --- a/library/std/src/num/f32.rs +++ b/library/std/src/num/f32.rs @@ -10,7 +10,6 @@ //! defined directly on the `f32` type. #![stable(feature = "rust1", since = "1.0.0")] -#![allow(missing_docs)] #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, clippy::legacy_numeric_constants)] diff --git a/library/std/src/num/f64.rs b/library/std/src/num/f64.rs index dcab1615780b2..2b586321235c4 100644 --- a/library/std/src/num/f64.rs +++ b/library/std/src/num/f64.rs @@ -10,7 +10,6 @@ //! defined directly on the `f64` type. #![stable(feature = "rust1", since = "1.0.0")] -#![allow(missing_docs)] #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, clippy::legacy_numeric_constants)] diff --git a/library/std/src/num/mod.rs b/library/std/src/num/mod.rs index 2feaae34135fe..3d9e26569d40f 100644 --- a/library/std/src/num/mod.rs +++ b/library/std/src/num/mod.rs @@ -4,7 +4,6 @@ //! work. See the individual documentation for each piece for more information. #![stable(feature = "rust1", since = "1.0.0")] -#![allow(missing_docs)] #[unstable(feature = "complex_numbers", issue = "154023")] pub use core::num::Complex; diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 4b0bbdaf073ca..9b6eec8e322b8 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -1,4 +1,4 @@ -#![allow(missing_docs, nonstandard_style)] +#![allow(nonstandard_style)] use crate::io;