<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/git/next/linux-next.git/rust/pin-init/internal, branch master</title>
<subtitle>The linux-next integration testing tree</subtitle>
<id>https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/atom?h=master</id>
<link rel='self' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/'/>
<updated>2026-09-14T00:37:02+00:00</updated>
<entry>
<title>rust: pin-init: internal: init: support tuple struct constructor syntax</title>
<updated>2026-09-14T00:37:02+00:00</updated>
<author>
<name>Mohamad Alsadhan</name>
<email>mo@sdhn.cc</email>
</author>
<published>2026-09-04T14:12:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=3b3ff9034a497fb3b8429f6fe8ba5697bc7dcebd'/>
<id>urn:sha1:3b3ff9034a497fb3b8429f6fe8ba5697bc7dcebd</id>
<content type='text'>
A tuple struct whose fields are all set to a value reads better written
like a call to its constructor than with the indices spelled out:

    pin_init!(Foo(value, value))

Parse the two forms into separate types and rewrite the constructor
arguments into the indexed fields they are shorthand for, so that only the
parser has to know about the second form.

The arguments have no names, so they cannot use `&lt;-`. Parse it anyway and
reject it afterwards, which reports the position of every offending `&lt;-`
rather than stopping at the first one.

`cfg` needs different treatment for tuple constructor syntax. As non-derive
proc macros are invoked before cfg is resolved, the macro cannot know
whether a field survives, and dropping a tuple field renumbers every field
after it. That cannot be expressed by attaching a `cfg` attribute to the
initializer of a single field. Thus, resolve tuple field cfgs up front
instead, by generating two cfg-gated invocations of the macro with one
field resolved in each. This is the approach of commit 5bbf2b2deb94 ("rust:
pin-init: internal: rework how `#[pin_data]` handles cfg"), and it is
linear time because only one of the two branches is ever expanded. Struct
expression syntax do not renumber, so using tuple structs with struct
syntax can keep using the existing attribute-based handling.

Suggested-by: Gary Guo &lt;gary@garyguo.net&gt;
Link: https://github.com/Rust-for-Linux/pin-init/pull/165
Signed-off-by: Mohamad Alsadhan &lt;mo@sdhn.cc&gt;
[ Pre-expand cfgs for tuple init syntax. Use generics instead of separate
  types for normalization - Gary ]
Co-developed-by: Gary Guo &lt;gary@garyguo.net&gt;
Link: https://patch.msgid.link/20260904-tuple-struct-v1-4-72c50bd037fd@garyguo.net
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: internal: init: support tuple structs in `[pin_]init!`</title>
<updated>2026-09-14T00:36:05+00:00</updated>
<author>
<name>Mohamad Alsadhan</name>
<email>mo@sdhn.cc</email>
</author>
<published>2026-09-04T14:12:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=d48aa955cb91745ef2e5089f9277a7a95060cce3'/>
<id>urn:sha1:d48aa955cb91745ef2e5089f9277a7a95060cce3</id>
<content type='text'>
Extend the initializer syntax so that a field can be named by an index,
addressing tuple struct fields the same way a struct expression does:

    pin_init!(Foo { 0: value, 1 &lt;- initializer })

Tuple fields are not exposed by a `let` binding to the fields after them,
since they have no name to bind; `_0` would shadow a user variable.

Signed-off-by: Mohamad Alsadhan &lt;mo@sdhn.cc&gt;
[ Fixed incorrect index calculation and cleaned up the code - Gary ]
Link: https://patch.msgid.link/20260904-tuple-struct-v1-3-72c50bd037fd@garyguo.net
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: internal: pin_data: support tuple struct projections</title>
<updated>2026-09-14T00:36:05+00:00</updated>
<author>
<name>Mohamad Alsadhan</name>
<email>mo@sdhn.cc</email>
</author>
<published>2026-09-04T14:12:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=1ee699c4516607c0b594813c9c81da4285ed7d56'/>
<id>urn:sha1:1ee699c4516607c0b594813c9c81da4285ed7d56</id>
<content type='text'>
`#[pin_data]` rejects tuple structs because it assumes every field has a
name, which it uses for the projection field, the `__Unpin` field and the
pin-data accessor.

Identify fields by `syn::Member` instead, so that tuple fields are referred
to by their index in generated field accesses. The names that generated
items still need are derived from the index as `_0`, `_1`, etc.

The projection of a tuple struct is a tuple struct itself, so projected
fields are accessed with the same `.0`, `.1` syntax as on the input
type rather than through synthesised names.

Signed-off-by: Mohamad Alsadhan &lt;mo@sdhn.cc&gt;
[ Moved utility code to util.rs as extension trait - Gary ]
Link: https://patch.msgid.link/20260904-tuple-struct-v1-2-72c50bd037fd@garyguo.net
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: internal: extract utility code to new module</title>
<updated>2026-09-14T00:36:05+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2026-09-04T14:12:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c2bc9bd605add0b9f1f3b7e93b649bd814de226a'/>
<id>urn:sha1:c2bc9bd605add0b9f1f3b7e93b649bd814de226a</id>
<content type='text'>
Create a new `util.rs` to host utility code that are generic and can be
shared by multiple macros.

Link: https://patch.msgid.link/20260904-tuple-struct-v1-1-72c50bd037fd@garyguo.net
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: add `#[inline]` to small functions</title>
<updated>2026-08-05T10:36:18+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2026-08-03T13:02:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=1e26aea0355ad2afa1ccbc62885c01f5bcfc58ca'/>
<id>urn:sha1:1e26aea0355ad2afa1ccbc62885c01f5bcfc58ca</id>
<content type='text'>
Currently `pin-init` crate is missing many inline annotations. They are all
generic so still get inlined in normal builds, but are not inlined in
`-C opt-level=s` build. Mark these functions as `#[inline]` so they are
considered for inlining regardless.

Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: internal: rework how `#[pin_data]` handles cfg</title>
<updated>2026-07-27T10:52:08+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2026-07-23T18:19:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=5bbf2b2deb94d0ef8324866d39cb5e0947ca5068'/>
<id>urn:sha1:5bbf2b2deb94d0ef8324866d39cb5e0947ca5068</id>
<content type='text'>
Attribute macros are invoked without cfg being resolved. This adds quite a
bit complexity to the macro because all of the macro needs to be careful to
attach necessary cfgs. This becomes especially tricky for tuple structs.
Thus, it is convenient if cfgs are all resolved like derive macros.

The most optimal way to handle this is via `TokenStream::expand_expr`, but
that is still unstable. We can also create an internal derive macro and
transform the attribute macro invocation to be derive macro, but doing
requires us to serialize all extracted information in a form of helper
attributes; it would also make it more difficult if we want to make changes
to the struct (which the self-reference feature would need).

Implement an approach where we generate two cfg-gated macro invocations
with cfg resolved within the invocation. This would mean when the loop
falls through, all field cfgs are resolved, so remove all handling of
cfg_attrs for the rest of the macro.

Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: internal: generate brace in macro for init code blocks</title>
<updated>2026-07-13T11:11:01+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2026-07-10T16:20:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=751ecd5a19cf2c55807bf30f35bafc32e179a19c'/>
<id>urn:sha1:751ecd5a19cf2c55807bf30f35bafc32e179a19c</id>
<content type='text'>
`init!` support interleaving code execution and initialization, and code
execution is done using `_: { ... }` syntax. If the code inside block is a
single statement, Rust may add a lint about unused braces, but the
suggestion will be incorrect as block is required by pin-init.

Currently we use `unused_brace` to suppress this, but this affect
everything nested inside as well. Use an alternative approach by generating
the block from the macro, then rustc will know to not emit the lint.

Reviewed-by: Benno Lossin &lt;lossin@kernel.org&gt;
Link: https://patch.msgid.link/20260710-pin-init-sync-v1-5-8fa16cde87ae@garyguo.net
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: internal: remove `allow` and `expect`s that don't fire</title>
<updated>2026-07-13T11:10:05+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2026-07-10T16:20:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=c1722ae6fefe3723f31656172f4bc196225506dc'/>
<id>urn:sha1:c1722ae6fefe3723f31656172f4bc196225506dc</id>
<content type='text'>
Most warnings are suppressed from external macro expansions by default.
Thus remove `allow` and `expect`s for them.

Note that `unfulfilled_lint_expectations` is one of them too. This means
that all of our `expect`s inside macros do nothing, and actually mislead
people to the lints would be actually emitted without them.

Reviewed-by: Benno Lossin &lt;lossin@kernel.org&gt;
Link: https://patch.msgid.link/20260710-pin-init-sync-v1-4-8fa16cde87ae@garyguo.net
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin-init: internal: error on duplicate `#[pin]` attribute</title>
<updated>2026-07-13T11:08:46+00:00</updated>
<author>
<name>Luiz Georg</name>
<email>luizgngeorg@gmail.com</email>
</author>
<published>2026-07-10T16:20:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f26f2f22c6d16d6019fbd1248681e57a1a533bd3'/>
<id>urn:sha1:f26f2f22c6d16d6019fbd1248681e57a1a533bd3</id>
<content type='text'>
Duplicated `#[pin]` has no effect, thus error if misused.

Reported-by: Mohamad Alsadhan &lt;mo@sdhn.cc&gt;
Closes: https://github.com/Rust-for-Linux/pin-init/issues/119
Signed-off-by: Luiz Georg &lt;luizgngeorg@gmail.com&gt;
Link: https://patch.msgid.link/20260710-pin-init-sync-v1-1-8fa16cde87ae@garyguo.net
[ Reworded commit message, and change the logic so code generation still
  continue after reporting error - Gary ]
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
<entry>
<title>rust: pin_init: internal: use `loop {}` to produce never value</title>
<updated>2026-05-29T20:58:36+00:00</updated>
<author>
<name>Gary Guo</name>
<email>gary@garyguo.net</email>
</author>
<published>2026-05-08T15:29:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rulkc.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=d2f309227952e73966682f348161094e40eb6440'/>
<id>urn:sha1:d2f309227952e73966682f348161094e40eb6440</id>
<content type='text'>
In the `init!`/`pin_init!` macros, we rely on a trick that assigns never
(`!`) values to all mentioned fields in never-executed code to let the
compiler check that all fields have been initialized.

Currently we use `::core::panic!()` to produce this value, but before Rust
1.91.0, it creates outlined `panic_cold_explicit` functions which do not
get removed by the optimizer, thus leaving dead code behind in the binary.
This has been fixed by [1], which lands in Rust 1.91.0+, higher than the
kernel minimum version 1.85.0.

This causes ~200 dead `panic_cold_explicit` instances being included in the
binary, with ~90 of them from nova-core's usage of pin-init.

Work around the issue by using `loop {}` which creates the never value
without macro expansion or function call at all. All instances of
`panic_cold_explicit` outside libcore are removed by this change in my
kernel build.

Link: https://github.com/rust-lang/rust/pull/145304 [1]
Link: https://patch.msgid.link/20260508152950.833635-1-gary@kernel.org
Signed-off-by: Gary Guo &lt;gary@garyguo.net&gt;
</content>
</entry>
</feed>
