Messages in this thread | | | Date | Mon, 27 Feb 2023 10:59:10 -0300 | Subject | Re: [PATCH 5/5] rust: error: Add from_kernel_result!() macro | From | Martin Rodriguez Reboredo <> |
| |
On 2/26/23 17:59, Miguel Ojeda wrote: > On Sun, Feb 26, 2023 at 7:17 PM Boqun Feng <boqun.feng@gmail.com> wrote: >> >> My preference to function instead of macro here is because I want to >> avoid the extra level of abstraction and make things explict, so that >> users and reviewers can understand the API behavior solely based on >> Rust's types, functions and closures: they are simpler than macros, at >> least to me ;-) > > There is one extra problem with the macro: `rustfmt` does not format > the contents if called with braces (as we currently do). > > So when I was cleaning some things up for v8, one of the things I did > was run manually `rustfmt` on the blocks by removing the macro > invocation, in commit 77a1a8c952e1 ("rust: kernel: apply `rustfmt` to > `from_kernel_result!` blocks"). > > Having said that, it does format it when called with parenthesis > wrapping the block, so we could do that if we end up with the macro.
Also rust-analyzer can't analyze the insides of a from_kernel_result! block. Only thing it can do is to suggest a macro expansion. Plus, this macro triggers a clippy lint on a redundant call on a closure. So it's a bit annoying to work with.
| |