Skip to content

Commit 9e4c0a0

Browse files
committed
Fix use of no_std after rust-lang/RFC-1184
rust-lang/rfcs#1184
1 parent 0b71ed1 commit 9e4c0a0

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

examples/no_std.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// cfg-gating is a workaround for Cargo until https://github.com/rust-lang/cargo/issues/1570 lands.
55
// Do not include it if you copy any code.
66

7-
#![cfg_attr(feature = "no_std", feature(lang_items, start, core, alloc, no_std))]
7+
#![cfg_attr(feature = "no_std", feature(lang_items, start, alloc, no_std))]
88
#![cfg_attr(feature = "no_std", no_std)]
99

1010
#[cfg(not(feature = "no_std"))]
@@ -14,12 +14,11 @@ fn main() { }
1414
#[macro_use]
1515
extern crate mopa;
1616

17-
#[cfg(feature = "no_std")]
18-
extern crate core;
1917
#[cfg(feature = "no_std")]
2018
extern crate alloc;
2119

2220
#[cfg(feature = "no_std")]
21+
#[allow(dead_code)]
2322
mod silly_wrapper_to_save_writing_the_whole_cfg_incantation_on_every_item {
2423
trait Panic { fn panic(&self) { } }
2524

@@ -43,5 +42,6 @@ mod silly_wrapper_to_save_writing_the_whole_cfg_incantation_on_every_item {
4342

4443
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
4544
#[lang = "eh_personality"] extern fn eh_personality() {}
45+
#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {}
4646
#[lang = "panic_fmt"] extern fn panic_fmt() {}
4747
}

examples/no_std_or_alloc.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Do not include it if you copy any code.
66

77

8-
#![cfg_attr(feature = "no_std", feature(lang_items, start, core, libc, no_std))]
8+
#![cfg_attr(feature = "no_std", feature(lang_items, start, libc, no_std))]
99
#![cfg_attr(feature = "no_std", no_std)]
1010

1111
#[cfg(not(feature = "no_std"))]
@@ -15,17 +15,17 @@ fn main() { }
1515
#[macro_use]
1616
extern crate mopa;
1717

18-
#[cfg(feature = "no_std")]
19-
extern crate core;
2018
#[cfg(feature = "no_std")]
2119
extern crate libc;
2220

2321
#[cfg(feature = "no_std")]
22+
#[allow(dead_code)]
2423
mod silly_wrapper_to_save_writing_the_whole_cfg_incantation_on_every_item {
2524
trait Panic { fn panic(&self) { } }
2625

2726
trait PanicAny: Panic + ::mopa::Any { }
2827

28+
#[allow(dead_code)]
2929
mopafy!(PanicAny, core = core);
3030

3131
impl Panic for i32 { }
@@ -44,5 +44,6 @@ mod silly_wrapper_to_save_writing_the_whole_cfg_incantation_on_every_item {
4444

4545
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
4646
#[lang = "eh_personality"] extern fn eh_personality() {}
47+
#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {}
4748
#[lang = "panic_fmt"] extern fn panic_fmt() {}
4849
}

src/lib.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,9 @@
132132
//! types across a variety of libraries. But the question of purpose and suitability is open, and I
133133
//! don’t have a really good example of such a use case here at present. TODO.
134134
135-
#![cfg_attr(feature = "no_std", feature(core, no_std))]
135+
#![cfg_attr(feature = "no_std", feature(no_std))]
136136
#![cfg_attr(feature = "no_std", no_std)]
137137

138-
#[cfg(feature = "no_std")]
139-
#[macro_use]
140-
extern crate core;
141-
142138
#[cfg(all(test, feature = "no_std"))]
143139
extern crate std;
144140

@@ -251,7 +247,7 @@ macro_rules! mopafy {
251247
};
252248

253249
($trait_:ident, core = $core:ident) => {
254-
mopafy!($trait_(), core = $core, alloc = std);
250+
mopafy!($trait_(), core = $core);
255251
};
256252

257253
($trait_:ident, core = $core:ident, alloc = $alloc:ident) => {
@@ -263,7 +259,7 @@ macro_rules! mopafy {
263259
};
264260

265261
($trait_:ident <$($args: ident),+>, core = $core:ident) => {
266-
mopafy!($trait_($($args),*), core = $core, alloc = $alloc);
262+
mopafy!($trait_($($args),*), core = $core);
267263
};
268264

269265
($trait_:ident <$($args: ident),+>, core = $core:ident, alloc = $alloc:ident) => {

0 commit comments

Comments
 (0)