mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
Clippy fixes
This commit is contained in:
parent
11f0164448
commit
3cfb95a5db
14 changed files with 43 additions and 63 deletions
3
build.rs
3
build.rs
|
@ -19,8 +19,7 @@ fn main() {
|
|||
&& !(target.starts_with("thumbv6m") | target.starts_with("thumbv8m.base"))
|
||||
{
|
||||
panic!(
|
||||
"Unknown target '{}'. Need to update BASEPRI logic in build.rs.",
|
||||
target
|
||||
"Unknown target '{target}'. Need to update BASEPRI logic in build.rs."
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@ pub fn app(app: &App) -> parse::Result<()> {
|
|||
let s = {
|
||||
format!(
|
||||
"not enough interrupts to dispatch \
|
||||
all software tasks (need: {}; given: {})",
|
||||
need, given
|
||||
all software tasks (need: {need}; given: {given})"
|
||||
)
|
||||
};
|
||||
|
||||
|
|
|
@ -85,8 +85,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
|
||||
if level > 0 {
|
||||
let doc = format!(
|
||||
"Interrupt handler to dispatch async tasks at priority {}",
|
||||
level
|
||||
"Interrupt handler to dispatch async tasks at priority {level}"
|
||||
);
|
||||
let attribute = &interrupts.get(&level).expect("UNREACHABLE").1.attrs;
|
||||
items.push(quote!(
|
||||
|
|
|
@ -15,15 +15,13 @@ pub fn codegen(app: &App, analysis: &Analysis) -> TokenStream2 {
|
|||
let call_idle = if let Some(idle) = &app.idle {
|
||||
let name = &idle.name;
|
||||
quote!(#name(#name::Context::new()))
|
||||
} else if analysis.channels.get(&0).is_some() {
|
||||
let dispatcher = util::zero_prio_dispatcher_ident();
|
||||
quote!(#dispatcher();)
|
||||
} else {
|
||||
if analysis.channels.get(&0).is_some() {
|
||||
let dispatcher = util::zero_prio_dispatcher_ident();
|
||||
quote!(#dispatcher();)
|
||||
} else {
|
||||
quote!(loop {
|
||||
rtic::export::nop()
|
||||
})
|
||||
}
|
||||
quote!(loop {
|
||||
rtic::export::nop()
|
||||
})
|
||||
};
|
||||
|
||||
let main = util::suffixed("main");
|
||||
|
|
|
@ -40,8 +40,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
|||
}
|
||||
})) {
|
||||
let es = format!(
|
||||
"Maximum priority used by interrupt vector '{}' is more than supported by hardware",
|
||||
name
|
||||
"Maximum priority used by interrupt vector '{name}' is more than supported by hardware"
|
||||
);
|
||||
// Compile time assert that this priority is supported by the device
|
||||
stmts.push(quote!(
|
||||
|
@ -69,8 +68,7 @@ pub fn codegen(app: &App, analysis: &Analysis) -> Vec<TokenStream2> {
|
|||
}
|
||||
}) {
|
||||
let es = format!(
|
||||
"Maximum priority used by interrupt vector '{}' is more than supported by hardware",
|
||||
name
|
||||
"Maximum priority used by interrupt vector '{name}' is more than supported by hardware"
|
||||
);
|
||||
// Compile time assert that this priority is supported by the device
|
||||
stmts.push(quote!(
|
||||
|
|
|
@ -51,7 +51,7 @@ pub fn impl_mutex(
|
|||
|
||||
/// Generates an identifier for the `EXECUTOR_RUN` atomics (`async` API)
|
||||
pub fn executor_run_ident(task: &Ident) -> Ident {
|
||||
mark_internal_name(&format!("{}_EXECUTOR_RUN", task))
|
||||
mark_internal_name(&format!("{task}_EXECUTOR_RUN"))
|
||||
}
|
||||
|
||||
pub fn interrupt_ident() -> Ident {
|
||||
|
@ -78,12 +78,12 @@ pub fn is_exception(name: &Ident) -> bool {
|
|||
|
||||
/// Mark a name as internal
|
||||
pub fn mark_internal_name(name: &str) -> Ident {
|
||||
Ident::new(&format!("{}_{}", RTIC_INTERNAL, name), Span::call_site())
|
||||
Ident::new(&format!("{RTIC_INTERNAL}_{name}"), Span::call_site())
|
||||
}
|
||||
|
||||
/// Generate an internal identifier for tasks
|
||||
pub fn internal_task_ident(task: &Ident, ident_name: &str) -> Ident {
|
||||
mark_internal_name(&format!("{}_{}", task, ident_name))
|
||||
mark_internal_name(&format!("{task}_{ident_name}"))
|
||||
}
|
||||
|
||||
fn link_section_index() -> usize {
|
||||
|
@ -153,7 +153,7 @@ pub fn local_resources_ident(ctxt: Context, app: &App) -> Ident {
|
|||
|
||||
/// Generates an identifier for a ready queue, async task version
|
||||
pub fn rq_async_ident(async_task_name: &Ident) -> Ident {
|
||||
mark_internal_name(&format!("ASYNC_TASK_{}_RQ", async_task_name))
|
||||
mark_internal_name(&format!("ASYNC_TASK_{async_task_name}_RQ"))
|
||||
}
|
||||
|
||||
/// Suffixed identifier
|
||||
|
@ -163,7 +163,7 @@ pub fn suffixed(name: &str) -> Ident {
|
|||
}
|
||||
|
||||
pub fn static_shared_resource_ident(name: &Ident) -> Ident {
|
||||
mark_internal_name(&format!("shared_resource_{}", name))
|
||||
mark_internal_name(&format!("shared_resource_{name}"))
|
||||
}
|
||||
|
||||
/// Generates an Ident for the number of 32 bit chunks used for Mask storage.
|
||||
|
@ -176,15 +176,15 @@ pub fn priority_masks_ident() -> Ident {
|
|||
}
|
||||
|
||||
pub fn static_local_resource_ident(name: &Ident) -> Ident {
|
||||
mark_internal_name(&format!("local_resource_{}", name))
|
||||
mark_internal_name(&format!("local_resource_{name}"))
|
||||
}
|
||||
|
||||
pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident {
|
||||
mark_internal_name(&format!("local_{}_{}", task_name, name))
|
||||
mark_internal_name(&format!("local_{task_name}_{name}"))
|
||||
}
|
||||
|
||||
pub fn need_to_lock_ident(name: &Ident) -> Ident {
|
||||
Ident::new(&format!("{}_that_needs_to_be_locked", name), name.span())
|
||||
Ident::new(&format!("{name}_that_needs_to_be_locked"), name.span())
|
||||
}
|
||||
|
||||
pub fn zero_prio_dispatcher_ident() -> Ident {
|
||||
|
|
|
@ -39,9 +39,8 @@ pub fn app(args: TokenStream, input: TokenStream) -> TokenStream {
|
|||
Ok(x) => x,
|
||||
};
|
||||
|
||||
match check::app(&app) {
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
_ => {}
|
||||
if let Err(e) = check::app(&app) {
|
||||
return e.to_compile_error().into();
|
||||
}
|
||||
|
||||
let analysis = analyze::app(analysis, &app);
|
||||
|
@ -86,7 +85,7 @@ pub fn app(args: TokenStream, input: TokenStream) -> TokenStream {
|
|||
|
||||
// Try to write the expanded code to disk
|
||||
if let Some(out_str) = out_dir.to_str() {
|
||||
fs::write(format!("{}/rtic-expansion.rs", out_str), ts.to_string()).ok();
|
||||
fs::write(format!("{out_str}/rtic-expansion.rs"), ts.to_string()).ok();
|
||||
}
|
||||
|
||||
ts.into()
|
||||
|
|
|
@ -450,8 +450,7 @@ impl App {
|
|||
return Err(parse::Error::new(
|
||||
init.user_shared_struct.span(),
|
||||
format!(
|
||||
"This name and the one defined on `#[shared]` are not the same. Should this be `{}`?",
|
||||
shared_resources_ident
|
||||
"This name and the one defined on `#[shared]` are not the same. Should this be `{shared_resources_ident}`?"
|
||||
),
|
||||
));
|
||||
}
|
||||
|
@ -460,8 +459,7 @@ impl App {
|
|||
return Err(parse::Error::new(
|
||||
init.user_local_struct.span(),
|
||||
format!(
|
||||
"This name and the one defined on `#[local]` are not the same. Should this be `{}`?",
|
||||
local_resources_ident
|
||||
"This name and the one defined on `#[local]` are not the same. Should this be `{local_resources_ident}`?"
|
||||
),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -39,9 +39,8 @@ impl HardwareTask {
|
|||
|
||||
Err(parse::Error::new(
|
||||
span,
|
||||
&format!(
|
||||
"this task handler must have type signature `fn({}::Context)`",
|
||||
name
|
||||
format!(
|
||||
"this task handler must have type signature `fn({name}::Context)`"
|
||||
),
|
||||
))
|
||||
}
|
||||
|
@ -83,9 +82,8 @@ impl HardwareTask {
|
|||
|
||||
Err(parse::Error::new(
|
||||
span,
|
||||
&format!(
|
||||
"this task handler must have type signature `fn({}::Context)`",
|
||||
name
|
||||
format!(
|
||||
"this task handler must have type signature `fn({name}::Context)`"
|
||||
),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -34,9 +34,8 @@ impl Idle {
|
|||
|
||||
Err(parse::Error::new(
|
||||
item.sig.ident.span(),
|
||||
&format!(
|
||||
"this `#[idle]` function must have signature `fn({}::Context) -> !`",
|
||||
name
|
||||
format!(
|
||||
"this `#[idle]` function must have signature `fn({name}::Context) -> !`"
|
||||
),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -41,9 +41,8 @@ impl Init {
|
|||
|
||||
Err(parse::Error::new(
|
||||
span,
|
||||
&format!(
|
||||
"the `#[init]` function must have signature `fn({}::Context) -> (Shared resources struct, Local resources struct)`",
|
||||
name
|
||||
format!(
|
||||
"the `#[init]` function must have signature `fn({name}::Context) -> (Shared resources struct, Local resources struct)`"
|
||||
),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -33,9 +33,8 @@ impl SoftwareTask {
|
|||
|
||||
Err(parse::Error::new(
|
||||
span,
|
||||
&format!(
|
||||
"this task handler must have type signature `async fn({}::Context)`",
|
||||
name
|
||||
format!(
|
||||
"this task handler must have type signature `async fn({name}::Context)`"
|
||||
),
|
||||
))
|
||||
}
|
||||
|
@ -71,9 +70,8 @@ impl SoftwareTask {
|
|||
|
||||
Err(parse::Error::new(
|
||||
span,
|
||||
&format!(
|
||||
"this task handler must have type signature `async fn({}::Context)`",
|
||||
name
|
||||
format!(
|
||||
"this task handler must have type signature `async fn({name}::Context)`"
|
||||
),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -234,17 +234,13 @@ pub fn parse_local_resources(content: ParseStream<'_>) -> parse::Result<LocalRes
|
|||
pub fn parse_inputs(inputs: Punctuated<FnArg, Token![,]>, name: &str) -> Option<Box<Pat>> {
|
||||
let mut inputs = inputs.into_iter();
|
||||
|
||||
match inputs.next() {
|
||||
Some(FnArg::Typed(first)) => {
|
||||
if type_is_path(&first.ty, &[name, "Context"]) {
|
||||
// No more inputs
|
||||
if inputs.next().is_none() {
|
||||
return Some(first.pat);
|
||||
}
|
||||
if let Some(FnArg::Typed(first)) = inputs.next() {
|
||||
if type_is_path(&first.ty, &[name, "Context"]) {
|
||||
// No more inputs
|
||||
if inputs.next().is_none() {
|
||||
return Some(first.pat);
|
||||
}
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
||||
None
|
||||
|
|
|
@ -298,9 +298,9 @@ pub unsafe fn lock<T, R, const M: usize>(
|
|||
if ceiling >= 4 {
|
||||
// safe to manipulate outside critical section
|
||||
// execute closure under protection of raised system ceiling
|
||||
let r = interrupt::free(|_| f(&mut *ptr));
|
||||
|
||||
// safe to manipulate outside critical section
|
||||
r
|
||||
interrupt::free(|_| f(&mut *ptr))
|
||||
} else {
|
||||
// safe to manipulate outside critical section
|
||||
let mask = compute_mask(0, ceiling, masks);
|
||||
|
|
Loading…
Reference in a new issue