<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/scripts/generate_rust_analyzer.py, branch v7.1-rc2</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>rust: support overriding crate_name</title>
<updated>2026-04-03T09:57:35+00:00</updated>
<author>
<name>Alice Ryhl</name>
<email>aliceryhl@google.com</email>
</author>
<published>2026-04-02T10:55:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=7e9535ebd05d7e8de155164b7c97a370d4646e06'/>
<id>7e9535ebd05d7e8de155164b7c97a370d4646e06</id>
<content type='text'>
Currently you cannot filter out the crate-name argument
RUSTFLAGS_REMOVE_stem.o because the Rust filter-out invocation does not
include that particular argument. Since --crate-name is an argument that
can't be passed multiple times, this means that it's currently not
possible to override the crate name. Thus, remove the --crate-name
argument for drivers. This allows them to override the crate name using
the #![crate_name] annotation.

This affects symbol names, but has no effect on the filenames of object
files and other things generated by the build, as we always use --emit
with a fixed output filename.

The --crate-name argument is kept for the crates under rust/ for
simplicity and to avoid changing many of them by adding #![crate_name].

The rust analyzer script is updated to use rustc to obtain the crate
name of the driver crates, which picks up the right name whether it is
configured via #![crate_name] or not. For readability, the logic to
invoke 'rustc' is extracted to its own function.

Note that the crate name in the python script is not actually that
important - the only place where the name actually affects anything is
in the 'deps' array which specifies an index and name for each
dependency, and determines what that dependency is called in *this*
crate. (The same crate may be called different things in each
dependency.) Since driver crates are leaf crates, this doesn't apply and
the rustc invocation only affects the 'display_name' parameter.

Acked-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Jesung Yang &lt;y.jems.n@gmail.com&gt;
Acked-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
Link: https://patch.msgid.link/20260402-binder-crate-name-v4-1-ec3919b87909@google.com
[ Applied Python type hints. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently you cannot filter out the crate-name argument
RUSTFLAGS_REMOVE_stem.o because the Rust filter-out invocation does not
include that particular argument. Since --crate-name is an argument that
can't be passed multiple times, this means that it's currently not
possible to override the crate name. Thus, remove the --crate-name
argument for drivers. This allows them to override the crate name using
the #![crate_name] annotation.

This affects symbol names, but has no effect on the filenames of object
files and other things generated by the build, as we always use --emit
with a fixed output filename.

The --crate-name argument is kept for the crates under rust/ for
simplicity and to avoid changing many of them by adding #![crate_name].

The rust analyzer script is updated to use rustc to obtain the crate
name of the driver crates, which picks up the right name whether it is
configured via #![crate_name] or not. For readability, the logic to
invoke 'rustc' is extracted to its own function.

Note that the crate name in the python script is not actually that
important - the only place where the name actually affects anything is
in the 'deps' array which specifies an index and name for each
dependency, and determines what that dependency is called in *this*
crate. (The same crate may be called different things in each
dependency.) Since driver crates are leaf crates, this doesn't apply and
the rustc invocation only affects the 'display_name' parameter.

Acked-by: Gary Guo &lt;gary@garyguo.net&gt;
Signed-off-by: Alice Ryhl &lt;aliceryhl@google.com&gt;
Reviewed-by: Jesung Yang &lt;y.jems.n@gmail.com&gt;
Acked-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
Link: https://patch.msgid.link/20260402-binder-crate-name-v4-1-ec3919b87909@google.com
[ Applied Python type hints. - Miguel ]
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: reduce cfg plumbing</title>
<updated>2026-03-09T17:20:09+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@kernel.org</email>
</author>
<published>2026-01-27T13:55:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=5c8d16ac49405c5b77c955684849528f7d4d6b81'/>
<id>5c8d16ac49405c5b77c955684849528f7d4d6b81</id>
<content type='text'>
Pass `pin_init{,_internal}-cfgs` from rust/Makefile to
scripts/generate_rust_analyzer.py. Remove hardcoded `cfg`s in
scripts/generate_rust_analyzer.py for `pin-init{,-internal}` now that
these are passed from `rust/Makefile`.

Centralize `cfg` lookup in scripts/generate_rust_analyzer.py in
`append_crate` to avoid having to do so for each crate.

Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Acked-by: Benno Lossin &lt;lossin@kernel.org&gt;
Acked-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://patch.msgid.link/20260127-rust-analyzer-pin-init-duplication-v3-2-118c48c35e88@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pass `pin_init{,_internal}-cfgs` from rust/Makefile to
scripts/generate_rust_analyzer.py. Remove hardcoded `cfg`s in
scripts/generate_rust_analyzer.py for `pin-init{,-internal}` now that
these are passed from `rust/Makefile`.

Centralize `cfg` lookup in scripts/generate_rust_analyzer.py in
`append_crate` to avoid having to do so for each crate.

Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Acked-by: Benno Lossin &lt;lossin@kernel.org&gt;
Acked-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
Link: https://patch.msgid.link/20260127-rust-analyzer-pin-init-duplication-v3-2-118c48c35e88@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: rename cfg to generated_cfg</title>
<updated>2026-03-09T17:20:09+00:00</updated>
<author>
<name>Eliot Courtney</name>
<email>ecourtney@nvidia.com</email>
</author>
<published>2026-01-20T08:52:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=dc6b431f18cfb1e8cc7da45c16ccf371bcd636d5'/>
<id>dc6b431f18cfb1e8cc7da45c16ccf371bcd636d5</id>
<content type='text'>
This variable is for the cfg from generated files. It's also easy to
confuse with the `cfg` parameter in append_crate(), so rename it.

[ Changed title to include script extension. - Tamir ]

Signed-off-by: Eliot Courtney &lt;ecourtney@nvidia.com&gt;
Reviewed-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
Link: https://patch.msgid.link/20260120-ra-fix-v1-1-829e4e92818c@nvidia.com
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This variable is for the cfg from generated files. It's also easy to
confuse with the `cfg` parameter in append_crate(), so rename it.

[ Changed title to include script extension. - Tamir ]

Signed-off-by: Eliot Courtney &lt;ecourtney@nvidia.com&gt;
Reviewed-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
Link: https://patch.msgid.link/20260120-ra-fix-v1-1-829e4e92818c@nvidia.com
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: avoid FD leak</title>
<updated>2026-03-09T17:20:09+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@kernel.org</email>
</author>
<published>2026-01-27T16:35:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9b4744d8eda2824041064a5639ccbb079850914d'/>
<id>9b4744d8eda2824041064a5639ccbb079850914d</id>
<content type='text'>
Use `pathlib.Path.read_text()` to avoid leaking file descriptors.

Fixes: 8c4555ccc55c ("scripts: add `generate_rust_analyzer.py`")
Cc: stable@vger.kernel.org
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Link: https://patch.msgid.link/20260127-rust-analyzer-fd-leak-v2-1-1bb55b9b6822@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use `pathlib.Path.read_text()` to avoid leaking file descriptors.

Fixes: 8c4555ccc55c ("scripts: add `generate_rust_analyzer.py`")
Cc: stable@vger.kernel.org
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Link: https://patch.msgid.link/20260127-rust-analyzer-fd-leak-v2-1-1bb55b9b6822@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: define scripts</title>
<updated>2026-03-09T17:20:08+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@kernel.org</email>
</author>
<published>2026-01-22T16:53:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=36c619f6bd793493294becb10a02fea370b67a91'/>
<id>36c619f6bd793493294becb10a02fea370b67a91</id>
<content type='text'>
Add IDE support for host-side scripts written in Rust. This support has
been missing since these scripts were initially added in commit
9a8ff24ce584 ("scripts: add `generate_rust_target.rs`"), thus add it.

Change the existing instance of extension stripping to
`pathlib.Path.stem` to maintain code consistency.

Fixes: 9a8ff24ce584 ("scripts: add `generate_rust_target.rs`")
Cc: stable@vger.kernel.org
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-scripts-v1-1-ff6ba278170e@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add IDE support for host-side scripts written in Rust. This support has
been missing since these scripts were initially added in commit
9a8ff24ce584 ("scripts: add `generate_rust_target.rs`"), thus add it.

Change the existing instance of extension stripping to
`pathlib.Path.stem` to maintain code consistency.

Fixes: 9a8ff24ce584 ("scripts: add `generate_rust_target.rs`")
Cc: stable@vger.kernel.org
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-scripts-v1-1-ff6ba278170e@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: identify crates explicitly</title>
<updated>2026-03-09T17:20:08+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@kernel.org</email>
</author>
<published>2026-01-22T17:30:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=75c0fb25b56dc3ef122b1ac2dbb7bc9b31937408'/>
<id>75c0fb25b56dc3ef122b1ac2dbb7bc9b31937408</id>
<content type='text'>
Use the return of `append_crate` to declare dependency on that crate.
This removes the need to build an index of crates and allows multiple
crates with the same display_name be defined, which allows e.g. host
crates to be defined separately from target crates.

Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-4-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use the return of `append_crate` to declare dependency on that crate.
This removes the need to build an index of crates and allows multiple
crates with the same display_name be defined, which allows e.g. host
crates to be defined separately from target crates.

Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-4-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: add type hints</title>
<updated>2026-03-09T17:20:08+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@kernel.org</email>
</author>
<published>2026-01-22T17:30:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=94a3b2d9877eee2f8b5b41a51d99b7860efbd34d'/>
<id>94a3b2d9877eee2f8b5b41a51d99b7860efbd34d</id>
<content type='text'>
Python type hints allow static analysis tools like mypy to detect type
errors during development, improving the developer experience.

Python type hints have been present in the kernel since 2019 at the
latest; see commit 6ebf5866f2e8 ("kunit: tool: add Python wrappers for
running KUnit tests").

Add a subclass of `argparse.Namespace` to get type checking on the CLI
arguments.

Run `mypy --strict scripts/generate_rust_analyzer.py --python-version
3.9` to verify. Note that `mypy` no longer supports python &lt; 3.9.

Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-3-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Python type hints allow static analysis tools like mypy to detect type
errors during development, improving the developer experience.

Python type hints have been present in the kernel since 2019 at the
latest; see commit 6ebf5866f2e8 ("kunit: tool: add Python wrappers for
running KUnit tests").

Add a subclass of `argparse.Namespace` to get type checking on the CLI
arguments.

Run `mypy --strict scripts/generate_rust_analyzer.py --python-version
3.9` to verify. Note that `mypy` no longer supports python &lt; 3.9.

Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-3-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: drop `"is_proc_macro": false`</title>
<updated>2026-03-09T17:20:08+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@kernel.org</email>
</author>
<published>2026-01-22T17:30:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=4079cf049cb265c15c3c7349d85943462ba054d5'/>
<id>4079cf049cb265c15c3c7349d85943462ba054d5</id>
<content type='text'>
Add a dedicated `append_proc_macro_crate` function to reduce overloading
in `append_crate`. This has the effect of removing `"is_proc_macro":
false` from the output; this field is interpreted as false if absent[1]
so this doesn't change the behavior of rust-analyzer.

Use the `/` operator on `pathlib.Path` rather than directly crafting a
string. This is consistent with all other path manipulation in this
script.

Link: https://github.com/rust-lang/rust-analyzer/blob/8d01570b5e812a49daa1f08404269f6ea5dd73a1/crates/project-model/src/project_json.rs#L372-L373 [1]
Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-2-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a dedicated `append_proc_macro_crate` function to reduce overloading
in `append_crate`. This has the effect of removing `"is_proc_macro":
false` from the output; this field is interpreted as false if absent[1]
so this doesn't change the behavior of rust-analyzer.

Use the `/` operator on `pathlib.Path` rather than directly crafting a
string. This is consistent with all other path manipulation in this
script.

Link: https://github.com/rust-lang/rust-analyzer/blob/8d01570b5e812a49daa1f08404269f6ea5dd73a1/crates/project-model/src/project_json.rs#L372-L373 [1]
Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-2-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scripts: generate_rust_analyzer.py: extract `{build,register}_crate`</title>
<updated>2026-03-09T17:20:04+00:00</updated>
<author>
<name>Tamir Duberstein</name>
<email>tamird@kernel.org</email>
</author>
<published>2026-01-22T17:30:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e33d58ee0c081c4468d0ea4f03fcb93c6cb5e21a'/>
<id>e33d58ee0c081c4468d0ea4f03fcb93c6cb5e21a</id>
<content type='text'>
Extract helpers from `append_crate` to avoid the need to peek into
`crates[-1]`. This improves readability.

Change default parameters to `None` with true defaults applied in
`build_crate` to avoid repeating the defaults in wrapper functions such
as `append_crate`.

Suggested-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-1-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Extract helpers from `append_crate` to avoid the need to peek into
`crates[-1]`. This improves readability.

Change default parameters to `None` with true defaults applied in
`build_crate` to avoid repeating the defaults in wrapper functions such
as `append_crate`.

Suggested-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Tested-by: Daniel Almeida &lt;daniel.almeida@collabora.com&gt;
Reviewed-by: Fiona Behrens &lt;me@kloenk.dev&gt;
Reviewed-by: Trevor Gross &lt;tmgross@umich.edu&gt;
Reviewed-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Tested-by: Jesung Yang &lt;y.j3ms.n@gmail.com&gt;
Link: https://patch.msgid.link/20260122-rust-analyzer-types-v1-1-29cc2e91dcd5@kernel.org
Signed-off-by: Tamir Duberstein &lt;tamird@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge tag 'rust-6.20-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux</title>
<updated>2026-02-10T19:53:01+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2026-02-10T19:53:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=a9aabb3b839aba094ed80861054993785c61462c'/>
<id>a9aabb3b839aba094ed80861054993785c61462c</id>
<content type='text'>
Pull rust updates from Miguel Ojeda:
 "Toolchain and infrastructure:

   - Add '__rust_helper' annotation to the C helpers

     This is needed to inline these helpers into Rust code

   - Remove imports available via the prelude, treewide

     This was possible thanks to a new lint in Klint that Gary has
     implemented -- more Klint-related changes, including initial
     upstream support, are coming

   - Deduplicate pin-init flags

  'kernel' crate:

   - Add support for calling a function exactly once with the new
     'do_once_lite!' macro (and 'OnceLite' type)

     Based on this, add 'pr_*_once!' macros to print only once

   - Add 'impl_flags!' macro for defining common bitflags operations:

         impl_flags!(
             /// Represents multiple permissions.
             #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)]
             pub struct Permissions(u32);

             /// Represents a single permission.
             #[derive(Debug, Clone, Copy, PartialEq, Eq)]
             pub enum Permission {
                 /// Read permission.
                 Read = 1 &lt;&lt; 0,

                 /// Write permission.
                 Write = 1 &lt;&lt; 1,

                 /// Execute permission.
                 Execute = 1 &lt;&lt; 2,
             }
         );

         let mut f: Permissions = Permission::Read | Permission::Write;
         assert!(f.contains(Permission::Read));
         assert!(!f.contains(Permission::Execute));

         f |= Permission::Execute;
         assert!(f.contains(Permission::Execute));

         let f2: Permissions = Permission::Write | Permission::Execute;
         assert!((f ^ f2).contains(Permission::Read));
         assert!(!(f ^ f2).contains(Permission::Write));

   - 'bug' module: support 'CONFIG_DEBUG_BUGVERBOSE_DETAILED' in the
     'warn_on!' macro in order to show the evaluated condition alongside
     the file path:

          ------------[ cut here ]------------
          WARNING: [val == 1] linux/samples/rust/rust_minimal.rs:27 at ...
          Modules linked in: rust_minimal(+)

   - Add safety module with 'unsafe_precondition_assert!' macro,
     currently a wrapper for 'debug_assert!', intended to mark the
     validation of safety preconditions where possible:

         /// # Safety
         ///
         /// The caller must ensure that `index` is less than `N`.
         unsafe fn set_unchecked(&amp;mut self, index: usize, value: T) {
             unsafe_precondition_assert!(
                 index &lt; N,
                 "set_unchecked() requires index ({index}) &lt; N ({N})"
             );

             ...
         }

   - Add instructions to 'build_assert!' documentation requesting to
     always inline functions when used with function arguments

   - 'ptr' module: replace 'build_assert!' with a 'const' one

   - 'rbtree' module: reduce unsafe blocks on pointer derefs

   - 'transmute' module: implement 'FromBytes' and 'AsBytes' for
     inhabited ZSTs, and use it in Nova

   - More treewide replacements of 'c_str!' with C string literals

  'macros' crate:

   - Rewrite most procedural macros ('module!', 'concat_idents!',
     '#[export]', '#[vtable]', '#[kunit_tests]') to use the 'syn'
     parsing library which we introduced last cycle, with better
     diagnostics

     This also allows to support '#[cfg]' properly in the '#[vtable]'
     macro, to support arbitrary types in 'module!' macro (not just an
     identifier) and to remove several custom parsing helpers we had

   - Use 'quote!' from the recently vendored 'quote' library and remove
     our custom one

     The vendored one also allows us to avoid quoting '"' and '{}'
     inside the template anymore and editors can now highlight it. In
     addition, it improves robustness as it eliminates the need for
     string quoting and escaping

   - Use 'pin_init::zeroed()' to simplify KUnit code

  'pin-init' crate:

   - Rewrite all procedural macros ('[pin_]init!', '#[pin_data]',
     '#[pinned_drop]', 'derive([Maybe]Zeroable)') to use the 'syn'
     parsing library which we introduced last cycle, with better
     diagnostics

   - Implement 'InPlaceWrite' for '&amp;'static mut MaybeUninit&lt;T&gt;'. This
     enables users to use external allocation mechanisms such as
     'static_cell'

   - Support tuple structs in 'derive([Maybe]Zeroable)'

   - Support attributes on fields in '[pin_]init!' (such as
     '#[cfg(...)]')

   - Add a '#[default_error(&lt;type&gt;)]' attribute to '[pin_]init!' to
     override the default error (when no '? Error' is specified)

   - Support packed structs in '[pin_]init!' with
     '#[disable_initialized_field_access]'

   - Remove 'try_[pin_]init!' in favor of merging their feature with
     '[pin_]init!'. Update the kernel's own 'try_[pin_]init!' macros to
     use the 'default_error' attribute

   - Correct 'T: Sized' bounds to 'T: ?Sized' in the generated
     'PinnedDrop' check by '#[pin_data]'

  Documentation:

   - Conclude the Rust experiment

  MAINTAINERS:

   - Add "RUST [RUST-ANALYZER]" entry for the rust-analyzer support.
     Tamir and Jesung will take care of it. They have both been active
     around it for a while. The new tree will flow through the Rust one

   - Add Gary as maintainer for "RUST [PIN-INIT]"

   - Update Boqun and Tamir emails to their kernel.org accounts

  And a few other cleanups and improvements"

* tag 'rust-6.20-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (59 commits)
  rust: safety: introduce `unsafe_precondition_assert!` macro
  rust: add `impl_flags!` macro for defining common bitflag operations
  rust: print: Add pr_*_once macros
  rust: bug: Support DEBUG_BUGVERBOSE_DETAILED option
  rust: print: Add support for calling a function exactly once
  rust: kbuild: deduplicate pin-init flags
  gpu: nova-core: remove imports available via prelude
  rust: clk: replace `kernel::c_str!` with C-Strings
  MAINTAINERS: Update my email address to @kernel.org
  rust: macros: support `#[cfg]` properly in `#[vtable]` macro.
  rust: kunit: use `pin_init::zeroed` instead of custom null value
  rust: macros: rearrange `#[doc(hidden)]` in `module!` macro
  rust: macros: allow arbitrary types to be used in `module!` macro
  rust: macros: convert `#[kunit_tests]` macro to use `syn`
  rust: macros: convert `concat_idents!` to use `syn`
  rust: macros: convert `#[export]` to use `syn`
  rust: macros: use `quote!` for `module!` macro
  rust: macros: use `syn` to parse `module!` macro
  rust: macros: convert `#[vtable]` macro to use `syn`
  rust: macros: use `quote!` from vendored crate
  ...
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Pull rust updates from Miguel Ojeda:
 "Toolchain and infrastructure:

   - Add '__rust_helper' annotation to the C helpers

     This is needed to inline these helpers into Rust code

   - Remove imports available via the prelude, treewide

     This was possible thanks to a new lint in Klint that Gary has
     implemented -- more Klint-related changes, including initial
     upstream support, are coming

   - Deduplicate pin-init flags

  'kernel' crate:

   - Add support for calling a function exactly once with the new
     'do_once_lite!' macro (and 'OnceLite' type)

     Based on this, add 'pr_*_once!' macros to print only once

   - Add 'impl_flags!' macro for defining common bitflags operations:

         impl_flags!(
             /// Represents multiple permissions.
             #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)]
             pub struct Permissions(u32);

             /// Represents a single permission.
             #[derive(Debug, Clone, Copy, PartialEq, Eq)]
             pub enum Permission {
                 /// Read permission.
                 Read = 1 &lt;&lt; 0,

                 /// Write permission.
                 Write = 1 &lt;&lt; 1,

                 /// Execute permission.
                 Execute = 1 &lt;&lt; 2,
             }
         );

         let mut f: Permissions = Permission::Read | Permission::Write;
         assert!(f.contains(Permission::Read));
         assert!(!f.contains(Permission::Execute));

         f |= Permission::Execute;
         assert!(f.contains(Permission::Execute));

         let f2: Permissions = Permission::Write | Permission::Execute;
         assert!((f ^ f2).contains(Permission::Read));
         assert!(!(f ^ f2).contains(Permission::Write));

   - 'bug' module: support 'CONFIG_DEBUG_BUGVERBOSE_DETAILED' in the
     'warn_on!' macro in order to show the evaluated condition alongside
     the file path:

          ------------[ cut here ]------------
          WARNING: [val == 1] linux/samples/rust/rust_minimal.rs:27 at ...
          Modules linked in: rust_minimal(+)

   - Add safety module with 'unsafe_precondition_assert!' macro,
     currently a wrapper for 'debug_assert!', intended to mark the
     validation of safety preconditions where possible:

         /// # Safety
         ///
         /// The caller must ensure that `index` is less than `N`.
         unsafe fn set_unchecked(&amp;mut self, index: usize, value: T) {
             unsafe_precondition_assert!(
                 index &lt; N,
                 "set_unchecked() requires index ({index}) &lt; N ({N})"
             );

             ...
         }

   - Add instructions to 'build_assert!' documentation requesting to
     always inline functions when used with function arguments

   - 'ptr' module: replace 'build_assert!' with a 'const' one

   - 'rbtree' module: reduce unsafe blocks on pointer derefs

   - 'transmute' module: implement 'FromBytes' and 'AsBytes' for
     inhabited ZSTs, and use it in Nova

   - More treewide replacements of 'c_str!' with C string literals

  'macros' crate:

   - Rewrite most procedural macros ('module!', 'concat_idents!',
     '#[export]', '#[vtable]', '#[kunit_tests]') to use the 'syn'
     parsing library which we introduced last cycle, with better
     diagnostics

     This also allows to support '#[cfg]' properly in the '#[vtable]'
     macro, to support arbitrary types in 'module!' macro (not just an
     identifier) and to remove several custom parsing helpers we had

   - Use 'quote!' from the recently vendored 'quote' library and remove
     our custom one

     The vendored one also allows us to avoid quoting '"' and '{}'
     inside the template anymore and editors can now highlight it. In
     addition, it improves robustness as it eliminates the need for
     string quoting and escaping

   - Use 'pin_init::zeroed()' to simplify KUnit code

  'pin-init' crate:

   - Rewrite all procedural macros ('[pin_]init!', '#[pin_data]',
     '#[pinned_drop]', 'derive([Maybe]Zeroable)') to use the 'syn'
     parsing library which we introduced last cycle, with better
     diagnostics

   - Implement 'InPlaceWrite' for '&amp;'static mut MaybeUninit&lt;T&gt;'. This
     enables users to use external allocation mechanisms such as
     'static_cell'

   - Support tuple structs in 'derive([Maybe]Zeroable)'

   - Support attributes on fields in '[pin_]init!' (such as
     '#[cfg(...)]')

   - Add a '#[default_error(&lt;type&gt;)]' attribute to '[pin_]init!' to
     override the default error (when no '? Error' is specified)

   - Support packed structs in '[pin_]init!' with
     '#[disable_initialized_field_access]'

   - Remove 'try_[pin_]init!' in favor of merging their feature with
     '[pin_]init!'. Update the kernel's own 'try_[pin_]init!' macros to
     use the 'default_error' attribute

   - Correct 'T: Sized' bounds to 'T: ?Sized' in the generated
     'PinnedDrop' check by '#[pin_data]'

  Documentation:

   - Conclude the Rust experiment

  MAINTAINERS:

   - Add "RUST [RUST-ANALYZER]" entry for the rust-analyzer support.
     Tamir and Jesung will take care of it. They have both been active
     around it for a while. The new tree will flow through the Rust one

   - Add Gary as maintainer for "RUST [PIN-INIT]"

   - Update Boqun and Tamir emails to their kernel.org accounts

  And a few other cleanups and improvements"

* tag 'rust-6.20-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (59 commits)
  rust: safety: introduce `unsafe_precondition_assert!` macro
  rust: add `impl_flags!` macro for defining common bitflag operations
  rust: print: Add pr_*_once macros
  rust: bug: Support DEBUG_BUGVERBOSE_DETAILED option
  rust: print: Add support for calling a function exactly once
  rust: kbuild: deduplicate pin-init flags
  gpu: nova-core: remove imports available via prelude
  rust: clk: replace `kernel::c_str!` with C-Strings
  MAINTAINERS: Update my email address to @kernel.org
  rust: macros: support `#[cfg]` properly in `#[vtable]` macro.
  rust: kunit: use `pin_init::zeroed` instead of custom null value
  rust: macros: rearrange `#[doc(hidden)]` in `module!` macro
  rust: macros: allow arbitrary types to be used in `module!` macro
  rust: macros: convert `#[kunit_tests]` macro to use `syn`
  rust: macros: convert `concat_idents!` to use `syn`
  rust: macros: convert `#[export]` to use `syn`
  rust: macros: use `quote!` for `module!` macro
  rust: macros: use `syn` to parse `module!` macro
  rust: macros: convert `#[vtable]` macro to use `syn`
  rust: macros: use `quote!` from vendored crate
  ...
</pre>
</div>
</content>
</entry>
</feed>
