Skip to content

Commit c23774c

Browse files
committed
Switch to 2024 edition
1 parent 18f286a commit c23774c

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

grub_rust_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
authors = ["Vladimir Serbinenko <[email protected]>"]
3-
edition = "2018"
3+
edition = "2024"
44
name = "grub"
55
version = "0.1.0"
66

grub_rust_core/src/lib.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(rustc_attrs)]
55
#![feature(format_args_nl)]
66
#![feature(inherent_str_constructors)]
7+
#![warn(static_mut_refs)]
78

89
extern crate alloc;
910

@@ -22,14 +23,14 @@ use core::ffi::CStr;
2223
use core::panic::PanicInfo;
2324
use core::num::TryFromIntError;
2425

25-
#[link_section = ".modname"]
26-
#[no_mangle]
26+
#[unsafe(link_section = ".modname")]
27+
#[unsafe(no_mangle)]
2728
pub static GRUB_MODNAME: [u8; 5] = *b"rust\0";
28-
#[link_section = ".module_license"]
29-
#[no_mangle]
29+
#[unsafe(link_section = ".module_license")]
30+
#[unsafe(no_mangle)]
3031
pub static GRUB_LICENSE: [u8; 15] = *b"LICENSE=GPLv3+\0";
3132

32-
extern "C" {
33+
unsafe extern "C" {
3334
static grub_xputs: extern "C" fn(stri: *const c_char);
3435
fn grub_abort();
3536
fn grub_malloc(sz: usize) -> *mut u8;
@@ -88,7 +89,7 @@ macro_rules! eformat {
8889
}
8990
}
9091

91-
#[no_mangle]
92+
#[unsafe(no_mangle)]
9293
pub extern "C" fn strlen(s: *const c_char) -> usize {
9394
return unsafe { grub_strlen(s) };
9495
}
@@ -314,11 +315,11 @@ struct GrubAllocator;
314315

315316
unsafe impl GlobalAlloc for GrubAllocator {
316317
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
317-
return grub_malloc(layout.size());
318+
return unsafe { grub_malloc(layout.size()) };
318319
}
319320

320321
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
321-
grub_free(ptr);
322+
unsafe { grub_free(ptr) };
322323
}
323324
}
324325

grub_rust_example/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
authors = ["Vladimir Serbinenko <[email protected]>"]
3-
edition = "2018"
3+
edition = "2024"
44
readme = "README.md"
55
name = "grub-rust-hello"
66
version = "0.1.0"

grub_rust_example/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ use grub::dprintln;
1717
use grub::println;
1818
use grub::eformat;
1919

20-
#[link_section = ".modname"]
21-
#[no_mangle]
20+
#[unsafe(link_section = ".modname")]
21+
#[unsafe(no_mangle)]
2222
pub static GRUB_MODNAME_EXAMPLE: [u8; 11] = *b"rust_hello\0";
23-
#[link_section = ".module_license"]
24-
#[no_mangle]
23+
#[unsafe(link_section = ".module_license")]
24+
#[unsafe(no_mangle)]
2525
pub static GRUB_LICENSE_EXAMPLE: [u8; 15] = *b"LICENSE=GPLv3+\0";
2626

2727

@@ -121,7 +121,7 @@ fn rust_hexdump (args: &[&str]) -> Result<(), grub::GrubError> {
121121
return Ok(());
122122
}
123123

124-
#[no_mangle]
124+
#[unsafe(no_mangle)]
125125
pub extern "C" fn grub_mod_init() {
126126
grub::Command::register("rust_hello", rust_hello,
127127
"Rust hello", "Say hello from Rust.");
@@ -131,7 +131,7 @@ pub extern "C" fn grub_mod_init() {
131131
"Rust hexdump", "Hexdump a file from Rust.");
132132
}
133133

134-
#[no_mangle]
134+
#[unsafe(no_mangle)]
135135
pub extern "C" fn grub_mod_fini() {
136136
grub::Command::unregister_all();
137137
}

0 commit comments

Comments
 (0)