Skip to content

Commit 419a576

Browse files
committed
Bump Rust version to nightly-2025-02-18(2024 Edition)
1 parent 0713384 commit 419a576

File tree

19 files changed

+42
-38
lines changed

19 files changed

+42
-38
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::*;
@@ -45,9 +44,9 @@ global_asm!(include_str!("link_app.S"));
4544

4645
/// clear BSS segment
4746
fn clear_bss() {
48-
extern "C" {
49-
fn sbss();
50-
fn ebss();
47+
unsafe extern "C" {
48+
safe fn sbss();
49+
safe fn ebss();
5150
}
5251
unsafe {
5352
core::slice::from_raw_parts_mut(sbss as usize as *mut u8, ebss as usize - sbss as usize)
@@ -56,7 +55,7 @@ fn clear_bss() {
5655
}
5756

5857
/// the rust entry-point of os
59-
#[no_mangle]
58+
#[unsafe(no_mangle)]
6059
pub fn rust_main() -> ! {
6160
clear_bss();
6261
logging::init();

os/src/sbi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn set_timer(timer: usize) {
1313

1414
/// use sbi call to shutdown the kernel
1515
pub fn shutdown(failure: bool) -> ! {
16-
use sbi_rt::{system_reset, NoReason, Shutdown, SystemFailure};
16+
use sbi_rt::{NoReason, Shutdown, SystemFailure, system_reset};
1717
if !failure {
1818
system_reset(Shutdown, NoReason);
1919
} 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)