Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 23 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion kernel/comps/block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#![deny(unsafe_code)]
#![feature(fn_traits)]
#![feature(step_trait)]
#![feature(trait_upcasting)]

extern crate alloc;

Expand Down
4 changes: 2 additions & 2 deletions kernel/comps/logger/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ macro_rules! print {
}};
}

/// Copied from Rust std: <https://github.com/rust-lang/rust/blob/master/library/std/src/macros.rs>
/// 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)*)));
}};
}

Expand Down
1 change: 0 additions & 1 deletion kernel/comps/logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions kernel/comps/mlsdisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion kernel/comps/raid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion kernel/comps/time/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MPL-2.0

//! The system time of Asterinas.
#![feature(let_chains)]
#![no_std]
#![deny(unsafe_code)]

Expand Down
1 change: 0 additions & 1 deletion kernel/libs/aster-bigtcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#![no_std]
#![deny(unsafe_code)]
#![feature(extract_if)]

pub mod boolean_value;
pub mod device;
Expand Down
1 change: 0 additions & 1 deletion kernel/libs/atomic-integer-wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
//! ```
//!

#![feature(let_chains)]
#![feature(proc_macro_diagnostic)]

use proc_macro::TokenStream;
Expand Down
2 changes: 1 addition & 1 deletion kernel/libs/comp-sys/cargo-component/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 4 additions & 1 deletion kernel/src/fs/exfat/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/fs/ext2/block_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this syntax do?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.. is the unbounded range, so this call operates over the entire collection. I don't know why extract_if would take a range, while other functions don't. drain also takes one. I'm not sure why.

.map(|(_, inode)| inode)
.collect();

Expand Down
6 changes: 0 additions & 6 deletions kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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)]
Expand Down
6 changes: 5 additions & 1 deletion kernel/src/process/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions osdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion osdk/src/commands/new/rust-toolchain.toml.template
Original file line number Diff line number Diff line change
@@ -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"]
1 change: 1 addition & 0 deletions osdk/src/config/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down
2 changes: 1 addition & 1 deletion ostd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 1 addition & 3 deletions ostd/libs/linux-bzimage/setup/src/loader.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
}
2 changes: 0 additions & 2 deletions ostd/libs/linux-bzimage/setup/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ostd/libs/linux-bzimage/setup/src/x86/amd64_efi/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<BootParams>());
MaybeUninit::fill(bytes, 0);
bytes.write_filled(0);
// SAFETY: Zero initialization gives a valid representation for `BootParams`.
unsafe { &mut *bytes.as_mut_ptr().cast::<BootParams>() }
};
Expand Down
6 changes: 6 additions & 0 deletions ostd/libs/orpc-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions ostd/src/arch/x86/iommu/interrupt_remapping/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pub enum SourceIdQualifier {
IgnoreLeastThree = 0b11,
}

#[expect(dead_code)]
#[derive(Debug, TryFromInt)]
#[repr(u32)]
enum DeliveryMode {
Expand Down
2 changes: 1 addition & 1 deletion ostd/src/arch/x86/kernel/apic/x2apic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion ostd/src/arch/x86/kernel/apic/xapic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
8 changes: 4 additions & 4 deletions ostd/src/arch/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,27 @@ pub fn read_random() -> Option<u64> {
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
}

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
}
Expand Down
2 changes: 1 addition & 1 deletion ostd/src/assertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
3 changes: 2 additions & 1 deletion ostd/src/cpu/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -181,7 +182,7 @@ impl<T: 'static, S: AnyStorage<T>> !Clone for CpuLocal<T, S> {}

// 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<T: 'static> !Send for CpuLocal<T, StaticStorage<T>> {}
assert_not_impl_any!(CpuLocal<usize, StaticStorage<usize>>: Send);

/// The static CPU-local areas for APs.
static CPU_LOCAL_STORAGES: Once<&'static [Paddr]> = Once::new();
Expand Down
6 changes: 0 additions & 6 deletions ostd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Loading
Loading