Skip to content

Commit f102430

Browse files
committed
singleton: don't forward visibility
1 parent 5ce1643 commit f102430

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cortex-m/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2424
- Added the ability to name the statics generated by `singleton!()` for better debuggability (#364, #380).
2525
- Added `critical-section-single-core` feature which provides an implementation for the `critical_section` crate for single-core systems, based on disabling all interrupts. (#447)
2626
- Added support for `embedded-hal` version 1 delay traits, requiring rust 1.60.
27-
- `singleton!()` now forwards attributes and visibility (#521).
27+
- `singleton!()` now forwards attributes (#522).
2828

2929
### Fixed
3030
- Fixed `singleton!()` statics sometimes ending up in `.data` instead of `.bss` (#364, #380).

cortex-m/src/macros.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ macro_rules! iprintln {
6464
/// ```
6565
#[macro_export]
6666
macro_rules! singleton {
67-
($(#[$meta:meta])* $vis:vis $name:ident: $ty:ty = $expr:expr) => {
67+
($(#[$meta:meta])* $name:ident: $ty:ty = $expr:expr) => {
6868
$crate::_export::critical_section::with(|_| {
6969
// this is a tuple of a MaybeUninit and a bool because using an Option here is
7070
// problematic: Due to niche-optimization, an Option could end up producing a non-zero
7171
// initializer value which would move the entire static from `.bss` into `.data`...
7272
$(#[$meta])*
73-
$vis static mut $name: (::core::mem::MaybeUninit<$ty>, bool) =
73+
static mut $name: (::core::mem::MaybeUninit<$ty>, bool) =
7474
(::core::mem::MaybeUninit::uninit(), false);
7575

7676
#[allow(unsafe_code)]
@@ -89,8 +89,8 @@ macro_rules! singleton {
8989
}
9090
})
9191
};
92-
(: $ty:ty = $expr:expr) => {
93-
$crate::singleton!(VAR: $ty = $expr)
92+
($(#[$meta:meta])* : $ty:ty = $expr:expr) => {
93+
$crate::singleton!($(#[$meta])* VAR: $ty = $expr)
9494
};
9595
}
9696

@@ -121,8 +121,9 @@ const CPASS: () = ();
121121
/// use cortex_m::singleton;
122122
///
123123
/// fn foo() {
124-
/// // check that attributes and visibility are forwarded
125-
/// singleton!(#[link_section = ".bss"] pub(crate) FOO: u8 = 0);
124+
/// // check that attributes are forwarded
125+
/// singleton!(#[link_section = ".bss"] FOO: u8 = 0);
126+
/// singleton!(#[link_section = ".bss"]: u8 = 1);
126127
/// }
127128
/// ```
128129
#[allow(dead_code)]

0 commit comments

Comments
 (0)