[PATCH v4 0/3] rust: add kunit doctest with doc fixes

Jimmy Ostler posted 3 patches 12 months ago
rust/kernel/alloc/layout.rs | 19 +++++++++++++++++++
rust/kernel/error.rs        |  7 ++++---
rust/kernel/init.rs         | 22 ++++++++++++++++++----
3 files changed, 41 insertions(+), 7 deletions(-)
[PATCH v4 0/3] rust: add kunit doctest with doc fixes
Posted by Jimmy Ostler 12 months ago
This patch series adds a doctest for the `ArrayLayout` type, as well as
implements `From<LayoutError> for Error` for the internal `LayoutError`.
This change in the first patch is required for the added rustdoc kunit
test in the third patch to compile.

This series also adds a change to the `stack_try_pin_init` example
documentation, so it correctly imports the `AllocError` kernel type.

Link: https://lore.kernel.org/lkml/20241203051843.291729-1-jtostler1@gmail.com/ [v1]
Link: https://lore.kernel.org/lkml/20241205105627.992587-1-jtostler1@gmail.com/ [v2]
Link: https://lore.kernel.org/lkml/cover.1734477232.git.jtostler1@gmail.com/    [v3]
Signed-off-by: Jimmy Ostler <jtostler1@gmail.com>
---
v3 -> v4: Reword patch one message for clarity
v2 -> v3:
- Remove `From` implementation on `core::alloc::LayoutError`
- Move changes to "rust/kernel/alloc/layout.rs" to separate patch
- Move changes to "rust/kernel/error.rs" to separate patch
- Change documentation in "rust/kernel/init.rs"
- Link [v2]: https://lore.kernel.org/lkml/20241205105627.992587-1-jtostler1@gmail.com/

v1 -> v2 changes:
- Add third assert where length is smaller but still overflows
- Remove rustdoc markdown codeblock languge signifier
- Change tests to return results using `?` instead of panic
- Remove `#[derive(Debug)]` for `LayoutError`
- Add `From<LayoutError> for Error` implementation
- Link [v1]: https://lore.kernel.org/lkml/20241203051843.291729-1-jtostler1@gmail.com/

Jimmy Ostler (3):
  rust: error: Change `LayoutError` to internal
  rust: error: Update 'stack_try_pin_init' example
  rust: alloc: Add doctest for `ArrayLayout`

 rust/kernel/alloc/layout.rs | 19 +++++++++++++++++++
 rust/kernel/error.rs        |  7 ++++---
 rust/kernel/init.rs         | 22 ++++++++++++++++++----
 3 files changed, 41 insertions(+), 7 deletions(-)


base-commit: 0c5928deada15a8d075516e6e0d9ee19011bb000
-- 
2.47.1
Re: [PATCH v4 0/3] rust: add kunit doctest with doc fixes
Posted by Miguel Ojeda 11 months, 1 week ago
On Fri, Dec 20, 2024 at 7:25 AM Jimmy Ostler <jtostler1@gmail.com> wrote:
>
> This patch series adds a doctest for the `ArrayLayout` type, as well as
> implements `From<LayoutError> for Error` for the internal `LayoutError`.
> This change in the first patch is required for the added rustdoc kunit
> test in the third patch to compile.
>
> This series also adds a change to the `stack_try_pin_init` example
> documentation, so it correctly imports the `AllocError` kernel type.

Applied to `rust-next` -- thanks everyone!

    [ Reworded commit. - Miguel ]

    [ Fixed formatting of imports (still unordered). Slightly reworded
      commit. - Miguel ]

    [ Added periods to example comments. Reworded title. - Miguel ]

Jimmy: I tried to improve the wording a bit more on the first patch
following our discussions, to try to be clearer/explicit, but please
let me know if I made a mistake or you disagree. Thanks!

Cheers,
Miguel