-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
What it does
This is a suggestion for an additional configuration option for missing_docs_in_private_items called allow_unused whereby _underscored fields do not have to have documentation even if missing_docs_in_private_items is enabled.
Advantage
When writing structures that must adhere to a specific format (such as memory mapped I/O structures) there are inevitably fields that are "reserved" by specifications and thus need no documentation. In cases where private docs are preferred but reserved fields need no explanation, having to #[allow/expect] this lint removes the ability to check for otherwise used fields' documentation.
Drawbacks
None that I can think of.
Example
/// The memory mapped register block for the HPET.
#[repr(C, align(8))]
struct HpetRegisters {
/// General capabilities and ID.
///
/// **Read only**
caps_and_id: Volatile<HpetCapsAndId>,
/// Reserved.
_reserved0: u64,
/// General Configuration Register
///
/// **Read write**
gen_cfg: Volatile<u64>,
/// Reserved.
_reserved1: u64,
/// General Interrupt Status Register
///
/// **Read write**
gen_status: Volatile<u64>,
/// Reserved.
_reserved2: u64,
/// Main counter value register
///
/// **Read write**
main_counter: Volatile<u64>,
/// Reserved.
_reserved3: u64,
/// Timers.
///
/// **Note that not all counters are available.**
/// The [`Self::caps_and_id`] field must be checked
/// for the number of timers that are present.
///
/// As of the 1.0a specification, timers 3 and above
/// (index 2 and greater) are **reserved**.
///
/// Accessing a timer that isn't indicated as available
/// is **undefined behavior**.
timers: [HpetTimer; 1 << 5],
}Could be written as:
/// The memory mapped register block for the HPET.
#[repr(C, align(8))]
struct HpetRegisters {
/// General capabilities and ID.
///
/// **Read only**
caps_and_id: Volatile<HpetCapsAndId>,
_reserved0: u64,
/// General Configuration Register
///
/// **Read write**
gen_cfg: Volatile<u64>,
_reserved1: u64,
/// General Interrupt Status Register
///
/// **Read write**
gen_status: Volatile<u64>,
_reserved2: u64,
/// Main counter value register
///
/// **Read write**
main_counter: Volatile<u64>,
_reserved3: u64,
/// Timers.
///
/// **Note that not all counters are available.**
/// The [`Self::caps_and_id`] field must be checked
/// for the number of timers that are present.
///
/// As of the 1.0a specification, timers 3 and above
/// (index 2 and greater) are **reserved**.
///
/// Accessing a timer that isn't indicated as available
/// is **undefined behavior**.
timers: [HpetTimer; 1 << 5],
}Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy