Skip to content

Commit de9b3ec

Browse files
committed
Bump Rust version to nightly-2025-02-18(2024 Edition)
1 parent 37b2d53 commit de9b3ec

File tree

18 files changed

+41
-37
lines changed

18 files changed

+41
-37
lines changed

.github/workflows/doc-and-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: [push]
44

55
env:
66
CARGO_TERM_COLOR: always
7-
rust_toolchain: nightly-2024-01-18
7+
rust_toolchain: nightly-2025-02-18
88

99
jobs:
1010
build-doc:

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/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::fs::{read_dir, File};
1+
use std::fs::{File, read_dir};
22
use std::io::{Result, Write};
33

44
fn main() {

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-
error!("[kernel] Panicked: {}", info.message().unwrap());
17+
error!("[kernel] Panicked: {}", info.message());
1818
}
1919
shutdown(true)
2020
}

os/src/loader.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ fn get_base_i(app_id: usize) -> usize {
5555

5656
/// Get the total number of applications.
5757
pub fn get_num_app() -> usize {
58-
extern "C" {
59-
fn _num_app();
58+
unsafe extern "C" {
59+
safe fn _num_app();
6060
}
6161
unsafe { (_num_app as usize as *const usize).read_volatile() }
6262
}
6363

6464
/// Load nth user app at
6565
/// [APP_BASE_ADDRESS + n * APP_SIZE_LIMIT, APP_BASE_ADDRESS + (n+1) * APP_SIZE_LIMIT).
6666
pub fn load_apps() {
67-
extern "C" {
68-
fn _num_app();
67+
unsafe extern "C" {
68+
safe fn _num_app();
6969
}
7070
let num_app_ptr = _num_app as usize as *const usize;
7171
let num_app = get_num_app();

os/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![deny(warnings)]
2020
#![no_std]
2121
#![no_main]
22-
#![feature(panic_info_message)]
2322

2423
use core::arch::global_asm;
2524
use log::*;
@@ -40,9 +39,9 @@ global_asm!(include_str!("link_app.S"));
4039

4140
/// clear BSS segment
4241
fn clear_bss() {
43-
extern "C" {
44-
fn sbss();
45-
fn ebss();
42+
unsafe extern "C" {
43+
safe fn sbss();
44+
safe fn ebss();
4645
}
4746
unsafe {
4847
core::slice::from_raw_parts_mut(sbss as usize as *mut u8, ebss as usize - sbss as usize)
@@ -51,7 +50,7 @@ fn clear_bss() {
5150
}
5251

5352
/// the rust entry-point of os
54-
#[no_mangle]
53+
#[unsafe(no_mangle)]
5554
pub fn rust_main() -> ! {
5655
clear_bss();
5756
logging::init();

os/src/sbi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn console_getchar() -> usize {
1515

1616
/// use sbi call to shutdown the kernel
1717
pub fn shutdown(failure: bool) -> ! {
18-
use sbi_rt::{system_reset, NoReason, Shutdown, SystemFailure};
18+
use sbi_rt::{NoReason, Shutdown, SystemFailure, system_reset};
1919
if !failure {
2020
system_reset(Shutdown, NoReason);
2121
} else {

os/src/task/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ impl TaskContext {
2424

2525
/// set task context {__restore ASM funciton, kernel stack, s_0..12 }
2626
pub fn goto_restore(kstack_ptr: usize) -> Self {
27-
extern "C" {
28-
fn __restore();
27+
unsafe extern "C" {
28+
unsafe fn __restore();
2929
}
3030
Self {
3131
ra: __restore as usize,

os/src/task/switch.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ use core::arch::global_asm;
1010

1111
global_asm!(include_str!("switch.S"));
1212

13-
extern "C" {
13+
unsafe extern "C" {
1414
/// Switch to the context of `next_task_cx_ptr`, saving the current context
1515
/// in `current_task_cx_ptr`.
16-
pub fn __switch(current_task_cx_ptr: *mut TaskContext, next_task_cx_ptr: *const TaskContext);
16+
pub unsafe fn __switch(
17+
current_task_cx_ptr: *mut TaskContext,
18+
next_task_cx_ptr: *const TaskContext,
19+
);
1720
}

os/src/trap/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use riscv::register::sstatus::{self, Sstatus, SPP};
1+
use riscv::register::sstatus::{self, SPP, Sstatus};
22
/// Trap Context
33
#[repr(C)]
44
pub struct TrapContext {

0 commit comments

Comments
 (0)