diff --git a/macros/Cargo.toml b/macros/Cargo.toml index dd5fb546b8..4c4b734b23 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -3,6 +3,7 @@ authors = ["Jorge Aparicio "] categories = ["concurrency", "embedded", "no-std"] description = "Procedural macros of the cortex-m-rtfm crate" documentation = "https://japaric.github.io/cortex-m-rtfm/api/cortex_m_rtfm" +edition = "2018" keywords = ["arm", "cortex-m"] license = "MIT OR Apache-2.0" name = "cortex-m-rtfm-macros" diff --git a/macros/src/analyze.rs b/macros/src/analyze.rs index 869b5d2060..19575b7728 100644 --- a/macros/src/analyze.rs +++ b/macros/src/analyze.rs @@ -5,7 +5,7 @@ use std::{ use syn::{Attribute, Ident, Type}; -use syntax::{App, Idents}; +use crate::syntax::{App, Idents}; pub type Ownerships = HashMap; diff --git a/macros/src/check.rs b/macros/src/check.rs index 85184596be..ae2262a859 100644 --- a/macros/src/check.rs +++ b/macros/src/check.rs @@ -3,14 +3,14 @@ use std::{collections::HashSet, iter}; use proc_macro2::Span; use syn::parse; -use syntax::App; +use crate::syntax::App; pub fn app(app: &App) -> parse::Result<()> { // Check that all referenced resources have been declared for res in app .idle .as_ref() - .map(|idle| -> Box> { Box::new(idle.args.resources.iter()) }) + .map(|idle| -> Box> { Box::new(idle.args.resources.iter()) }) .unwrap_or_else(|| Box::new(iter::empty())) .chain(&app.init.args.resources) .chain(app.exceptions.values().flat_map(|e| &e.args.resources)) @@ -53,7 +53,7 @@ pub fn app(app: &App) -> parse::Result<()> { for task in app .idle .as_ref() - .map(|idle| -> Box> { + .map(|idle| -> Box> { Box::new(idle.args.schedule.iter().chain(&idle.args.spawn)) }) .unwrap_or_else(|| Box::new(iter::empty())) diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs index eafea945c3..45c3e263f7 100644 --- a/macros/src/codegen.rs +++ b/macros/src/codegen.rs @@ -12,8 +12,10 @@ use quote::quote; use rand::{Rng, SeedableRng}; use syn::{parse_quote, ArgCaptured, Attribute, Ident, IntSuffix, LitInt}; -use analyze::{Analysis, Ownership}; -use syntax::{App, Idents, Static}; +use crate::{ + analyze::{Analysis, Ownership}, + syntax::{App, Idents, Static}, +}; // NOTE to avoid polluting the user namespaces we map some identifiers to pseudo-hygienic names. // In some instances we also use the pseudo-hygienic names for safety, for example the user should diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 2e32da6585..c8d9fee190 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -2,10 +2,6 @@ #![recursion_limit = "128"] extern crate proc_macro; -extern crate proc_macro2; -extern crate quote; -extern crate rand; -extern crate syn; use proc_macro::TokenStream; use syn::parse_macro_input; diff --git a/macros/src/syntax.rs b/macros/src/syntax.rs index b9424fbe16..85f3caaa90 100644 --- a/macros/src/syntax.rs +++ b/macros/src/syntax.rs @@ -20,7 +20,7 @@ pub struct AppArgs { } impl Parse for AppArgs { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { let mut device = None; loop { if input.is_empty() { @@ -80,8 +80,8 @@ pub struct Input { } impl Parse for Input { - fn parse(input: ParseStream) -> parse::Result { - fn parse_items(input: ParseStream) -> parse::Result> { + fn parse(input: ParseStream<'_>) -> parse::Result { + fn parse_items(input: ParseStream<'_>) -> parse::Result> { let mut items = vec![]; while !input.is_empty() { @@ -254,7 +254,7 @@ impl App { pub fn resource_accesses(&self) -> impl Iterator { self.idle .as_ref() - .map(|idle| -> Box> { + .map(|idle| -> Box> { Box::new(idle.args.resources.iter().map(|res| (0, res))) }) .unwrap_or_else(|| Box::new(iter::empty())) @@ -293,7 +293,7 @@ impl App { .chain( self.idle .as_ref() - .map(|idle| -> Box> { + .map(|idle| -> Box> { Box::new(idle.args.spawn.iter().map(|s| (Some(0), s))) }) .unwrap_or_else(|| Box::new(iter::empty())), @@ -329,7 +329,7 @@ impl App { .chain( self.idle .as_ref() - .map(|idle| -> Box> { + .map(|idle| -> Box> { Box::new(idle.args.schedule.iter().map(|s| (Some(0), s))) }) .unwrap_or_else(|| Box::new(iter::empty())), @@ -358,7 +358,7 @@ impl App { pub fn schedule_callers(&self) -> impl Iterator { self.idle .as_ref() - .map(|idle| -> Box> { + .map(|idle| -> Box> { Box::new(iter::once(( Ident::new("idle", Span::call_site()), &idle.args.schedule, @@ -389,7 +389,7 @@ impl App { pub fn spawn_callers(&self) -> impl Iterator { self.idle .as_ref() - .map(|idle| -> Box> { + .map(|idle| -> Box> { Box::new(iter::once(( Ident::new("idle", Span::call_site()), &idle.args.spawn, @@ -492,7 +492,7 @@ impl Default for InitArgs { } impl Parse for InitArgs { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { if input.is_empty() { return Ok(InitArgs::default()); } @@ -662,7 +662,7 @@ pub struct ExceptionArgs { } impl Parse for ExceptionArgs { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { parse_args(input, false).map( |TaskArgs { priority, @@ -853,13 +853,13 @@ impl Default for TaskArgs { } impl Parse for TaskArgs { - fn parse(input: ParseStream) -> parse::Result { + fn parse(input: ParseStream<'_>) -> parse::Result { parse_args(input, true) } } // Parser shared by TaskArgs and ExceptionArgs / InterruptArgs -fn parse_args(input: ParseStream, accept_capacity: bool) -> parse::Result { +fn parse_args(input: ParseStream<'_>, accept_capacity: bool) -> parse::Result { if input.is_empty() { return Ok(TaskArgs::default()); }