From 51a8c4fec9e1e06a80537ada395daaf2ac8edafb Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Mon, 9 Dec 2019 20:24:44 -0500 Subject: [PATCH] Remove 'extern crate cortex_m_rt' from macros See justification on 519d46a. Using 'extern crate cortex_m_rt' inside of the macros limits our ability to use the macros crate in other contexts. As long as another crate publicly exports an enumeration of `interrupt` and an enumeration of `exception`, the macros crate may be used in other cortex-m-rt-like systems. --- macros/src/lib.rs | 8 ++------ src/lib.rs | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 543130c9..a844305c 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -173,7 +173,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { /// # Syntax /// /// ``` -/// # use cortex_m_rt_macros::exception; +/// # use cortex_m_rt::exception; /// #[exception] /// fn SysTick() { /// // .. @@ -449,10 +449,8 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { })); f.block.stmts = iter::once( syn::parse2(quote! {{ - extern crate cortex_m_rt; - // check that this exception actually exists - cortex_m_rt::Exception::#ident; + exception::#ident; }}) .unwrap(), ) @@ -619,8 +617,6 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream { })); f.block.stmts = iter::once( syn::parse2(quote! {{ - extern crate cortex_m_rt; - // Check that this interrupt actually exists interrupt::#ident; }}) diff --git a/src/lib.rs b/src/lib.rs index 85d94965..8bfdd693 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -599,6 +599,8 @@ pub enum Exception { SysTick, } +pub use self::Exception as exception; + extern "C" { fn NonMaskableInt();