Skip to content

Commit dcebfd2

Browse files
committed
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]`
2 parents 26ae421 + 191f49f commit dcebfd2

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,9 @@ KBUILD_CFLAGS += $(stackp-flags-y)
961961
ifdef CONFIG_FRAME_POINTER
962962
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
963963
KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
964+
# Work around rustc bug on compilers without
965+
# https://github.com/rust-lang/rust/pull/156980.
966+
KBUILD_RUSTFLAGS += $(if $(call rustc-min-version,109800),,-Zllvm_module_flag=frame-pointer:u32:2:max)
964967
else
965968
# Some targets (ARM with Thumb2, for example), can't be built with frame
966969
# pointers. For those, we don't have FUNCTION_TRACER automatically

rust/kernel/bitfield.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ macro_rules! bitfield {
535535
// `Debug` implementation.
536536
(@debug $name:ident { $($field:ident;)* }) => {
537537
impl ::kernel::fmt::Debug for $name {
538+
#[inline]
538539
fn fmt(&self, f: &mut ::kernel::fmt::Formatter<'_>) -> ::kernel::fmt::Result {
539540
f.debug_struct(stringify!($name))
540541
.field("<raw>", &::kernel::prelude::fmt!("{:#x}", self.inner))

scripts/rustdoc_test_builder.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
//
2929
// ```
3030
// fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_28_0() {
31-
// fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_37_0() -> Result<(), impl ::core::fmt::Debug> {
31+
// fn main() { #[allow(non_snake_case)] fn _doctest_main_rust_kernel_file_rs_37_0() -> Result<(), impl core::fmt::Debug> {
3232
// ```
3333
//
3434
// It should be unlikely that doctest code matches such lines (when code is formatted properly).
@@ -47,12 +47,16 @@ fn main() {
4747
})
4848
.expect("No test function found in `rustdoc`'s output.");
4949

50-
// Qualify `Result` to avoid the collision with our own `Result` coming from the prelude.
50+
// Replicate `rustdoc` 1.87+ behaviour [1] by fully qualifying `Result` to avoid the collision
51+
// with our own `Result` coming from the prelude.
52+
//
53+
// [1]: https://github.com/rust-lang/rust/pull/137807
54+
//
55+
// TODO: Remove this when MSRV is bumped above 1.87.
5156
let body = body.replace(
52-
&format!("{rustdoc_function_name}() -> Result<(), impl ::core::fmt::Debug> {{"),
53-
&format!(
54-
"{rustdoc_function_name}() -> ::core::result::Result<(), impl ::core::fmt::Debug> {{"
55-
),
57+
&format!("{rustdoc_function_name}() -> Result<(), impl core::fmt::Debug> {{"),
58+
// This intentionally does not use absolute paths to match `rustdoc` 1.87 behaviour.
59+
&format!("{rustdoc_function_name}() -> core::result::Result<(), impl core::fmt::Debug> {{"),
5660
);
5761

5862
// For tests that get generated with `Result`, like above, `rustdoc` generates an `unwrap()` on

0 commit comments

Comments
 (0)