mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-24 02:49:34 +01:00
move macros crate to the 2018 edition
This commit is contained in:
parent
8e9a91d0b0
commit
56d09a12dd
6 changed files with 21 additions and 22 deletions
|
@ -3,6 +3,7 @@ authors = ["Jorge Aparicio <jorge@japaric.io>"]
|
|||
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"
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
|
||||
use syn::{Attribute, Ident, Type};
|
||||
|
||||
use syntax::{App, Idents};
|
||||
use crate::syntax::{App, Idents};
|
||||
|
||||
pub type Ownerships = HashMap<Ident, Ownership>;
|
||||
|
||||
|
|
|
@ -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<Iterator<Item = _>> { Box::new(idle.args.resources.iter()) })
|
||||
.map(|idle| -> Box<dyn Iterator<Item = _>> { 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<Iterator<Item = _>> {
|
||||
.map(|idle| -> Box<dyn Iterator<Item = _>> {
|
||||
Box::new(idle.args.schedule.iter().chain(&idle.args.spawn))
|
||||
})
|
||||
.unwrap_or_else(|| Box::new(iter::empty()))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -20,7 +20,7 @@ pub struct AppArgs {
|
|||
}
|
||||
|
||||
impl Parse for AppArgs {
|
||||
fn parse(input: ParseStream) -> parse::Result<Self> {
|
||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
||||
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<Self> {
|
||||
fn parse_items(input: ParseStream) -> parse::Result<Vec<Item>> {
|
||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
||||
fn parse_items(input: ParseStream<'_>) -> parse::Result<Vec<Item>> {
|
||||
let mut items = vec![];
|
||||
|
||||
while !input.is_empty() {
|
||||
|
@ -254,7 +254,7 @@ impl App {
|
|||
pub fn resource_accesses(&self) -> impl Iterator<Item = (u8, &Ident)> {
|
||||
self.idle
|
||||
.as_ref()
|
||||
.map(|idle| -> Box<Iterator<Item = _>> {
|
||||
.map(|idle| -> Box<dyn Iterator<Item = _>> {
|
||||
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<Iterator<Item = _>> {
|
||||
.map(|idle| -> Box<dyn Iterator<Item = _>> {
|
||||
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<Iterator<Item = _>> {
|
||||
.map(|idle| -> Box<dyn Iterator<Item = _>> {
|
||||
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<Item = (Ident, &Idents)> {
|
||||
self.idle
|
||||
.as_ref()
|
||||
.map(|idle| -> Box<Iterator<Item = _>> {
|
||||
.map(|idle| -> Box<dyn Iterator<Item = _>> {
|
||||
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<Item = (Ident, &Idents)> {
|
||||
self.idle
|
||||
.as_ref()
|
||||
.map(|idle| -> Box<Iterator<Item = _>> {
|
||||
.map(|idle| -> Box<dyn Iterator<Item = _>> {
|
||||
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<InitArgs> {
|
||||
fn parse(input: ParseStream<'_>) -> parse::Result<InitArgs> {
|
||||
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<Self> {
|
||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
||||
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<Self> {
|
||||
fn parse(input: ParseStream<'_>) -> parse::Result<Self> {
|
||||
parse_args(input, true)
|
||||
}
|
||||
}
|
||||
|
||||
// Parser shared by TaskArgs and ExceptionArgs / InterruptArgs
|
||||
fn parse_args(input: ParseStream, accept_capacity: bool) -> parse::Result<TaskArgs> {
|
||||
fn parse_args(input: ParseStream<'_>, accept_capacity: bool) -> parse::Result<TaskArgs> {
|
||||
if input.is_empty() {
|
||||
return Ok(TaskArgs::default());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue