aboutsummaryrefslogtreecommitdiff
path: root/macros/src/check.rs
diff options
context:
space:
mode:
authorhomunkulus <homunkulus@gmx.com>2017-12-09 12:09:35 +0000
committerhomunkulus <homunkulus@gmx.com>2017-12-09 12:09:35 +0000
commite78ca98c42a2af1ca9c04d176441b045cd5e8c65 (patch)
tree36287f0622b3ea691e9fa83781c6308c5ad490e3 /macros/src/check.rs
parente620b1e57a39f342cf73ad6ac8ab0e179b97bfd5 (diff)
parent1830bdbe5c10814031e5022552a09147d5c534fc (diff)
Auto merge of #50 - japaric:singletons, r=japaric
Peripherals as scoped singletons See this RFC for details: japaric/svd2rust#157 - The first commit adapts this crate to the changes in japaric/cortex-m#65 and japaric/svd2rust#158 - ~~The second commit is an alternative implementation of RFC #47 (there's another implementation in #49. This second commit is not required for RFC157 but let us experiment with safe DMA abstractions.~~ postponed ### TODO - [x] un-bless peripherals as resources. Peripherals as resources were special cased: if resource listed in e.g. `app.tasks.FOO.resources` didn't appear in `app.resources` then it was assumed to be a peripheral and special code was generated for it. This is no longer required under RFC157. ~~This depends on PR japaric/rtfm-syntax#2~~ postponed
Diffstat (limited to 'macros/src/check.rs')
-rw-r--r--macros/src/check.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/macros/src/check.rs b/macros/src/check.rs
index 3cd112a..63cac1f 100644
--- a/macros/src/check.rs
+++ b/macros/src/check.rs
@@ -63,16 +63,15 @@ pub fn app(app: check::App) -> Result<App> {
tasks: app.tasks
.into_iter()
.map(|(k, v)| {
- let v = ::check::task(k.as_ref(), v)
- .chain_err(|| format!("checking task `{}`", k))?;
+ let v =
+ ::check::task(k.as_ref(), v).chain_err(|| format!("checking task `{}`", k))?;
Ok((k, v))
})
.collect::<Result<_>>()?,
};
- ::check::resources(&app)
- .chain_err(|| "checking `resources`")?;
+ ::check::resources(&app).chain_err(|| "checking `resources`")?;
Ok(app)
}
@@ -93,6 +92,17 @@ fn resources(app: &App) -> Result<()> {
bail!("resource `{}` is unused", resource);
}
+ for (name, task) in &app.tasks {
+ for resource in &task.resources {
+ ensure!(
+ app.resources.contains_key(&resource),
+ "task {} contains an undeclared resource with name {}",
+ name,
+ resource
+ );
+ }
+ }
+
Ok(())
}