Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
15 changes: 9 additions & 6 deletions kernel/comps/logger/src/aster_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ fn print_logs(record: &Record, timestamp: f64) {
log::Level::Trace => Style::new().bright_black(),
};

super::_print(format_args!(
"{} {:<5}: {}\n",
timestamp_style.style(format_args!("[{:>10.3}]", timestamp)),
level_style.style(record.level()),
record_style.style(record.args())
));
super::_print(
format_args!(
"{} {:<5}: {}\n",
timestamp_style.style(format_args!("[{:>10.3}]", timestamp)),
level_style.style(record.level()),
record_style.style(record.args())
),
false,
);
}

#[cfg(not(feature = "log_color"))]
Expand Down
12 changes: 8 additions & 4 deletions kernel/comps/logger/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use aster_console::AnyConsoleDevice;
use ostd::sync::{LocalIrqDisabled, SpinLockGuard};

/// Prints the formatted arguments to the standard output.
pub fn _print(args: fmt::Arguments) {
pub fn _print(args: fmt::Arguments, append_nl: bool) {
// We must call `all_devices_lock` instead of `all_devices` here, as `all_devices` invokes the
// `clone` method of `String` and `Arc`, which may lead to a deadlock when there is low memory
// in the heap. (The heap allocator will log a message when memory is low.)
Expand All @@ -31,7 +31,11 @@ pub fn _print(args: fmt::Arguments) {
}
}

Printer(devices).write_fmt(args).unwrap();
let mut printer = Printer(devices);
printer.write_fmt(args).unwrap();
if append_nl {
printer.write_char('\n').unwrap();
}
} else {
// Fall-back to early_print if we have no console setup.
ostd::console::early_print(args);
Expand All @@ -42,7 +46,7 @@ pub fn _print(args: fmt::Arguments) {
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {{
$crate::_print(format_args!($($arg)*));
$crate::_print(format_args!($($arg)*), false);
}};
}

Expand All @@ -53,7 +57,7 @@ macro_rules! println {
$crate::print!("\n")
};
($($arg:tt)*) => {{
$crate::_print(format_args_nl!($($arg)*));
$crate::_print(format_args!($($arg)*), true);

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.

Is the comment above about this being copied from rust's stdlib still true?

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.

I don't know why you can no-longer access format_args_nl, but you can't. However based on rust-lang/rust#111060 (comment), format_args!("{}\n", format_args!($($arg)*)) has no overhead, so I'm using that instead.

}};
}

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
5 changes: 0 additions & 5 deletions kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@
#![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 +20,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
Loading
Loading