Skip to content

Commit a784d3b

Browse files
committed
uefi_std: Remove unstable features except prelude_import
Most of the unstable features are not required for building. For panics, the only remaining detail is having an implementation of the panic handler (`panic_handler`) itself. - `eh_personality`: Not required with `panic=abort` - `_Unwind_Resume`: Symbol not present with `panic=abort` - `alloc_error_handler`: OOM triggers a panic; feature will be removed [1] [1]: rust-lang/rust#112331 Signed-off-by: Tim Crawford <[email protected]>
1 parent e9030af commit a784d3b

File tree

4 files changed

+9
-55
lines changed

4 files changed

+9
-55
lines changed

crates/uefi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
#![no_std]
12
#![allow(dead_code)]
23
#![allow(non_snake_case)]
3-
#![no_std]
44

55
#[macro_use]
66
pub mod macros;

crates/uefi_std/src/lib.rs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
#![no_std]
2-
#![feature(alloc_error_handler)]
3-
#![feature(concat_idents)]
4-
#![feature(core_intrinsics)]
5-
#![feature(custom_test_frameworks)]
6-
#![feature(format_args_nl)]
7-
#![feature(lang_items)]
8-
#![feature(log_syntax)]
92
#![feature(prelude_import)]
10-
#![feature(prelude_2024)]
11-
#![feature(slice_concat_ext)]
12-
#![feature(test)]
13-
#![feature(trace_macros)]
143

154
/* This section was addapted from the Rust Standard Library, and is licensed accordingly
165
* https://github.com/rust-lang/rust/blob/master/src/libstd/lib.rs
@@ -60,7 +49,6 @@ pub use core::i16;
6049
pub use core::i32;
6150
pub use core::i64;
6251
pub use core::i8;
63-
pub use core::intrinsics;
6452
pub use core::isize;
6553
pub use core::iter;
6654
pub use core::marker;
@@ -96,28 +84,23 @@ pub use core::{
9684
};
9785

9886
// Re-export built-in macros defined through libcore.
99-
pub use core::prelude::v1::{
87+
pub use core::prelude::rust_2021::{
10088
// Stable
10189
assert,
10290
cfg,
10391
column,
10492
compile_error,
10593
concat,
10694
// Unstable
107-
concat_idents,
10895
env,
10996
file,
110-
format_args,
111-
format_args_nl,
11297
include,
11398
include_bytes,
11499
include_str,
115100
line,
116-
log_syntax,
117101
module_path,
118102
option_env,
119103
stringify,
120-
trace_macros,
121104
};
122105

123106
/* } */

crates/uefi_std/src/prelude.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ pub use crate::result::Result::{self, Err, Ok};
2727

2828
// Re-exported built-in macros
2929
#[doc(no_inline)]
30-
pub use core::prelude::v1::{
31-
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
32-
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
33-
stringify, trace_macros,
30+
pub use core::prelude::rust_2021::{
31+
assert, cfg, column, compile_error, concat, env, file,
32+
include, include_bytes, include_str, line, module_path, option_env,
33+
stringify,
3434
};
3535

3636
// FIXME: Attribute and derive macros are not documented because for them rustdoc generates
3737
// dead links which fail link checker testing.
3838
#[allow(deprecated)]
3939
#[doc(hidden)]
40-
pub use core::prelude::v1::{
41-
bench, test, test_case, Clone, Copy, Debug, Default, Eq, Hash, Ord,
40+
pub use core::prelude::rust_2021::{
41+
Clone, Copy, Debug, Default, Eq, Hash, Ord,
4242
PartialEq, PartialOrd,
4343
};
4444

crates/uefi_std/src/rt/panic.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,6 @@
1-
// These functions are used by the compiler, but not
2-
// for a bare-bones hello world. These are normally
3-
// provided by libstd.
4-
5-
use core::prelude::rust_2024::alloc_error_handler;
6-
7-
#[lang = "eh_personality"]
8-
#[no_mangle]
9-
pub extern "C" fn rust_eh_personality() {}
10-
111
#[panic_handler]
12-
#[no_mangle]
13-
pub fn rust_begin_panic(pi: &::core::panic::PanicInfo) -> ! {
2+
pub fn panic(pi: &core::panic::PanicInfo) -> ! {
143
print!("SETUP PANIC: {}", pi);
154

165
loop {}
176
}
18-
19-
#[alloc_error_handler]
20-
#[no_mangle]
21-
pub fn rust_oom(layout: ::core::alloc::Layout) -> ! {
22-
println!(
23-
"SETUP OOM: {} bytes aligned to {} bytes\n",
24-
layout.size(),
25-
layout.align()
26-
);
27-
28-
loop {}
29-
}
30-
31-
#[allow(non_snake_case)]
32-
#[no_mangle]
33-
pub extern "C" fn _Unwind_Resume() {
34-
loop {}
35-
}

0 commit comments

Comments
 (0)