Skip to content

Commit 5c46d13

Browse files
committed
[chore] Update to Rust Edition 2024
1 parent b79acad commit 5c46d13

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

os/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "os"
33
version = "0.1.0"
44
authors = ["Yifan Wu <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66

77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

os/src/lang_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ fn panic(info: &PanicInfo) -> ! {
1111
"[kernel] Panicked at {}:{} {}",
1212
location.file(),
1313
location.line(),
14-
info.message().unwrap()
14+
info.message()
1515
);
1616
} else {
17-
println!("[kernel] Panicked: {}", info.message().unwrap());
17+
println!("[kernel] Panicked: {}", info.message());
1818
}
1919
shutdown()
2020
}

os/src/main.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![deny(warnings)]
1212
#![no_std]
1313
#![no_main]
14-
#![feature(panic_info_message)]
1514

1615
use core::arch::global_asm;
1716
use log::*;
@@ -29,35 +28,34 @@ global_asm!(include_str!("entry.asm"));
2928

3029
/// clear BSS segment
3130
pub fn clear_bss() {
32-
extern "C" {
33-
fn sbss();
34-
fn ebss();
31+
unsafe extern "C" {
32+
unsafe fn sbss();
33+
unsafe fn ebss();
3534
}
3635
(sbss as usize..ebss as usize).for_each(|a| unsafe { (a as *mut u8).write_volatile(0) });
3736
}
3837

3938
/// the rust entry-point of os
40-
#[no_mangle]
39+
#[unsafe(no_mangle)]
4140
pub fn rust_main() -> ! {
42-
extern "C" {
43-
fn stext(); // begin addr of text segment
44-
fn etext(); // end addr of text segment
45-
fn srodata(); // start addr of Read-Only data segment
46-
fn erodata(); // end addr of Read-Only data ssegment
47-
fn sdata(); // start addr of data segment
48-
fn edata(); // end addr of data segment
49-
fn sbss(); // start addr of BSS segment
50-
fn ebss(); // end addr of BSS segment
51-
fn boot_stack_lower_bound(); // stack lower bound
52-
fn boot_stack_top(); // stack top
41+
unsafe extern "C" {
42+
unsafe fn stext(); // begin addr of text segment
43+
unsafe fn etext(); // end addr of text segment
44+
unsafe fn srodata(); // start addr of Read-Only data segment
45+
unsafe fn erodata(); // end addr of Read-Only data ssegment
46+
unsafe fn sdata(); // start addr of data segment
47+
unsafe fn edata(); // end addr of data segment
48+
unsafe fn sbss(); // start addr of BSS segment
49+
unsafe fn ebss(); // end addr of BSS segment
50+
unsafe fn boot_stack_lower_bound(); // stack lower bound
51+
unsafe fn boot_stack_top(); // stack top
5352
}
5453
clear_bss();
5554
logging::init();
5655
println!("[kernel] Hello, world!");
5756
trace!(
5857
"[kernel] .text [{:#x}, {:#x})",
59-
stext as usize,
60-
etext as usize
58+
stext as usize, etext as usize
6159
);
6260
debug!(
6361
"[kernel] .rodata [{:#x}, {:#x})",
@@ -75,5 +73,5 @@ pub fn rust_main() -> ! {
7573

7674
use crate::board::QEMUExit;
7775
crate::board::QEMU_EXIT_HANDLE.exit_success(); // CI autotest success
78-
//crate::board::QEMU_EXIT_HANDLE.exit_failure(); // CI autoest failed
76+
//crate::board::QEMU_EXIT_HANDLE.exit_failure(); // CI autoest failed
7977
}

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[toolchain]
22
profile = "minimal"
33
# use the nightly version of the last stable toolchain, see <https://forge.rust-lang.org/>
4-
channel = "nightly-2024-05-02"
4+
channel = "nightly-2025-09-18"
55
components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"]

0 commit comments

Comments
 (0)