diff options
author | 2021-11-11 13:32:35 +0000 | |
---|---|---|
committer | 2021-11-11 13:32:35 +0000 | |
commit | 4f2dd875ffc9740b35b99adc11623266398275e0 (patch) | |
tree | 1adb489563769d5e3bda7d698baac33d31d9b092 /macros/src/codegen/shared_resources.rs | |
parent | 6466aec406ccb20bc9f7b2b31fa5ab9e2501c2e7 (diff) | |
parent | 6f2aa08910cbe7c41ae877bdbf6eb3dc3cad5f22 (diff) | |
download | rtic-4f2dd875ffc9740b35b99adc11623266398275e0.tar.gz rtic-4f2dd875ffc9740b35b99adc11623266398275e0.tar.zst rtic-4f2dd875ffc9740b35b99adc11623266398275e0.zip |
Merge #554
554: Better errors on when missing to lock shared resources r=perlindgren a=korken89
Old error:
```
error[E0614]: type `value<'_>` cannot be dereferenced
--> examples/lock_minimal.rs:33:9
|
33 | *c.shared.value += 1;
| ^^^^^^^^^^^^^^^
```
New error:
```
error[E0614]: type `value_that_needs_to_be_locked<'_>` cannot be dereferenced
--> examples/lock_minimal.rs:33:9
|
33 | *c.shared.value += 1;
| ^^^^^^^^^^^^^^^
```
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'macros/src/codegen/shared_resources.rs')
-rw-r--r-- | macros/src/codegen/shared_resources.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs index b27c827c..ddd3824c 100644 --- a/macros/src/codegen/shared_resources.rs +++ b/macros/src/codegen/shared_resources.rs @@ -43,21 +43,23 @@ pub fn codegen( // For future use // let doc = format!(" RTIC internal: {}:{}", file!(), line!()); + let shared_name = util::need_to_lock_ident(name); + if !res.properties.lock_free { mod_resources.push(quote!( // #[doc = #doc] #[doc(hidden)] #[allow(non_camel_case_types)] #(#cfgs)* - pub struct #name<'a> { + pub struct #shared_name<'a> { priority: &'a Priority, } #(#cfgs)* - impl<'a> #name<'a> { + impl<'a> #shared_name<'a> { #[inline(always)] pub unsafe fn new(priority: &'a Priority) -> Self { - #name { priority } + #shared_name { priority } } #[inline(always)] @@ -86,7 +88,7 @@ pub fn codegen( extra, cfgs, true, - &name, + &shared_name, quote!(#ty), ceiling, ptr, |