diff --git a/Cargo.lock b/Cargo.lock index 6e139eb9a..a3b8e1406 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -808,9 +808,9 @@ checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "gimli" -version = "0.31.1" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" [[package]] name = "half" @@ -1930,11 +1930,11 @@ dependencies = [ [[package]] name = "unwinding" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c" +checksum = "60612c845ef41699f39dc8c5391f252942c0a88b7d15da672eff0d14101bbd6d" dependencies = [ - "gimli 0.31.1", + "gimli 0.32.3", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b55ab09b6..78f872160 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,12 +50,34 @@ exclude = [ ] [workspace.lints.rust] -unsafe_op_in_unsafe_fn = "deny" +function_casts_as_integer = "allow" +mismatched_lifetime_syntaxes = "allow" missing_crate_level_docs = "warn" unexpected_cfgs = { level = "deny", check-cfg = ['cfg(baseline_asterinas)', 'cfg(ktest)'] } +unpredictable-function-pointer-comparisons = "allow" +unsafe_op_in_unsafe_fn = "deny" +unused_parens = "allow" [workspace.lints.clippy] allow_attributes = "warn" +collapsible_match = "allow" +collapsible-if = "allow" +derivable_impls = "allow" +explicit_counter_loop = "allow" +filter_next = "allow" +implicit_saturating_sub = "allow" +iter_kv_map = "allow" +let_and_return = "allow" +manual_is_multiple_of = "allow" +manual_saturating_arithmetic = "allow" +mem-replace-option-with-some = "allow" +question_mark = "allow" +unnecessary_cast = "allow" +unnecessary_option_map_or_else = "allow" +unnecessary_sort_by = "allow" +unnecessary_unwrap = "allow" +while_let_loop = "allow" + # TODO(arthurp, #48): Enable once the code can pass it. # undocumented_unsafe_blocks = "deny" # TODO(arthurp, #49): Enable once the code can pass it. diff --git a/kernel/comps/block/src/lib.rs b/kernel/comps/block/src/lib.rs index 8151b4e69..145a8ffcd 100644 --- a/kernel/comps/block/src/lib.rs +++ b/kernel/comps/block/src/lib.rs @@ -30,7 +30,6 @@ #![deny(unsafe_code)] #![feature(fn_traits)] #![feature(step_trait)] -#![feature(trait_upcasting)] extern crate alloc; diff --git a/kernel/comps/logger/src/console.rs b/kernel/comps/logger/src/console.rs index 7384d1a3a..92ffb7160 100644 --- a/kernel/comps/logger/src/console.rs +++ b/kernel/comps/logger/src/console.rs @@ -46,14 +46,14 @@ macro_rules! print { }}; } -/// Copied from Rust std: +/// The same as [`print!`], but adds a trailing new-line. #[macro_export] macro_rules! println { () => { $crate::print!("\n") }; ($($arg:tt)*) => {{ - $crate::_print(format_args_nl!($($arg)*)); + $crate::_print(format_args!("{}\n", format_args!($($arg)*))); }}; } diff --git a/kernel/comps/logger/src/lib.rs b/kernel/comps/logger/src/lib.rs index cf51b3a3c..79b77c9c9 100644 --- a/kernel/comps/logger/src/lib.rs +++ b/kernel/comps/logger/src/lib.rs @@ -12,7 +12,6 @@ //! //! IRQs are disabled while printing. So do not print long log messages. #![no_std] -#![feature(format_args_nl)] #![deny(unsafe_code)] extern crate alloc; diff --git a/kernel/comps/mlsdisk/src/lib.rs b/kernel/comps/mlsdisk/src/lib.rs index d78177204..333d8a360 100644 --- a/kernel/comps/mlsdisk/src/lib.rs +++ b/kernel/comps/mlsdisk/src/lib.rs @@ -2,9 +2,7 @@ #![no_std] #![deny(unsafe_code)] -#![feature(let_chains)] #![feature(negative_impls)] -#![feature(slice_as_chunks)] #![expect(dead_code, unused_imports)] mod error; diff --git a/kernel/comps/raid/src/lib.rs b/kernel/comps/raid/src/lib.rs index ac5f2ef39..57f4d7d34 100644 --- a/kernel/comps/raid/src/lib.rs +++ b/kernel/comps/raid/src/lib.rs @@ -17,7 +17,6 @@ #![no_std] // BlockDevice crate also not using rust std and not using unsafe code. #![deny(unsafe_code)] -#![feature(trait_upcasting)] extern crate alloc; diff --git a/kernel/comps/time/src/lib.rs b/kernel/comps/time/src/lib.rs index e61387a32..6f27ea507 100644 --- a/kernel/comps/time/src/lib.rs +++ b/kernel/comps/time/src/lib.rs @@ -1,7 +1,6 @@ // SPDX-License-Identifier: MPL-2.0 //! The system time of Asterinas. -#![feature(let_chains)] #![no_std] #![deny(unsafe_code)] diff --git a/kernel/libs/aster-bigtcp/src/lib.rs b/kernel/libs/aster-bigtcp/src/lib.rs index a0aadb7d0..a20132563 100644 --- a/kernel/libs/aster-bigtcp/src/lib.rs +++ b/kernel/libs/aster-bigtcp/src/lib.rs @@ -12,7 +12,6 @@ #![no_std] #![deny(unsafe_code)] -#![feature(extract_if)] pub mod boolean_value; pub mod device; diff --git a/kernel/libs/atomic-integer-wrapper/src/lib.rs b/kernel/libs/atomic-integer-wrapper/src/lib.rs index 80ef4b6ac..19c432a0a 100644 --- a/kernel/libs/atomic-integer-wrapper/src/lib.rs +++ b/kernel/libs/atomic-integer-wrapper/src/lib.rs @@ -45,7 +45,6 @@ //! ``` //! -#![feature(let_chains)] #![feature(proc_macro_diagnostic)] use proc_macro::TokenStream; diff --git a/kernel/libs/comp-sys/cargo-component/rust-toolchain.toml b/kernel/libs/comp-sys/cargo-component/rust-toolchain.toml index 19d918006..e06a8ae7a 100644 --- a/kernel/libs/comp-sys/cargo-component/rust-toolchain.toml +++ b/kernel/libs/comp-sys/cargo-component/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-02-05" +channel = "nightly-2026-03-01" components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] diff --git a/kernel/src/fs/exfat/inode.rs b/kernel/src/fs/exfat/inode.rs index 6f7182ba9..2c29132e5 100644 --- a/kernel/src/fs/exfat/inode.rs +++ b/kernel/src/fs/exfat/inode.rs @@ -1384,7 +1384,10 @@ impl Inode for ExfatInode { .block_device() .read_blocks(physical_bid, bio_segment.clone())?; bio_segment.reader().unwrap().read_fallible(writer)?; - buf_offset += BLOCK_SIZE; + #[expect(unused_assignments)] + { + buf_offset += BLOCK_SIZE; + } cur_offset += BLOCK_SIZE; if cur_offset >= cluster_size { diff --git a/kernel/src/fs/ext2/block_group.rs b/kernel/src/fs/ext2/block_group.rs index 3303178aa..050f9b7b5 100644 --- a/kernel/src/fs/ext2/block_group.rs +++ b/kernel/src/fs/ext2/block_group.rs @@ -277,7 +277,7 @@ impl BlockGroup { .inner .write() .inode_cache - .extract_if(|_, inode| Arc::strong_count(inode) == 1) + .extract_if(.., |_, inode| Arc::strong_count(inode) == 1) .map(|(_, inode)| inode) .collect(); diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 8c5247c7c..3e2823008 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -7,15 +7,10 @@ #![no_main] #![deny(unsafe_code)] #![feature(btree_cursors)] -#![feature(btree_extract_if)] #![feature(debug_closure_helpers)] #![feature(extend_one)] -#![feature(extract_if)] #![feature(fn_traits)] -#![feature(format_args_nl)] #![feature(int_roundings)] -#![feature(integer_sign_cast)] -#![feature(let_chains)] #![feature(linked_list_cursors)] #![feature(linked_list_remove)] #![feature(linked_list_retain)] @@ -24,7 +19,6 @@ #![feature(register_tool)] #![feature(step_trait)] #![feature(trait_alias)] -#![feature(trait_upcasting)] #![feature(associated_type_defaults)] #![feature(closure_track_caller)] #![register_tool(component_access_control)] diff --git a/kernel/src/process/exit.rs b/kernel/src/process/exit.rs index 28a8368c6..108f588cb 100644 --- a/kernel/src/process/exit.rs +++ b/kernel/src/process/exit.rs @@ -88,7 +88,11 @@ fn move_process_children( return Err(()); } - for (_, child_process) in current_process.children().lock().extract_if(|_, _| true) { + for (_, child_process) in current_process + .children() + .lock() + .extract_if(.., |_, _| true) + { let mut parent = child_process.parent.lock(); reaper_process_children.insert(child_process.pid(), child_process.clone()); parent.set_process(reaper_process); diff --git a/osdk/Cargo.toml b/osdk/Cargo.toml index 982b8d536..93bdb6744 100644 --- a/osdk/Cargo.toml +++ b/osdk/Cargo.toml @@ -9,6 +9,11 @@ repository = "https://github.com/ldos-project/asterinas" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints.clippy] +collapsible_match = "allow" +collapsible_if = "allow" +unnecessary_unwrap = "allow" + [dependencies] linux-bzimage-builder = { version = "0.15.2", path = "../ostd/libs/linux-bzimage/builder" } clap = { version = "4.4.17", features = ["cargo", "derive"] } diff --git a/osdk/src/commands/new/rust-toolchain.toml.template b/osdk/src/commands/new/rust-toolchain.toml.template index 82e5c6648..9353f6b12 100644 --- a/osdk/src/commands/new/rust-toolchain.toml.template +++ b/osdk/src/commands/new/rust-toolchain.toml.template @@ -1,5 +1,5 @@ # One should also update asterinas/rust-toolchain.toml when updating this. # The first two lines will be deleted when generating the user's toolchain file. [toolchain] -channel = "nightly-2025-02-01" +channel = "nightly-2026-03-01" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] diff --git a/osdk/src/config/manifest.rs b/osdk/src/config/manifest.rs index 5430baa1c..f6378810a 100644 --- a/osdk/src/config/manifest.rs +++ b/osdk/src/config/manifest.rs @@ -14,6 +14,7 @@ use super::scheme::Scheme; use crate::{error::Errno, error_msg, util::get_cargo_metadata}; +#[expect(dead_code)] #[derive(Debug, Clone, Serialize, Deserialize)] pub struct OsdkMeta { #[serde(rename(serialize = "type", deserialize = "type"))] diff --git a/ostd/Cargo.toml b/ostd/Cargo.toml index 51b776065..61476eed9 100644 --- a/ostd/Cargo.toml +++ b/ostd/Cargo.toml @@ -37,7 +37,7 @@ spin = "0.9.4" slotmap = { version = "1.0", default-features = false } smallvec = { version = "1.15.1", features = ["union"] } snafu = { workspace = true } -unwinding = { version = "=0.2.5", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] } +unwinding = { version = "0.2.8", default-features = false, features = ["fde-gnu-eh-frame-hdr", "hide-trace", "panic", "personality", "unwinder"] } volatile = "0.6.1" bitvec = { version = "1.0", default-features = false, features = ["alloc"] } crossbeam-utils = { version = "0.8.21", default-features = false } diff --git a/ostd/libs/linux-bzimage/setup/src/loader.rs b/ostd/libs/linux-bzimage/setup/src/loader.rs index 6bae77297..abb338e55 100644 --- a/ostd/libs/linux-bzimage/setup/src/loader.rs +++ b/ostd/libs/linux-bzimage/setup/src/loader.rs @@ -1,7 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -use core::mem::MaybeUninit; - use xmas_elf::program::{ProgramHeader, SegmentData}; /// Load the kernel ELF payload to memory. @@ -37,5 +35,5 @@ fn load_segment(file: &xmas_elf::ElfFile, program: &xmas_elf::program::ProgramHe let (left, right) = dst_slice.split_at_mut(program.file_size as usize); left.write_copy_of_slice(segment_data); - MaybeUninit::fill(right, 0); + right.write_filled(0); } diff --git a/ostd/libs/linux-bzimage/setup/src/main.rs b/ostd/libs/linux-bzimage/setup/src/main.rs index 03c646b14..e1adaed15 100644 --- a/ostd/libs/linux-bzimage/setup/src/main.rs +++ b/ostd/libs/linux-bzimage/setup/src/main.rs @@ -22,8 +22,6 @@ #![no_std] #![no_main] #![feature(maybe_uninit_fill)] -#![feature(maybe_uninit_slice)] -#![feature(maybe_uninit_write_slice)] mod console; mod loader; diff --git a/ostd/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs b/ostd/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs index 156e83a7f..6d26d5f1d 100644 --- a/ostd/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs +++ b/ostd/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs @@ -46,7 +46,7 @@ extern "sysv64" fn main_efi_common64( fn allocate_boot_params() -> &'static mut BootParams { let boot_params = { let bytes = alloc_pages(AllocateType::AnyPages, core::mem::size_of::()); - MaybeUninit::fill(bytes, 0); + bytes.write_filled(0); // SAFETY: Zero initialization gives a valid representation for `BootParams`. unsafe { &mut *bytes.as_mut_ptr().cast::() } }; diff --git a/ostd/libs/orpc-macros/Cargo.toml b/ostd/libs/orpc-macros/Cargo.toml index f361a4ae7..5b67a383c 100644 --- a/ostd/libs/orpc-macros/Cargo.toml +++ b/ostd/libs/orpc-macros/Cargo.toml @@ -6,6 +6,12 @@ edition = "2024" [lib] proc-macro = true +[lints.rust] +mismatched_lifetime_syntaxes = "allow" + +[lints.clippy] +collapsible-if = "allow" + [dependencies] proc-macro2 = "1.0" quote = "1.0" diff --git a/ostd/src/arch/x86/iommu/interrupt_remapping/table.rs b/ostd/src/arch/x86/iommu/interrupt_remapping/table.rs index 1309f8100..fb0e97663 100644 --- a/ostd/src/arch/x86/iommu/interrupt_remapping/table.rs +++ b/ostd/src/arch/x86/iommu/interrupt_remapping/table.rs @@ -147,6 +147,7 @@ pub enum SourceIdQualifier { IgnoreLeastThree = 0b11, } +#[expect(dead_code)] #[derive(Debug, TryFromInt)] #[repr(u32)] enum DeliveryMode { diff --git a/ostd/src/arch/x86/kernel/apic/x2apic.rs b/ostd/src/arch/x86/kernel/apic/x2apic.rs index 7b2430512..b11d120d1 100644 --- a/ostd/src/arch/x86/kernel/apic/x2apic.rs +++ b/ostd/src/arch/x86/kernel/apic/x2apic.rs @@ -28,7 +28,7 @@ impl X2Apic { pub(super) fn has_x2apic() -> bool { // x2apic::X2APIC::new() - let value = unsafe { core::arch::x86_64::__cpuid(1) }; + let value = core::arch::x86_64::__cpuid(1); value.ecx & 0x20_0000 != 0 } diff --git a/ostd/src/arch/x86/kernel/apic/xapic.rs b/ostd/src/arch/x86/kernel/apic/xapic.rs index d0d7d7663..f45dcec97 100644 --- a/ostd/src/arch/x86/kernel/apic/xapic.rs +++ b/ostd/src/arch/x86/kernel/apic/xapic.rs @@ -60,7 +60,7 @@ impl XApic { } pub(super) fn has_xapic() -> bool { - let value = unsafe { core::arch::x86_64::__cpuid(1) }; + let value = core::arch::x86_64::__cpuid(1); value.edx & 0x100 != 0 } } diff --git a/ostd/src/arch/x86/mod.rs b/ostd/src/arch/x86/mod.rs index 217479085..0d6b58650 100644 --- a/ostd/src/arch/x86/mod.rs +++ b/ostd/src/arch/x86/mod.rs @@ -145,13 +145,13 @@ pub fn read_random() -> Option { fn has_avx() -> bool { use core::arch::x86_64::{__cpuid, __cpuid_count}; - let cpuid_result = unsafe { __cpuid(0) }; + let cpuid_result = __cpuid(0); if cpuid_result.eax < 1 { // CPUID function 1 is not supported return false; } - let cpuid_result = unsafe { __cpuid_count(1, 0) }; + let cpuid_result = __cpuid_count(1, 0); // Check for AVX (bit 28 of ecx) cpuid_result.ecx & (1 << 28) != 0 } @@ -159,13 +159,13 @@ fn has_avx() -> bool { fn has_avx512() -> bool { use core::arch::x86_64::{__cpuid, __cpuid_count}; - let cpuid_result = unsafe { __cpuid(0) }; + let cpuid_result = __cpuid(0); if cpuid_result.eax < 7 { // CPUID function 7 is not supported return false; } - let cpuid_result = unsafe { __cpuid_count(7, 0) }; + let cpuid_result = __cpuid_count(7, 0); // Check for AVX-512 Foundation (bit 16 of ebx) cpuid_result.ebx & (1 << 16) != 0 } diff --git a/ostd/src/assertion.rs b/ostd/src/assertion.rs index 806e6084c..dbe34fcbf 100644 --- a/ostd/src/assertion.rs +++ b/ostd/src/assertion.rs @@ -4,7 +4,7 @@ #![cfg(ktest)] -use core::{assert_matches::assert_matches, time::Duration}; +use core::{assert_matches, time::Duration}; use crate::{task::Task, timer::Jiffies}; diff --git a/ostd/src/cpu/local/mod.rs b/ostd/src/cpu/local/mod.rs index 7aca8f2c8..e7611c962 100644 --- a/ostd/src/cpu/local/mod.rs +++ b/ostd/src/cpu/local/mod.rs @@ -51,6 +51,7 @@ pub use cell::CpuLocalCell; pub use dyn_cpu_local::DynCpuLocalChunk; use dyn_cpu_local::DynamicStorage; use spin::Once; +use static_assertions::assert_not_impl_any; use static_cpu_local::StaticStorage; use super::CpuId; @@ -181,7 +182,7 @@ impl> !Clone for CpuLocal {} // In general, it does not make any sense to send instances of static `CpuLocal` // to other tasks as they should live on other CPUs to make sending useful. -impl !Send for CpuLocal> {} +assert_not_impl_any!(CpuLocal>: Send); /// The static CPU-local areas for APs. static CPU_LOCAL_STORAGES: Once<&'static [Paddr]> = Once::new(); diff --git a/ostd/src/lib.rs b/ostd/src/lib.rs index 98e578cba..8cfc75221 100644 --- a/ostd/src/lib.rs +++ b/ostd/src/lib.rs @@ -1,26 +1,20 @@ // SPDX-License-Identifier: MPL-2.0 //! The standard library for Asterinas and other Rust OSes. -#![cfg_attr(ktest, feature(assert_matches))] #![feature(alloc_error_handler)] #![feature(allocator_api)] #![feature(btree_cursors)] -#![feature(const_ptr_sub_ptr)] #![feature(const_trait_impl)] #![feature(core_intrinsics)] #![feature(coroutines)] #![feature(fn_traits)] #![feature(iter_advance_by)] #![feature(iter_from_coroutine)] -#![feature(let_chains)] #![feature(linkage)] #![feature(min_specialization)] #![feature(negative_impls)] #![feature(ptr_metadata)] -#![feature(ptr_sub_ptr)] #![feature(sync_unsafe_cell)] -#![feature(trait_upcasting)] -#![feature(unbounded_shifts)] #![expect(internal_features)] #![no_std] #![warn(missing_docs)] diff --git a/ostd/src/mm/test.rs b/ostd/src/mm/test.rs index 9a841116e..256ee113e 100644 --- a/ostd/src/mm/test.rs +++ b/ostd/src/mm/test.rs @@ -19,7 +19,7 @@ use crate::{ }; mod io { - use core::assert_matches::assert_matches; + use core::assert_matches; use super::*; diff --git a/ostd/src/orpc/framework/integration_test.rs b/ostd/src/orpc/framework/integration_test.rs index 55d9052e0..0df0dd76a 100644 --- a/ostd/src/orpc/framework/integration_test.rs +++ b/ostd/src/orpc/framework/integration_test.rs @@ -5,7 +5,7 @@ #[cfg(ktest)] mod test { use core::{ - assert_matches::assert_matches, + assert_matches, cell::Cell, panic::{RefUnwindSafe, UnwindSafe}, sync::atomic::{AtomicBool, AtomicUsize, Ordering}, diff --git a/ostd/src/orpc/oqueue/mod.rs b/ostd/src/orpc/oqueue/mod.rs index 1cc7d81ae..43b5451dc 100644 --- a/ostd/src/orpc/oqueue/mod.rs +++ b/ostd/src/orpc/oqueue/mod.rs @@ -587,7 +587,7 @@ impl WeakObserver { #[cfg(ktest)] mod test { use alloc::string::String; - use core::assert_matches::assert_matches; + use core::assert_matches; use super::*; use crate::{orpc::oqueue::generic_test, prelude::*}; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index c547ce44f..d385ce1f3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ # One should also update osdk/src/commands/new/rust-toolchain.toml.template # when updating this [toolchain] -channel = "nightly-2025-02-01" +channel = "nightly-2026-03-01" components = ["rust-src", "rustc-dev", "llvm-tools-preview"] targets = ["x86_64-unknown-none"] \ No newline at end of file