mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-01 16:04:33 +01:00
resources owned by idle have 'static lifetime
This commit is contained in:
parent
5824f837e1
commit
a2b0c9e0d0
1 changed files with 6 additions and 10 deletions
|
@ -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(
|
||||||
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(
|
||||||
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(
|
||||||
} 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)*
|
||||||
|
|
Loading…
Reference in a new issue