Add check again

This commit is contained in:
Emil Fresk 2023-01-02 14:58:37 +01:00 committed by Henrik Tjäder
parent ac4a3edf90
commit c85a4e34e6
3 changed files with 13 additions and 23 deletions

View file

@ -1,18 +1,12 @@
use std::collections::HashSet;
use proc_macro2::Span;
use rtic_syntax::{analyze::Analysis, ast::App};
use syn::{parse, Path};
use crate::syntax::ast::App;
use syn::parse;
pub struct Extra {
pub device: Path,
pub peripherals: bool,
}
pub fn app(app: &App, _analysis: &Analysis) -> parse::Result<Extra> {
pub fn app(app: &App) -> parse::Result<()> {
// Check that external (device-specific) interrupts are not named after known (Cortex-M)
// exceptions
for name in app.args.extern_interrupts.keys() {
for name in app.args.dispatchers.keys() {
let name_s = name.to_string();
match &*name_s {
@ -41,7 +35,7 @@ pub fn app(app: &App, _analysis: &Analysis) -> parse::Result<Extra> {
.collect::<HashSet<_>>();
let need = priorities.len();
let given = app.args.extern_interrupts.len();
let given = app.args.dispatchers.len();
if need > given {
let s = {
format!(
@ -72,15 +66,5 @@ pub fn app(app: &App, _analysis: &Analysis) -> parse::Result<Extra> {
}
}
if let Some(device) = app.args.device.clone() {
Ok(Extra {
device,
peripherals: app.args.peripherals,
})
} else {
Err(parse::Error::new(
Span::call_site(),
"a `device` argument must be specified in `#[rtic::app]`",
))
}
Ok(())
}

View file

@ -10,6 +10,7 @@ use std::{env, fs, path::Path};
mod analyze;
mod bindings;
mod check;
mod codegen;
mod syntax;
@ -61,6 +62,11 @@ pub fn app(args: TokenStream, input: TokenStream) -> TokenStream {
Ok(x) => x,
};
match check::app(&app) {
Err(e) => return e.to_compile_error().into(),
_ => {}
}
let analysis = analyze::app(analysis, &app);
let ts = codegen::app(&app, &analysis);

View file

@ -1,4 +1,4 @@
error: not enough interrupts to dispatch all software and async tasks (need: 1; given: 0) - one interrupt is needed per priority and sync/async task
error: not enough interrupts to dispatch all software tasks (need: 1; given: 0)
--> ui/extern-interrupt-not-enough.rs:17:8
|
17 | fn a(_: a::Context) {}