<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/rust/pin-init/examples, branch master</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=master</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2026-03-25T09:57:53Z</updated>
<entry>
<title>rust: pin-init: replace `addr_of_mut!` with `&amp;raw mut`</title>
<updated>2026-03-25T09:57:53Z</updated>
<author>
<name>Antonio Hickey</name>
<email>contact@antoniohickey.com</email>
</author>
<published>2026-03-19T09:35:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=09808839c7aa6695ceff5cd822c18b0d9550184d'/>
<id>urn:sha1:09808839c7aa6695ceff5cd822c18b0d9550184d</id>
<content type='text'>
`feature(raw_ref_op)` became stable in Rust 1.82.0 which is the current
MSRV of pin-init with no default features. Earlier Rust versions will
now need to enable `raw_ref_op` to continue to work with pin-init.

This reduces visual complexity and improves consistency with existing
reference syntax.

Suggested-by: Benno Lossin &lt;lossin@kernel.org&gt;
Link: https://github.com/Rust-for-Linux/linux/issues/1148
Closes: https://github.com/Rust-for-Linux/pin-init/issues/99
Signed-off-by: Antonio Hickey &lt;contact@antoniohickey.com&gt;
Link: https://github.com/Rust-for-Linux/pin-init/commit/e27763004e2f6616b089437fbe9b3719cd72bd5c
[ Reworded commit message. - Benno ]
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Link: https://patch.msgid.link/20260319093542.3756606-6-lossin@kernel.org
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: properly document let binding workaround</title>
<updated>2026-03-25T09:56:53Z</updated>
<author>
<name>Benno Lossin</name>
<email>lossin@kernel.org</email>
</author>
<published>2026-03-19T09:35:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=960c37cbcba78730ee175f4887ffcdf523385c53'/>
<id>urn:sha1:960c37cbcba78730ee175f4887ffcdf523385c53</id>
<content type='text'>
The three let bindings (in the bodies of `cast_init`, `cast_pin_init`
and the `init!` macro) are used to avoid the following compiler error in
Rust 1.78.0, 1.79.0, 1.80.0, 1.80.1, and 1.81.0 (just showing the one
for `cast_init`, the others are similar):

    error[E0391]: cycle detected when computing type of opaque `cast_init::{opaque#0}`
        --&gt; src/lib.rs:1160:66
         |
    1160 | pub const unsafe fn cast_init&lt;T, U, E&gt;(init: impl Init&lt;T, E&gt;) -&gt; impl Init&lt;U, E&gt; {
         |                                                                  ^^^^^^^^^^^^^^^
         |
    note: ...which requires borrow-checking `cast_init`...
        --&gt; src/lib.rs:1160:1
         |
    1160 | pub const unsafe fn cast_init&lt;T, U, E&gt;(init: impl Init&lt;T, E&gt;) -&gt; impl Init&lt;U, E&gt; {
         | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    note: ...which requires const checking `cast_init`...
        --&gt; src/lib.rs:1160:1
         |
    1160 | pub const unsafe fn cast_init&lt;T, U, E&gt;(init: impl Init&lt;T, E&gt;) -&gt; impl Init&lt;U, E&gt; {
         | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         = note: ...which requires computing whether `cast_init::{opaque#0}` is freeze...
         = note: ...which requires evaluating trait selection obligation `cast_init::{opaque#0}: core::marker::Freeze`...
         = note: ...which again requires computing type of opaque `cast_init::{opaque#0}`, completing the cycle
    note: cycle used when computing type of `cast_init::{opaque#0}`
        --&gt; src/lib.rs:1160:66
         |
    1160 | pub const unsafe fn cast_init&lt;T, U, E&gt;(init: impl Init&lt;T, E&gt;) -&gt; impl Init&lt;U, E&gt; {
         |                                                                  ^^^^^^^^^^^^^^^
         = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

Once we raise the nightly-MSRV above 1.81, we can remove this
workaround.

Link: https://github.com/Rust-for-Linux/pin-init/commit/bb3e96f3e9a4f5fca80a22af883c7e5aa90f0893
[ Moved this commit after the previous one to avoid a build failure due
  to unstable features. Changed the cfg to use `USE_RUSTC_FEAUTURES`.
  - Benno ]
Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Link: https://patch.msgid.link/20260319093542.3756606-3-lossin@kernel.org
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: build: simplify use of nightly features</title>
<updated>2026-03-25T09:56:16Z</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2026-03-19T09:35:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=002a121b16c3a20c6e0ff24fc8dad6dab59730f9'/>
<id>urn:sha1:002a121b16c3a20c6e0ff24fc8dad6dab59730f9</id>
<content type='text'>
We use some features that are already stable in later versions of Rust,
but only available as unstable features in older Rust versions that the
kernel needs to support.

Instead of checking if a feature is already stable, simply enable them
and allow the warning if the feature is already stable. This avoids the
need of hardcoding whether a feature has been stabilized at a given
version.

`#[feature(...)]` is used when cfg `USE_RUSTC_FEATURES` is enabled. The
build script automatically does this when a nightly compiler is detected
or `RUSTC_BOOTSTRAP` is set.

Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
Link: https://github.com/Rust-for-Linux/pin-init/commit/885c5d83d7eb778a796d4a17380a0898b0d0a571
[ Added kernel build system changes to always enable USE_RUSTC_FEATURES.
  Moved this commit earlier (swapped with the next one) to avoid a build
  error. - Benno ]
Link: https://patch.msgid.link/20260319093542.3756606-2-lossin@kernel.org
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: remove `try_` versions of the initializer macros</title>
<updated>2026-01-17T09:49:31Z</updated>
<author>
<name>Benno Lossin</name>
<email>lossin@kernel.org</email>
</author>
<published>2026-01-16T10:54:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=61d62ab08f0e62f89929f3920c0b6521d849fd57'/>
<id>urn:sha1:61d62ab08f0e62f89929f3920c0b6521d849fd57</id>
<content type='text'>
The `try_[pin_]init!` versions of the initializer macros are
superfluous. Instead of forcing the user to always write an error in
`try_[pin_]init!` and not allowing one in `[pin_]init!`, combine them
into `[pin_]init!` that defaults the error to
`core::convert::Infallible`, but also allows to specify a custom one.

Projects using pin-init still can provide their own defaulting
initializers using the `try_` prefix by using the `#[default_error]`
attribute added in a future patch.

[ Adjust the definition of the kernel's version of the `try_`
  initializer macros - Benno]

Reviewed-by: Gary Guo &lt;gary@garyguo.net&gt;
Tested-by: Andreas Hindborg &lt;a.hindborg@kernel.org&gt;
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: examples: error: use `Error` in `fn main()`</title>
<updated>2025-09-11T21:25:54Z</updated>
<author>
<name>Benno Lossin</name>
<email>lossin@kernel.org</email>
</author>
<published>2025-08-18T13:18:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3d536277449e4de4609d4f0b8302ae7fd00b04b2'/>
<id>urn:sha1:3d536277449e4de4609d4f0b8302ae7fd00b04b2</id>
<content type='text'>
When running this example with no cargo features enabled, the compiler
warns on 1.89:

  error: struct `Error` is never constructed
    --&gt; 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 &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: examples, tests: use `ignore` instead of conditionally compiling tests</title>
<updated>2025-06-11T19:13:57Z</updated>
<author>
<name>Benno Lossin</name>
<email>lossin@kernel.org</email>
</author>
<published>2025-06-05T15:52:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fc3870dc5cadb701b4122e4a8daa85f9fa2f57b9'/>
<id>urn:sha1:fc3870dc5cadb701b4122e4a8daa85f9fa2f57b9</id>
<content type='text'>
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 &lt;aliceryhl@google.com&gt;
Link: https://lore.kernel.org/all/aDC9y829vZZBzZ2p@google.com
Link: https://github.com/Rust-for-Linux/pin-init/pull/58/commits/b004dd8e64d4cbe219a4eff0d25f0a5f5bc750ca
Reviewed-by: Christian Schrefl &lt;chrisi.schrefl@gmail.com&gt;
Link: https://lore.kernel.org/all/20250605155258.573391-1-lossin@kernel.org
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: rename `zeroed` to `init_zeroed`</title>
<updated>2025-06-11T19:13:56Z</updated>
<author>
<name>Benno Lossin</name>
<email>lossin@kernel.org</email>
</author>
<published>2025-05-23T14:50:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=101b7cf006d4b4b98652bd15dc36e63ede8f8ad8'/>
<id>urn:sha1:101b7cf006d4b4b98652bd15dc36e63ede8f8ad8</id>
<content type='text'>
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/20250523145125.523275-2-lossin@kernel.org
[ 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 &lt;a.hindborg@kernel.org&gt;
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: examples: pthread_mutex: disable the main test for miri</title>
<updated>2025-06-11T19:13:56Z</updated>
<author>
<name>Benno Lossin</name>
<email>benno.lossin@proton.me</email>
</author>
<published>2025-05-23T12:54:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2408678d700c4db6c54749a272d42a964f5f3418'/>
<id>urn:sha1:2408678d700c4db6c54749a272d42a964f5f3418</id>
<content type='text'>
`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/20250523125424.192843-3-lossin@kernel.org
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: examples, tests: add conditional compilation in order to compile under any feature combination</title>
<updated>2025-06-11T19:13:56Z</updated>
<author>
<name>Benno Lossin</name>
<email>benno.lossin@proton.me</email>
</author>
<published>2025-05-23T12:54:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=58cebd68882edd407c7f65ebb4a42034bc1ffc6d'/>
<id>urn:sha1:58cebd68882edd407c7f65ebb4a42034bc1ffc6d</id>
<content type='text'>
In the CI, all examples &amp; tests should be run under all feature
combinations. Currently several examples &amp; 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/20250523125424.192843-2-lossin@kernel.org
Signed-off-by: Benno Lossin &lt;lossin@kernel.org&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: examples: use `allow` instead of `expect`</title>
<updated>2025-04-21T21:19:22Z</updated>
<author>
<name>Benno Lossin</name>
<email>benno.lossin@proton.me</email>
</author>
<published>2025-04-14T20:00:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=39051adb070432b283e6c11b2b24937281b9f97f'/>
<id>urn:sha1:39051adb070432b283e6c11b2b24937281b9f97f</id>
<content type='text'>
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/20250414195928.129040-4-benno.lossin@proton.me
Signed-off-by: Benno Lossin &lt;benno.lossin@proton.me&gt;
</content>
</entry>
</feed>
