Skip to content
Snippets Groups Projects
Commit b9f50e43 authored by Jorge Aparicio's avatar Jorge Aparicio
Browse files

make task.$T.path mandatory

parent d396da59
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,7 @@ pub enum Kind { ...@@ -49,7 +49,7 @@ pub enum Kind {
pub struct Task { pub struct Task {
pub kind: Kind, pub kind: Kind,
pub path: Option<Path>, pub path: Path,
pub priority: u8, pub priority: u8,
pub resources: Idents, pub resources: Idents,
} }
...@@ -122,7 +122,7 @@ fn task(name: &str, task: syntax::check::Task) -> Result<Task> { ...@@ -122,7 +122,7 @@ fn task(name: &str, task: syntax::check::Task) -> Result<Task> {
Ok(Task { Ok(Task {
kind, kind,
path: task.path, path: task.path.ok_or("`path` field is missing")?,
priority: task.priority.unwrap_or(1), priority: task.priority.unwrap_or(1),
resources: task.resources, resources: task.resources,
}) })
......
...@@ -603,7 +603,6 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) { ...@@ -603,7 +603,6 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
}); });
} }
if let Some(path) = task.path.as_ref() {
let mut tys = vec![]; let mut tys = vec![];
let mut exprs = vec![]; let mut exprs = vec![];
...@@ -624,6 +623,7 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) { ...@@ -624,6 +623,7 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
exprs.push(quote!(#name::Resources::new())); exprs.push(quote!(#name::Resources::new()));
} }
let path = &task.path;
let _name = Ident::new(format!("_{}", name)); let _name = Ident::new(format!("_{}", name));
let export_name = let export_name =
Lit::Str(name.as_ref().to_owned(), StrStyle::Cooked); Lit::Str(name.as_ref().to_owned(), StrStyle::Cooked);
...@@ -637,32 +637,6 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) { ...@@ -637,32 +637,6 @@ fn tasks(app: &App, ownerships: &Ownerships, root: &mut Vec<Tokens>) {
f(#(#exprs,)*) f(#(#exprs,)*)
} }
}); });
} else if !has_resources {
items.push(quote! {
pub struct Resources {
_0: (),
}
impl Resources {
pub unsafe fn new() -> Self {
Resources { _0: () }
}
}
});
// the `task!` macro will be used so the `#NAME::Resources` type
// must exist
}
let priority = task.priority;
if task.path.is_none() {
// This `const`ant is mainly used to make sure the user doesn't
// forget to set a task handler using the `task!` macro. They'll get
// an error if they do.
items.push(quote! {
#[deny(dead_code)]
pub const #name: u8 = #priority;
});
}
root.push(quote!{ root.push(quote!{
#[allow(non_snake_case)] #[allow(non_snake_case)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment