mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-24 10:26:25 +04:00
style: Formatting codes with clippy and fmt
Remove unnecessary trailing semicolon Exec cargo fmt
This commit is contained in:
parent
e10ed7a6be
commit
69c5c8fb36
@ -1,5 +1,5 @@
|
|||||||
use core::fmt::{self, Write};
|
|
||||||
use crate::sbi::console_putchar;
|
use crate::sbi::console_putchar;
|
||||||
|
use core::fmt::{self, Write};
|
||||||
|
|
||||||
struct Stdout;
|
struct Stdout;
|
||||||
|
|
||||||
@ -29,5 +29,3 @@ macro_rules! println {
|
|||||||
$crate::console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
|
$crate::console::print(format_args!(concat!($fmt, "\n") $(, $($arg)+)?));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
use core::panic::PanicInfo;
|
|
||||||
use crate::sbi::shutdown;
|
use crate::sbi::shutdown;
|
||||||
|
use core::panic::PanicInfo;
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(info: &PanicInfo) -> ! {
|
fn panic(info: &PanicInfo) -> ! {
|
||||||
if let Some(location) = info.location() {
|
if let Some(location) = info.location() {
|
||||||
println!("Panicked at {}:{} {}", location.file(), location.line(), info.message().unwrap());
|
println!(
|
||||||
|
"Panicked at {}:{} {}",
|
||||||
|
location.file(),
|
||||||
|
location.line(),
|
||||||
|
info.message().unwrap()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
println!("Panicked: {}", info.message().unwrap());
|
println!("Panicked: {}", info.message().unwrap());
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ mod console;
|
|||||||
mod lang_items;
|
mod lang_items;
|
||||||
mod sbi;
|
mod sbi;
|
||||||
|
|
||||||
|
|
||||||
global_asm!(include_str!("entry.asm"));
|
global_asm!(include_str!("entry.asm"));
|
||||||
|
|
||||||
fn clear_bss() {
|
fn clear_bss() {
|
||||||
@ -17,9 +16,7 @@ fn clear_bss() {
|
|||||||
fn sbss();
|
fn sbss();
|
||||||
fn ebss();
|
fn ebss();
|
||||||
}
|
}
|
||||||
(sbss as usize..ebss as usize).for_each(|a| {
|
(sbss as usize..ebss as usize).for_each(|a| unsafe { (a as *mut u8).write_volatile(0) });
|
||||||
unsafe { (a as *mut u8).write_volatile(0) }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
@ -35,13 +32,16 @@ pub fn rust_main() -> ! {
|
|||||||
fn ebss();
|
fn ebss();
|
||||||
fn boot_stack();
|
fn boot_stack();
|
||||||
fn boot_stack_top();
|
fn boot_stack_top();
|
||||||
};
|
}
|
||||||
clear_bss();
|
clear_bss();
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
println!(".text [{:#x}, {:#x})", stext as usize, etext as usize);
|
println!(".text [{:#x}, {:#x})", stext as usize, etext as usize);
|
||||||
println!(".rodata [{:#x}, {:#x})", srodata as usize, erodata as usize);
|
println!(".rodata [{:#x}, {:#x})", srodata as usize, erodata as usize);
|
||||||
println!(".data [{:#x}, {:#x})", sdata as usize, edata as usize);
|
println!(".data [{:#x}, {:#x})", sdata as usize, edata as usize);
|
||||||
println!("boot_stack [{:#x}, {:#x})", boot_stack as usize, boot_stack_top as usize);
|
println!(
|
||||||
|
"boot_stack [{:#x}, {:#x})",
|
||||||
|
boot_stack as usize, boot_stack_top as usize
|
||||||
|
);
|
||||||
println!(".bss [{:#x}, {:#x})", sbss as usize, ebss as usize);
|
println!(".bss [{:#x}, {:#x})", sbss as usize, ebss as usize);
|
||||||
panic!("Shutdown machine!");
|
panic!("Shutdown machine!");
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,3 @@ pub fn shutdown() -> ! {
|
|||||||
sbi_call(SBI_SHUTDOWN, 0, 0, 0);
|
sbi_call(SBI_SHUTDOWN, 0, 0, 0);
|
||||||
panic!("It should shutdown!");
|
panic!("It should shutdown!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user