Benno Lossin
3d53627744
rust: pin-init: examples: error: use Error in fn main()
...
When running this example with no cargo features enabled, the compiler
warns on 1.89:
error: struct `Error` is never constructed
--> examples/error.rs:11:12
|
11 | pub struct Error;
| ^^^^^
|
= note: `-D dead-code` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(dead_code)]`
Thus use the error in the main function to avoid this warning.
Signed-off-by: Benno Lossin <[email protected] >
2025-09-11 23:25:54 +02:00
Benno Lossin
fc3870dc5c
rust: pin-init: examples, tests: use ignore instead of conditionally compiling tests
...
Change `#[cfg(cond)]` to `#[cfg_attr(not(cond), ignore)]` on tests.
Ignoring tests instead of disabling them still makes them appear in the
test list, but with `ignored`. It also still compiles the code in those
cases.
Some tests still need to be ignore, because they use types that are not
present when the condition is false. For example the condition is
`feature = std` and then it uses `std::thread::Thread`.
Suggested-by: Alice Ryhl <[email protected] >
Link: https://lore.kernel.org/all/[email protected]
Link: https://github.com/Rust-for-Linux/pin-init/pull/58/commits/b004dd8e64d4cbe219a4eff0d25f0a5f5bc750ca
Reviewed-by: Christian Schrefl <[email protected] >
Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Benno Lossin <[email protected] >
2025-06-11 21:13:57 +02:00
Benno Lossin
101b7cf006
rust: pin-init: rename zeroed to init_zeroed
...
The name `zeroed` is a much better fit for a function that returns the
type by-value.
Link: https://github.com/Rust-for-Linux/pin-init/pull/56/commits/7dbe38682c9725405bab91dcabe9c4d8893d2f5e
[ also rename uses in `rust/kernel/init.rs` - Benno]
Link: https://lore.kernel.org/all/[email protected]
[ Fix wrong replacement of `mem::zeroed` in the definition of `trait
Zeroable`. - Benno ]
[ Also change occurrences of `zeroed` in `configfs.rs` - Benno ]
Acked-by: Andreas Hindborg <[email protected] >
Signed-off-by: Benno Lossin <[email protected] >
2025-06-11 21:13:56 +02:00
Benno Lossin
2408678d70
rust: pin-init: examples: pthread_mutex: disable the main test for miri
...
`miri` takes a long time to execute the test, so disable it.
Link: https://github.com/Rust-for-Linux/pin-init/pull/50/commits/e717a9eec85024c11e79e8bd9dcb664ad0de8f94
Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Benno Lossin <[email protected] >
2025-06-11 21:13:56 +02:00
Benno Lossin
58cebd6888
rust: pin-init: examples, tests: add conditional compilation in order to compile under any feature combination
...
In the CI, all examples & tests should be run under all feature
combinations. Currently several examples & tests use `std` without
conditionally enabling it. Thus make them all compile under any feature
combination by conditionally disabling the code that uses e.g. `std`.
Link: https://github.com/Rust-for-Linux/pin-init/pull/50/commits/fdfb70efddbc711b4543c850ee38a2f5a8d17cb6
Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Benno Lossin <[email protected] >
2025-06-11 21:13:56 +02:00
Benno Lossin
39051adb07
rust: pin-init: examples: use allow instead of expect
...
Rust 1.78 doesn't emit a `dead_code` error on the annotated element,
resulting in the `unfulfilled_lint_expectations` error. Rust 1.85 does
emit the `dead_code` error, so we still need an `allow`.
Link: https://github.com/Rust-for-Linux/pin-init/pull/33/commits/0e28cbb895bd29f896a59b40e8ed506ea7bef13c
Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Benno Lossin <[email protected] >
2025-04-21 23:19:22 +02:00
Benno Lossin
5c4167b405
rust: pin-init: examples: conditionally enable feature(lint_reasons)
...
`lint_reasons` is unstable in Rust 1.80 and earlier, enable it
conditionally in the examples to allow compiling them with older
compilers.
Link: https://github.com/Rust-for-Linux/pin-init/pull/33/commits/ec494fe686b0a97d5b59b5be5a42d3858038ea6a
Link: https://lore.kernel.org/all/[email protected]
Signed-off-by: Benno Lossin <[email protected] >
2025-04-21 23:19:12 +02:00
Miguel Ojeda
193b5a7574
rust: pin-init: use Markdown autolinks in Rust comments
...
"Normal" comments in Rust (`//`) are also formatted in Markdown, like
the documentation (`///` and `//!`), see
Documentation/rust/coding-guidelines.rst
Thus use Markdown autolinks for a couple links that were missing it.
It also helps to get proper linking in some software like kitty [1].
Suggested-by: Benno Lossin <[email protected] >
Link: https://github.com/Rust-for-Linux/pin-init/pull/32#discussion_r2023103712 [1]
Signed-off-by: Miguel Ojeda <[email protected] >
Link: https://github.com/Rust-for-Linux/pin-init/pull/32/commits/dd230d61bf0538281072fbff4bb71efc58f3420c
Fixes: 84837cf6fa ("rust: pin-init: change examples to the user-space version")
Cc: [email protected]
[ Change case in title. Reworded commit message. - Benno ]
Signed-off-by: Benno Lossin <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected] >
2025-04-08 21:12:58 +02:00
Benno Lossin
84837cf6fa
rust: pin-init: change examples to the user-space version
...
Replace the examples in the documentation by the ones from the
user-space version and introduce the standalone examples from the
user-space version such as the `CMutex<T>` type.
The `CMutex<T>` example from the pinned-init repository [1] is used in
several documentation examples in the user-space version instead of the
kernel `Mutex<T>` type (as it's not available). In order to split off
the pin-init crate, all examples need to be free of kernel-specific
types.
Link: https://github.com/rust-for-Linux/pinned-init [1]
Signed-off-by: Benno Lossin <[email protected] >
Reviewed-by: Fiona Behrens <[email protected] >
Tested-by: Andreas Hindborg <[email protected] >
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected] >
2025-03-16 21:59:18 +01:00