aboutsummaryrefslogtreecommitdiff
path: root/rtic-macros/src/syntax/parse/app.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-04-13 05:38:13 +0000
committerGitHub <noreply@github.com>2023-04-13 05:38:13 +0000
commitf741475a3f552585f789b3b2b9c622b090e72057 (patch)
treeb2696705d5a97ec53041a772378beaf70b5c5642 /rtic-macros/src/syntax/parse/app.rs
parent44c614d792c65aa2660f841e969db575f1ee6e86 (diff)
parente47914ee50b838cceca77cd881dce9caaf689901 (diff)
Merge #730
730: remove vis restriction for local and shared resources r=korken89 a=andrewgazelka Co-authored-by: Andrew Gazelka <andrew.gazelka@gmail.com>
Diffstat (limited to 'rtic-macros/src/syntax/parse/app.rs')
-rw-r--r--rtic-macros/src/syntax/parse/app.rs34
1 files changed, 13 insertions, 21 deletions
diff --git a/rtic-macros/src/syntax/parse/app.rs b/rtic-macros/src/syntax/parse/app.rs
index e797f75..2f2d816 100644
--- a/rtic-macros/src/syntax/parse/app.rs
+++ b/rtic-macros/src/syntax/parse/app.rs
@@ -8,7 +8,6 @@ use syn::{
Expr, ExprArray, Fields, ForeignItem, Ident, Item, LitBool, Path, Token, Visibility,
};
-use super::Input;
use crate::syntax::{
ast::{
App, AppArgs, Dispatcher, Dispatchers, HardwareTask, Idle, IdleArgs, Init, InitArgs,
@@ -18,6 +17,8 @@ use crate::syntax::{
Either, Map, Set,
};
+use super::Input;
+
impl AppArgs {
pub(crate) fn parse(tokens: TokenStream2) -> parse::Result<Self> {
(|input: ParseStream<'_>| -> parse::Result<Self> {
@@ -147,9 +148,13 @@ impl App {
let mut idle = None;
let mut shared_resources_ident = None;
+ let mut shared_resources_vis = Visibility::Inherited;
let mut shared_resources = Map::new();
+
let mut local_resources_ident = None;
+ let mut local_resources_vis = Visibility::Inherited;
let mut local_resources = Map::new();
+
let mut hardware_tasks = Map::new();
let mut software_tasks = Map::new();
let mut user_imports = vec![];
@@ -283,12 +288,7 @@ impl App {
));
}
- if struct_item.vis != Visibility::Inherited {
- return Err(parse::Error::new(
- struct_item.span(),
- "this item must have inherited / private visibility",
- ));
- }
+ shared_resources_vis = struct_item.vis.clone();
if let Fields::Named(fields) = &mut struct_item.fields {
for field in &mut fields.named {
@@ -301,10 +301,8 @@ impl App {
));
}
- shared_resources.insert(
- ident.clone(),
- SharedResource::parse(field, ident.span())?,
- );
+ shared_resources
+ .insert(ident.clone(), SharedResource::parse(field)?);
}
} else {
return Err(parse::Error::new(
@@ -328,12 +326,7 @@ impl App {
));
}
- if struct_item.vis != Visibility::Inherited {
- return Err(parse::Error::new(
- struct_item.span(),
- "this item must have inherited / private visibility",
- ));
- }
+ local_resources_vis = struct_item.vis.clone();
if let Fields::Named(fields) = &mut struct_item.fields {
for field in &mut fields.named {
@@ -346,10 +339,7 @@ impl App {
));
}
- local_resources.insert(
- ident.clone(),
- LocalResource::parse(field, ident.span())?,
- );
+ local_resources.insert(ident.clone(), LocalResource::parse(field)?);
}
} else {
return Err(parse::Error::new(
@@ -470,7 +460,9 @@ impl App {
init,
idle,
shared_resources,
+ shared_resources_vis,
local_resources,
+ local_resources_vis,
user_imports,
user_code,
hardware_tasks,