File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,20 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
171
171
}
172
172
}
173
173
174
- match exn {
174
+ // Emit a reference to the `Exception` variant corresponding to our exception.
175
+ // This will fail compilation when the target doesn't have that exception.
176
+ let assertion = match exn {
177
+ Exception :: Other => {
178
+ quote ! {
179
+ const _: ( ) = {
180
+ let _ = cortex_m_rt:: Exception :: #ident;
181
+ } ;
182
+ }
183
+ }
184
+ _ => quote ! ( ) ,
185
+ } ;
186
+
187
+ let handler = match exn {
175
188
Exception :: DefaultHandler => {
176
189
let valid_signature = f. sig . constness . is_none ( )
177
190
&& f. vis == Visibility :: Inherited
@@ -221,7 +234,6 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
221
234
222
235
#f
223
236
)
224
- . into ( )
225
237
}
226
238
Exception :: HardFault => {
227
239
let valid_signature = f. sig . constness . is_none ( )
@@ -274,7 +286,6 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
274
286
275
287
#f
276
288
)
277
- . into ( )
278
289
}
279
290
Exception :: NonMaskableInt | Exception :: Other => {
280
291
let valid_signature = f. sig . constness . is_none ( )
@@ -364,9 +375,14 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
364
375
365
376
#f
366
377
)
367
- . into ( )
368
378
}
369
- }
379
+ } ;
380
+
381
+ quote ! (
382
+ #assertion
383
+ #handler
384
+ )
385
+ . into ( )
370
386
}
371
387
372
388
#[ proc_macro_attribute]
You can’t perform that action at this time.
0 commit comments