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 {
171171 }
172172 }
173173
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 {
175188 Exception :: DefaultHandler => {
176189 let valid_signature = f. sig . constness . is_none ( )
177190 && f. vis == Visibility :: Inherited
@@ -221,7 +234,6 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
221234
222235 #f
223236 )
224- . into ( )
225237 }
226238 Exception :: HardFault => {
227239 let valid_signature = f. sig . constness . is_none ( )
@@ -274,7 +286,6 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
274286
275287 #f
276288 )
277- . into ( )
278289 }
279290 Exception :: NonMaskableInt | Exception :: Other => {
280291 let valid_signature = f. sig . constness . is_none ( )
@@ -364,9 +375,14 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
364375
365376 #f
366377 )
367- . into ( )
368378 }
369- }
379+ } ;
380+
381+ quote ! (
382+ #assertion
383+ #handler
384+ )
385+ . into ( )
370386}
371387
372388#[ proc_macro_attribute]
You can’t perform that action at this time.
0 commit comments