Skip to content

Commit c255c0c

Browse files
committed
fix rust fmt to not mangle externs
1 parent 0739b22 commit c255c0c

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

riscv-rt/build.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ fn main() {
1616
let mut target = Target::from_target_str(&target);
1717
target.retain_extensions("imc");
1818

19-
let target = target.to_string();
19+
let target = target.to_string();
2020

2121
fs::copy(
2222
format!("bin/{}.a", target),
2323
out_dir.join(format!("lib{}.a", name)),
24-
).unwrap();
24+
)
25+
.unwrap();
2526

2627
println!("cargo:rustc-link-lib=static={}", name);
2728
println!("cargo:rustc-link-search={}", out_dir.display());

riscv-rt/examples/empty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ use riscv_rt::entry;
99
#[entry]
1010
fn main() -> ! {
1111
// do something here
12-
loop { }
12+
loop {}
1313
}

riscv-rt/examples/multi_core.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ extern crate panic_halt;
55
extern crate riscv;
66
extern crate riscv_rt;
77

8-
use riscv::register::{mie, mip, mhartid};
98
use riscv::asm::wfi;
9+
use riscv::register::{mhartid, mie, mip};
1010
use riscv_rt::entry;
1111

1212
#[export_name = "_mp_hook"]
13+
#[rustfmt::skip]
1314
pub extern "Rust" fn user_mp_hook() -> bool {
1415
let hartid = mhartid::read();
1516
if hartid == 0 {
@@ -52,5 +53,5 @@ fn main() -> ! {
5253
}
5354
}
5455

55-
loop { }
56+
loop {}
5657
}

riscv-rt/src/lib.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,9 @@
330330
#![no_std]
331331
#![deny(missing_docs)]
332332

333+
extern crate r0;
333334
extern crate riscv;
334335
extern crate riscv_rt_macros as macros;
335-
extern crate r0;
336336

337337
pub use macros::{entry, pre_init};
338338

@@ -355,14 +355,14 @@ extern "C" {
355355
static _sidata: u32;
356356
}
357357

358-
359358
/// Rust entry point (_start_rust)
360359
///
361360
/// Zeros bss section, initializes data section and calls main. This function
362361
/// never returns.
363362
#[link_section = ".init.rust"]
364363
#[export_name = "_start_rust"]
365364
pub unsafe extern "C" fn start_rust() -> ! {
365+
#[rustfmt::skip]
366366
extern "Rust" {
367367
// This symbol will be provided by the user via `#[entry]`
368368
fn main() -> !;
@@ -407,7 +407,6 @@ pub struct TrapFrame {
407407
pub a7: usize,
408408
}
409409

410-
411410
/// Trap entry point rust (_start_trap_rust)
412411
///
413412
/// `mcause` is read to determine the cause of the trap. XLEN-1 bit indicates
@@ -501,25 +500,41 @@ pub union Vector {
501500
#[no_mangle]
502501
pub static __INTERRUPTS: [Vector; 12] = [
503502
Vector { handler: UserSoft },
504-
Vector { handler: SupervisorSoft },
503+
Vector {
504+
handler: SupervisorSoft,
505+
},
505506
Vector { reserved: 0 },
506-
Vector { handler: MachineSoft },
507+
Vector {
508+
handler: MachineSoft,
509+
},
507510
Vector { handler: UserTimer },
508-
Vector { handler: SupervisorTimer },
511+
Vector {
512+
handler: SupervisorTimer,
513+
},
509514
Vector { reserved: 0 },
510-
Vector { handler: MachineTimer },
511-
Vector { handler: UserExternal },
512-
Vector { handler: SupervisorExternal },
515+
Vector {
516+
handler: MachineTimer,
517+
},
518+
Vector {
519+
handler: UserExternal,
520+
},
521+
Vector {
522+
handler: SupervisorExternal,
523+
},
513524
Vector { reserved: 0 },
514-
Vector { handler: MachineExternal },
525+
Vector {
526+
handler: MachineExternal,
527+
},
515528
];
516529

517530
#[doc(hidden)]
518531
#[no_mangle]
532+
#[rustfmt::skip]
519533
pub unsafe extern "Rust" fn default_pre_init() {}
520534

521535
#[doc(hidden)]
522536
#[no_mangle]
537+
#[rustfmt::skip]
523538
pub extern "Rust" fn default_mp_hook() -> bool {
524539
use riscv::register::mhartid;
525540
match mhartid::read() {

0 commit comments

Comments
 (0)