style: Formatting codes with clippy and fmt

Remove unnecessary trailing semicolon
Exec cargo fmt
This commit is contained in:
Campbell He 2021-01-17 17:09:28 +08:00
parent e10ed7a6be
commit 69c5c8fb36
4 changed files with 15 additions and 13 deletions

View File

@ -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)+)?));
} }
} }

View File

@ -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());
} }

View File

@ -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!");
} }

View File

@ -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!");
} }