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

resources owned by idle have 'static lifetime

parent 5824f837
No related branches found
No related tags found
No related merge requests found
...@@ -89,7 +89,6 @@ fn idle( ...@@ -89,7 +89,6 @@ fn idle(
if !app.idle.resources.is_empty() { if !app.idle.resources.is_empty() {
let device = &app.device; let device = &app.device;
let mut lifetime = None;
let mut needs_reexport = false; let mut needs_reexport = false;
for name in &app.idle.resources { for name in &app.idle.resources {
...@@ -110,22 +109,19 @@ fn idle( ...@@ -110,22 +109,19 @@ fn idle(
let mut rfields = vec![]; let mut rfields = vec![];
for name in &app.idle.resources { for name in &app.idle.resources {
if ownerships[name].is_owned() { if ownerships[name].is_owned() {
lifetime = Some(quote!('a));
if let Some(resource) = app.resources.get(name) { if let Some(resource) = app.resources.get(name) {
let ty = &resource.ty; let ty = &resource.ty;
rfields.push(quote! { rfields.push(quote! {
pub #name: &'a mut ::#krate::Static<#ty>, pub #name: &'static mut #ty,
}); });
rexprs.push(quote! { rexprs.push(quote! {
#name: ::#krate::Static::ref_mut( #name: &mut *#super_::#name.get(),
&mut *#super_::#name.get(),
),
}); });
} else { } else {
rfields.push(quote! { rfields.push(quote! {
pub #name: &'a mut ::#device::#name, pub #name: &'static mut ::#device::#name,
}); });
rexprs.push(quote! { rexprs.push(quote! {
...@@ -147,7 +143,7 @@ fn idle( ...@@ -147,7 +143,7 @@ fn idle(
root.push(quote! { root.push(quote! {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub struct _idleResources<#lifetime> { pub struct _idleResources {
#(#rfields)* #(#rfields)*
} }
}); });
...@@ -158,14 +154,14 @@ fn idle( ...@@ -158,14 +154,14 @@ fn idle(
} else { } else {
mod_items.push(quote! { mod_items.push(quote! {
#[allow(non_snake_case)] #[allow(non_snake_case)]
pub struct Resources<#lifetime> { pub struct Resources {
#(#rfields)* #(#rfields)*
} }
}); });
} }
mod_items.push(quote! { mod_items.push(quote! {
impl<#lifetime> Resources<#lifetime> { impl Resources {
pub unsafe fn new() -> Self { pub unsafe fn new() -> Self {
Resources { Resources {
#(#rexprs)* #(#rexprs)*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment