Skip to content

Commit

Permalink
ci: switch most #[allow()] annotations to #[expect()]
Browse files Browse the repository at this point in the history
  • Loading branch information
Qix- committed Sep 8, 2024
1 parent 02c1de6 commit 4fdfb5e
Show file tree
Hide file tree
Showing 47 changed files with 129 additions and 153 deletions.
6 changes: 3 additions & 3 deletions oro-acpi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<P: Translator> Rsdp<P> {
}

// SAFETY(qix-): Uses unstable feature `trivial_bounds`.
#[allow(trivial_bounds)]
#[expect(trivial_bounds)]
impl<P: Translator> core::fmt::Debug for Rsdp<P>
where
sys::acpi_table_rsdp: core::fmt::Debug,
Expand Down Expand Up @@ -317,7 +317,7 @@ macro_rules! impl_tables {
}

// SAFETY(qix-): Uses unstable feature `trivial_bounds`.
#[allow(trivial_bounds)]
#[expect(trivial_bounds)]
impl<P: Translator> core::fmt::Debug for $ident<P> where $systbl_ident: core::fmt::Debug {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.ptr.fmt(f)
Expand Down Expand Up @@ -366,7 +366,7 @@ pub trait FromLe64<const ORIG: usize> {
// TODO(qix-): the numbers common lib will probably have better names for this.
// TODO(qix-): When this is copied over, remove the `#[allow(clippy::wrong_self_convention)]`
// TODO(qix-): and let's find a better name.
#[allow(clippy::wrong_self_convention)]
#[expect(clippy::wrong_self_convention)]
fn from_le_64(self) -> u64;
}

Expand Down
5 changes: 2 additions & 3 deletions oro-acpi/src/madt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ impl<'a> Iterator for MadtIterator<'a> {
}
}

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
macro_rules! madt_entries {
($($(#[$meta:meta])* $name:tt = $tyid:literal),* $(,)?) => {
paste! {
/// Represents an entry in the MADT table.
#[allow(missing_docs)]
#[expect(missing_docs)]
#[non_exhaustive]
pub enum MadtEntry<'a> {
$(
Expand Down Expand Up @@ -116,7 +116,6 @@ macro_rules! madt_entries {
}

/// A union of all APIC types. Used by the [`MadtIterator`].
#[allow(missing_docs)]
#[repr(C)]
union MadtData {
header: ManuallyDrop<sys::ACPI_SUBTABLE_HEADER>,
Expand Down
1 change: 0 additions & 1 deletion oro-acpica-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use ::convert_case::{Case, Casing};
use ::quote::ToTokens;

#[allow(clippy::missing_docs_in_private_items)]
fn main() {
let out_dir = std::env::var("OUT_DIR").unwrap();
let dest_path = std::path::Path::new(&out_dir).join("bindings.rs");
Expand Down
11 changes: 5 additions & 6 deletions oro-arch-aarch64/src/boot/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct PreparedMemory {
/// once during boot.
pub unsafe fn prepare_memory() -> PreparedMemory {
// First, let's make sure the recurisive page table is set up correctly.
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
const RIDX: usize = AddressSpaceLayout::RECURSIVE_ENTRY_IDX.0;
// SAFETY(qix-): We load TTBR1 which is always safe, and then do a
// SAFETY(qix-): safe instruction to ask the CPU to resolve the virtual address
Expand Down Expand Up @@ -144,7 +144,7 @@ unsafe fn linear_map_regions<'a>(
regions: MemoryMapIterator<'a>,
) -> Option<u64> {
// Get the virtual address of the linear map base.
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
const LINEAR_MAP_IDX: (usize, usize) = AddressSpaceLayout::LINEAR_MAP_IDX;
let linear_map_base = 0xFFFF_0000_0000_0000 | (LINEAR_MAP_IDX.0 << 39) as u64;
let linear_map_last_incl = !(511 << 39) | (LINEAR_MAP_IDX.1 << 39) as u64;
Expand Down Expand Up @@ -207,7 +207,7 @@ unsafe fn linear_map_regions<'a>(
continue;
}

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
const RIDX: usize = crate::mem::address_space::AddressSpaceLayout::RECURSIVE_ENTRY_IDX.0;

let mut total_mappings = 0;
Expand Down Expand Up @@ -415,7 +415,6 @@ impl<'a> MemoryMapPfa<'a> {

/// Consumes this iterator and returns the remaining
/// entry and usable memory regions iterator.
#[allow(dead_code)] // XXX(qix-): temporary
#[must_use]
fn into_inner(self) -> (MemoryMapEntry, MemoryMapIterator<'a>) {
(self.current_entry, self.iterator)
Expand Down Expand Up @@ -564,9 +563,9 @@ impl OnTheFlyMapper {
// Assuming the recursive map exists (it does if we're here),
// we can calculate the virtual address of the L1 page table
// for the OTF region.
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
const RIDX: usize = crate::mem::address_space::AddressSpaceLayout::RECURSIVE_ENTRY_IDX.0;
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
const OTF_IDX: usize = crate::mem::address_space::AddressSpaceLayout::BOOT_RESERVED_IDX;

debug_assert!(OTF_IDX < 512, "OTF_IDX is out of bounds");
Expand Down
5 changes: 2 additions & 3 deletions oro-arch-aarch64/src/boot/secondary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub unsafe fn boot_secondaries(
// Get the PSCI method.
let mut psci_method: Option<PsciMethod> = None;
for tkn in dtb.iter().filter_path(&[c"", c"psci"]) {
#[allow(clippy::redundant_guards)] // False positive
#[expect(clippy::redundant_guards)] // False positive
match tkn {
FdtToken::Property { name, value } if name == c"method" => {
let Ok(value) = CStr::from_bytes_with_nul(value) else {
Expand Down Expand Up @@ -81,7 +81,7 @@ pub unsafe fn boot_secondaries(
let mut cpu_id: u64 = 0;
let mut valid: bool = false;
for tkn in dtb.iter().filter_path(&[c"", c"cpus", c"cpu@"]) {
#[allow(clippy::redundant_guards)] // False positive
#[expect(clippy::redundant_guards)] // False positive
match tkn {
FdtToken::Node { name } => {
is_cpu = true;
Expand Down Expand Up @@ -338,7 +338,6 @@ unsafe fn boot_secondary(
// Allocate the boot stubs (maximum 4096 bytes).
let boot_phys = pfa.allocate().ok_or(SecondaryBootError::OutOfMemory)?;
let boot_virt = pat.translate_mut::<[u8; 4096]>(boot_phys);
#[allow(clippy::missing_docs_in_private_items)]
(&mut *boot_virt)[..SECONDARY_BOOT_STUB.len()].copy_from_slice(SECONDARY_BOOT_STUB);

// Direct map the boot stubs into the lower page table.
Expand Down
1 change: 0 additions & 1 deletion oro-arch-aarch64/src/mair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl MairEntry {
let mut mair = MairRegister::new();

for entry in MairEntry::iter_all() {
#[allow(clippy::match_same_arms)]
match entry {
MairEntry::DeviceMMIO => {
*mair[usize::from(entry.index())].device_mut() = MairDeviceAttribute::DnGnRnE;
Expand Down
19 changes: 9 additions & 10 deletions oro-arch-aarch64/src/mem/address_space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl AddressSpaceLayout {
/// Returns the segment descriptor for the kernel transfer stubs.
#[must_use]
pub fn stubs() -> <Self as AddressSpace>::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: AddressSpaceLayout::STUBS_IDX,
Expand All @@ -131,7 +131,7 @@ impl AddressSpaceLayout {
/// Returns the segment descriptor for the kernel stack.
#[must_use]
pub fn kernel_stack() -> <Self as AddressSpace>::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand Down Expand Up @@ -254,7 +254,6 @@ unsafe impl AddressSpace for AddressSpaceLayout {
// NOTE(qix-): Technically this isn't required since the kernel currently
// NOTE(qix-): requires `TCR_EL1.TnSZ=16`, but it's cheap and not often
// NOTE(qix-): called, so we'll just do it anyway.
#[allow(clippy::cast_possible_truncation)]
let (tt1_start, _) = TcrEl1::load().tt1_range();

let base_phys = crate::asm::load_ttbr1();
Expand Down Expand Up @@ -300,7 +299,7 @@ unsafe impl AddressSpace for AddressSpaceLayout {
}

fn kernel_code() -> Self::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand All @@ -325,7 +324,7 @@ unsafe impl AddressSpace for AddressSpaceLayout {
}

fn kernel_data() -> Self::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand All @@ -351,7 +350,7 @@ unsafe impl AddressSpace for AddressSpaceLayout {
}

fn kernel_rodata() -> Self::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand All @@ -377,7 +376,7 @@ unsafe impl AddressSpace for AddressSpaceLayout {
}

fn kernel_stack() -> Self::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand All @@ -403,7 +402,7 @@ unsafe impl AddressSpace for AddressSpaceLayout {
}

fn kernel_ring_registry() -> Self::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand Down Expand Up @@ -441,7 +440,7 @@ unsafe impl AddressSpace for AddressSpaceLayout {
}

fn kernel_module_instance_registry() -> Self::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand Down Expand Up @@ -479,7 +478,7 @@ unsafe impl AddressSpace for AddressSpaceLayout {
}

fn kernel_port_registry() -> Self::SupervisorSegment {
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
static DESCRIPTOR: Segment = unsafe {
Segment {
valid_range: (
Expand Down
21 changes: 10 additions & 11 deletions oro-arch-aarch64/src/mem/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub enum PageTableEntryTypeMut<'a> {
#[repr(C, align(8))]
pub struct PageTableEntry(u64);

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
const _: () = assert::size_of::<PageTableEntry, 8>();

macro_rules! impl_page_table_entry_type {
Expand Down Expand Up @@ -272,7 +272,7 @@ macro_rules! impl_page_table_entry_type {

impl PageTableEntry {
/// Creates a new page table entry.
#[allow(clippy::new_without_default)]
#[expect(clippy::new_without_default)]
#[inline(always)]
#[must_use]
pub const fn new() -> Self {
Expand Down Expand Up @@ -439,7 +439,7 @@ macro_rules! descriptor_init_value {
// FIXME(qix-): with the #[doc = ...] attribute on the subtype's
// FIXME(qix-): ::new() function, the doc comment keeps getting
// FIXME(qix-): indented whenever rustfmt runs.
#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
macro_rules! descriptor_doc {
($doc:literal) => {
concat!(
Expand Down Expand Up @@ -509,9 +509,9 @@ macro_rules! define_descriptor {
}

// TODO(qix-) Add docs. Silencing for now as it's inflating compile times.
#[allow(missing_docs)]
#[expect(missing_docs)]
impl $name {
#[allow(clippy::new_without_default)]
#[expect(clippy::new_without_default)]
#[doc = descriptor_doc!($doc)]
#[inline(always)]
#[must_use]
Expand Down Expand Up @@ -623,7 +623,7 @@ impl PageTableEntry {
}
}

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
macro_rules! impl_page_table_entry_valid_attr {
($($name:ty),*) => {
$(impl $name {
Expand Down Expand Up @@ -675,7 +675,7 @@ impl_page_table_entry_valid_attr!(
L3PageTableBlockDescriptor
);

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
macro_rules! impl_page_table_entry_table_descriptor_attr {
($($name:ty),*) => {
$(impl $name {
Expand Down Expand Up @@ -720,7 +720,7 @@ impl_page_table_entry_table_descriptor_attr!(
L2PageTableDescriptor
);

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
macro_rules! impl_page_table_entry_block_descriptor_attr {
($($name:ty),*) => {
$(impl $name {
Expand Down Expand Up @@ -966,7 +966,7 @@ impl_page_table_entry_block_descriptor_attr!(
L3PageTableBlockDescriptor
);

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
macro_rules! impl_page_table_entry_address {
($($name:ty),*) => {
$(impl $name {
Expand Down Expand Up @@ -1021,7 +1021,7 @@ impl_page_table_entry_address!(
L3PageTableBlockDescriptor
);

#[allow(clippy::missing_docs_in_private_items)]
#[expect(clippy::missing_docs_in_private_items)]
macro_rules! impl_page_table_entry_no_exec_attr {
(user_offset = $user_off:literal, kernel_offset = $kernel_off:literal, $($name:ty),*) => {
$(impl $name {
Expand Down Expand Up @@ -1179,7 +1179,6 @@ impl Default for PageTableEntryTableAccessPerm {
/// <https://developer.arm.com/documentation/den0024/a/Memory-Ordering/Memory-attributes/Cacheable-and-shareable-memory-attributes>
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u64)]
#[allow(unused)]
pub enum PageTableEntryShareability {
/// Non-shareable
None = 0b00 << 8,
Expand Down
4 changes: 2 additions & 2 deletions oro-arch-aarch64/src/mem/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ unsafe impl AddressSegment<AddressSpaceHandle> for &'static Segment {
// SAFETY(qix-): We know that the value is a 48-bit virtual address and we're
// SAFETY(qix-): munging the sign on purpose here.
// TODO(qix-): Once attributes on expressions is stabilized, move this to the macro instead of here.
#[allow(clippy::cast_sign_loss, clippy::cast_possible_wrap)]
#[expect(clippy::cast_sign_loss, clippy::cast_possible_wrap)]
fn range(&self) -> (usize, usize) {
let start = sign_extend!(self.valid_range.0 << 39);
// TODO(qix-): Assumes a 48-bit virtual address space for each TT; will need
Expand Down Expand Up @@ -350,7 +350,7 @@ unsafe impl AddressSegment<AddressSpaceHandle> for &'static Segment {

// SAFETY(qix-): We can guarantee this is an aligned virtual address
// SAFETY(qix-): given that `self.entry()` would have errored with a non-aligned error.
#[allow(clippy::verbose_bit_mask)]
#[expect(clippy::verbose_bit_mask)]
unsafe {
// Sanity check the pre-condition that it's aligned.
debug_assert!(virt & 0xFFF == 0);
Expand Down
4 changes: 2 additions & 2 deletions oro-arch-aarch64/src/psci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Error {
/// Checks the given code and returns an `Err` if it matches
/// one of the error codes.
fn check32<T: From<u32>>(e: u32) -> Result<T> {
#[allow(clippy::cast_possible_wrap)]
#[expect(clippy::cast_possible_wrap)]
let i = e as i32;
if i < 0 && i > -10 {
Err(unsafe { core::mem::transmute::<i64, Error>(i.into()) })
Expand All @@ -43,7 +43,7 @@ impl Error {
/// Checks the given code and returns an `Err` if it matches
/// one of the error codes.
fn check64<T: From<u64>>(e: u64) -> Result<T> {
#[allow(clippy::cast_possible_wrap)]
#[expect(clippy::cast_possible_wrap)]
let i = e as i64;
if i < 0 && i > -10 {
Err(unsafe { core::mem::transmute::<i64, Error>(i) })
Expand Down
5 changes: 2 additions & 3 deletions oro-arch-aarch64/src/reg/mair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl MairRegister {
pub unsafe fn get(self, index: usize) -> MairAttributes {
debug_assert!(index < 8, "index must be 0..=7");
let shift = index * 8;
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
MairAttributes((self.0 >> shift) as u8)
}

Expand Down Expand Up @@ -123,7 +123,7 @@ impl fmt::Debug for MairRegister {

// NOTE(qix-): I don't really want to encourage anyone convert back from a raw u64
// NOTE(qix-): to a `MairRegister` value as that's probably not very safe.
#[allow(clippy::from_over_into)]
#[expect(clippy::from_over_into)]
impl Into<u64> for MairRegister {
#[inline(always)]
fn into(self) -> u64 {
Expand Down Expand Up @@ -231,7 +231,6 @@ impl fmt::Debug for AttributesType {
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
#[non_exhaustive]
#[allow(clippy::upper_case_acronyms)]
pub enum MairDeviceAttribute {
/// Device non-Gathering, non-Reordering, No Early write acknowledgement.
DnGnRnE = 0b0000,
Expand Down
4 changes: 2 additions & 2 deletions oro-arch-aarch64/src/reg/sctlr_el1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl SctlrEl1 {
out(reg) sctlr_el1
);
// SAFETY(qix-): SCTLR_EL1 is a 32-bit register. Truncating the bits makes no difference.
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
Self(sctlr_el1 as u32)
}
}
Expand All @@ -168,7 +168,7 @@ impl SctlrEl1 {
}

/// Creates a new `SCTLR_EL1` register with all fields set to `0`.
#[allow(clippy::new_without_default)]
#[expect(clippy::new_without_default)]
#[must_use]
pub const fn new() -> Self {
Self(0)
Expand Down
Loading

0 comments on commit 4fdfb5e

Please sign in to comment.