mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
Rust fixes for v7.2
Toolchain and infrastructure:
- Work around a 'rustc' bug by setting the 'frame-pointer' LLVM module
flag under 'CONFIG_FRAME_POINTER'. The upcoming Rust 1.98.0 is fixed.
- Doctests: fix incorrect replacement pattern.
'kernel' crate:
- Mark 'Debug' impl as '#[inline]'.
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEPjU5OPd5QIZ9jqqOGXyLc2htIW0FAmo76uAACgkQGXyLc2ht
IW1XLQ/8DGJd3mulDJQVFOUO53o1vNSak74MvddVeURCwbqVVy+oO7o7ZPqwpoMW
R7nosvJTw3XFGytHjSdbhLJ01P2Tv2PQHW2vHMwFeLWBW5xtZqEAwbIgGjsB7LQ5
SrRQVglnjv7nBm6TurEBRB6WgtjdL1CuzWlWpspSSYA6LtZZiH/56cOxrgMLPOeb
usK0lh0lWFozeYUCpij1L9Sc6ShKYxoKXWIgGf0fY7aChEfSM77KQ2mXaARIbVd/
iKG7pL0B3QYOdwnrUasZdasqx+yBKl8rQNDzbLKCho//HpYSDLTkNgD7AmKYNXO3
6ZltvdV/z7Jg2Ks/08ers0EgvOV6ye0DgyJD6v9gbaKeNN4dp2F38wJJylJwfX+4
N2MMNfSYFuNYBCxb54nG+p2IWWJ042opGAaPAJ4+omHT3combzAAhUIxmRglOtGD
tHx7hs16TxITWZoRjpzyQz/ManwQJuZIipwkxIMrmRHre5+n+83I+LsdL51GEBAH
bREkLsdn7k3OlZIeQaeuSSUwRYI1QaJ0FzVw5BNslq4dRA0a3hMx3qGPBU+wrYlj
AXSIsV4VJMdvf1u3578Xjm/SqAzagM0MaBjc1+HgARA++nConnazzog1CP/4GoFN
FpZBQXXn+FL3ucn5Cp7p9Uz4aftAcF9D8VohtiwP4hKTY+mWQk4=
=8FnP
-----END PGP SIGNATURE-----
Merge tag 'rust-fixes-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull rust fixes from Miguel Ojeda:
"Toolchain and infrastructure:
- Work around a 'rustc' bug by setting the 'frame-pointer' LLVM
module flag under 'CONFIG_FRAME_POINTER'.
The upcoming Rust 1.98.0 is fixed.
- Doctests: fix incorrect replacement pattern.
'kernel' crate:
- Mark 'Debug' impl as '#[inline]'"
* tag 'rust-fixes-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux:
rust: Kbuild: set frame-pointer llvm module flag for CONFIG_FRAME_POINTER
rust: doctest: fix incorrect pattern in replacement
rust: bitfield: mark `Debug` impl as `#[inline]`
This commit is contained in:
commit
dcebfd2c14
3
Makefile
3
Makefile
|
|
@ -961,6 +961,9 @@ KBUILD_CFLAGS += $(stackp-flags-y)
|
|||
ifdef CONFIG_FRAME_POINTER
|
||||
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
|
||||
KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
|
||||
# Work around rustc bug on compilers without
|
||||
# https://github.com/rust-lang/rust/pull/156980.
|
||||
KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109800),,-Zllvm_module_flag=frame-pointer:u32:2:max)
|
||||
else
|
||||
# Some targets (ARM with Thumb2, for example), can't be built with frame
|
||||
# pointers. For those, we don't have FUNCTION_TRACER automatically
|
||||
|
|
|
|||
|
|
@ -535,6 +535,7 @@ const fn [<__with_ $field>](
|
|||
// `Debug` implementation.
|
||||
(@debug $name:ident { $($field:ident;)* }) => {
|
||||
impl ::kernel::fmt::Debug for $name {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut ::kernel::fmt::Formatter<'_>) -> ::kernel::fmt::Result {
|
||||
f.debug_struct(stringify!($name))
|
||||
.field("<raw>", &::kernel::prelude::fmt!("{:#x}", self.inner))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ fn main() {
|
|||
//
|
||||
// ```
|
||||
// fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_28_0() {
|
||||
// fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_37_0() -> Result<(), impl ::core::fmt::Debug> {
|
||||
// fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_37_0() -> Result<(), impl core::fmt::Debug> {
|
||||
// ```
|
||||
//
|
||||
// It should be unlikely that doctest code matches such lines (when code is formatted properly).
|
||||
|
|
@ -47,12 +47,16 @@ fn main() {
|
|||
})
|
||||
.expect("No test function found in `rustdoc`'s output.");
|
||||
|
||||
// Qualify `Result` to avoid the collision with our own `Result` coming from the prelude.
|
||||
// Replicate `rustdoc` 1.87+ behaviour [1] by fully qualifying `Result` to avoid the collision
|
||||
// with our own `Result` coming from the prelude.
|
||||
//
|
||||
// [1]: https://github.com/rust-lang/rust/pull/137807
|
||||
//
|
||||
// TODO: Remove this when MSRV is bumped above 1.87.
|
||||
let body = body.replace(
|
||||
&format!("{rustdoc_function_name}() -> Result<(), impl ::core::fmt::Debug> {{"),
|
||||
&format!(
|
||||
"{rustdoc_function_name}() -> ::core::result::Result<(), impl ::core::fmt::Debug> {{"
|
||||
),
|
||||
&format!("{rustdoc_function_name}() -> Result<(), impl core::fmt::Debug> {{"),
|
||||
// This intentionally does not use absolute paths to match `rustdoc` 1.87 behaviour.
|
||||
&format!("{rustdoc_function_name}() -> core::result::Result<(), impl core::fmt::Debug> {{"),
|
||||
);
|
||||
|
||||
// For tests that get generated with `Result`, like above, `rustdoc` generates an `unwrap()` on
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user