Skip to content

Commit ed35243

Browse files
committed
unsafe no-mangle
1 parent b6ef0b0 commit ed35243

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

.github/workflows/ci.yml

+16-4
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,29 @@ jobs:
8383
- { rust: stable, vendor: Spansion, options: "--atomics" }
8484
- { rust: stable, vendor: STMicro, options: "" }
8585
- { rust: stable, vendor: STMicro, options: "--atomics" }
86-
- { rust: stable, vendor: STM32-patched, options: "--strict -f enum_value::p: --max-cluster-size --atomics --atomics-feature atomics --impl-debug --impl-defmt defmt" }
86+
- {
87+
rust: stable,
88+
vendor: STM32-patched,
89+
options: "--strict -f enum_value::p: --max-cluster-size --atomics --atomics-feature atomics --impl-debug --impl-defmt defmt",
90+
}
8791
- { rust: stable, vendor: Toshiba, options: all }
8892
- { rust: stable, vendor: Toshiba, options: "" }
8993
# Test MSRV
90-
- { rust: 1.76.0, vendor: Nordic, options: "" }
94+
- { rust: 1.82.0, vendor: Nordic, options: "" }
9195
# Use nightly for architectures which don't support stable
9296
- { rust: nightly, vendor: MSP430, options: "--atomics" }
9397
- { rust: nightly, vendor: MSP430, options: "" }
9498
# Workaround for _1token0
95-
- { rust: nightly-2024-09-25, vendor: Espressif, options: "--atomics --ident-formats-theme legacy" }
96-
- { rust: nightly-2024-09-25, vendor: Espressif, options: "--ident-format register:::Reg" }
99+
- {
100+
rust: nightly-2024-09-25,
101+
vendor: Espressif,
102+
options: "--atomics --ident-formats-theme legacy",
103+
}
104+
- {
105+
rust: nightly-2024-09-25,
106+
vendor: Espressif,
107+
options: "--ident-format register:::Reg",
108+
}
97109

98110
steps:
99111
- uses: actions/checkout@v4

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77

88
## [Unreleased]
99

10+
- Bump MSRV of generated code to 1.82
11+
1012
## [v0.35.0] - 2024-11-12
1113

1214
- Add `crate_path` setting

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ This project is developed and maintained by the [Tools team][team].
1717

1818
## Minimum Supported Rust Version (MSRV)
1919

20-
The **generated code** is guaranteed to compile on stable Rust 1.76.0 and up.
20+
The **generated code** is guaranteed to compile on stable Rust 1.82.0 and up.
2121

22-
If you encounter compilation errors on any stable version newer than 1.76.0, please open an issue.
22+
If you encounter compilation errors on any stable version newer than 1.82.0, please open an issue.
2323

2424
# Testing Locally
2525

src/generate/device.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
273273
#feature_attribute
274274
pub #p_singleton: #p_ty,
275275
});
276-
exprs.extend(quote!(#feature_attribute #p_singleton: #p_ty::steal(),));
276+
exprs.extend(quote!(#feature_attribute #p_singleton: unsafe { #p_ty::steal() },));
277277
}
278278
Peripheral::Array(p, dim_element) => {
279279
for p_name in names(p, dim_element) {
@@ -288,7 +288,9 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
288288
#feature_attribute
289289
pub #p_singleton: #p_ty,
290290
});
291-
exprs.extend(quote!(#feature_attribute #p_singleton: #p_ty::steal(),));
291+
exprs.extend(
292+
quote!(#feature_attribute #p_singleton: unsafe { #p_ty::steal() },),
293+
);
292294
}
293295
}
294296
}
@@ -298,7 +300,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result<Toke
298300
// NOTE `no_mangle` is used here to prevent linking different minor versions of the device
299301
// crate as that would let you `take` the device peripherals more than once (one per minor
300302
// version)
301-
#[no_mangle]
303+
#[unsafe(no_mangle)]
302304
static mut DEVICE_PERIPHERALS: bool = false;
303305

304306
/// All the peripherals.

src/generate/interrupt.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub fn render(
144144
#[cfg(feature = "rt")]
145145
#[doc(hidden)]
146146
#link_section_attr
147-
#[no_mangle]
147+
#[unsafe(no_mangle)]
148148
pub static __INTERRUPTS: [Vector; #n] = [
149149
#elements
150150
];
@@ -179,7 +179,7 @@ pub fn render(
179179
#[cfg(feature = "rt")]
180180
#[doc(hidden)]
181181
#link_section_attr
182-
#[no_mangle]
182+
#[unsafe(no_mangle)]
183183
#[used]
184184
pub static __INTERRUPTS:
185185
[Vector; #n] = [
@@ -214,7 +214,7 @@ pub fn render(
214214
#[cfg(feature = "rt")]
215215
#[doc(hidden)]
216216
#link_section_attr
217-
#[no_mangle]
217+
#[unsafe(no_mangle)]
218218
pub static __EXTERNAL_INTERRUPTS: [Vector; #n] = [
219219
#elements
220220
];
@@ -414,7 +414,7 @@ pub fn render(
414414
}
415415

416416
#[allow(non_snake_case)]
417-
#[no_mangle]
417+
#[unsafe(no_mangle)]
418418
pub extern #abi fn $NAME() {
419419
// check that the handler exists
420420
let _ = $crate::interrupt::Interrupt::$NAME;
@@ -433,7 +433,7 @@ pub fn render(
433433
};
434434
($NAME:ident, $path:path) => {
435435
#[allow(non_snake_case)]
436-
#[no_mangle]
436+
#[unsafe(no_mangle)]
437437
pub extern #abi fn $NAME() {
438438
// check that the handler exists
439439
let _ = $crate::interrupt::Interrupt::$NAME;

0 commit comments

Comments
 (0)