Skip to content

Commit 2c62efa

Browse files
committed
Merge branch 'rust-fixes' into rust-lints-test
# Conflicts: # Makefile
2 parents 1e6fc47 + cff56ff commit 2c62efa

File tree

11 files changed

+41
-36
lines changed

11 files changed

+41
-36
lines changed

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Amit Nischal <[email protected]> <[email protected]>
6060
6161
6262
Andreas Herrmann <[email protected]>
63+
6364
Andrej Shadura <[email protected]>
6465
6566
Andrew Morton <[email protected]>

Documentation/rust/coding-guidelines.rst

+19-19
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,32 @@ This is how a well-documented Rust function may look like:
145145
This example showcases a few ``rustdoc`` features and some conventions followed
146146
in the kernel:
147147

148-
- The first paragraph must be a single sentence briefly describing what
149-
the documented item does. Further explanations must go in extra paragraphs.
148+
- The first paragraph must be a single sentence briefly describing what
149+
the documented item does. Further explanations must go in extra paragraphs.
150150

151-
- Unsafe functions must document their safety preconditions under
152-
a ``# Safety`` section.
151+
- Unsafe functions must document their safety preconditions under
152+
a ``# Safety`` section.
153153

154-
- While not shown here, if a function may panic, the conditions under which
155-
that happens must be described under a ``# Panics`` section.
154+
- While not shown here, if a function may panic, the conditions under which
155+
that happens must be described under a ``# Panics`` section.
156156

157-
Please note that panicking should be very rare and used only with a good
158-
reason. In almost all cases, a fallible approach should be used, typically
159-
returning a ``Result``.
157+
Please note that panicking should be very rare and used only with a good
158+
reason. In almost all cases, a fallible approach should be used, typically
159+
returning a ``Result``.
160160

161-
- If providing examples of usage would help readers, they must be written in
162-
a section called ``# Examples``.
161+
- If providing examples of usage would help readers, they must be written in
162+
a section called ``# Examples``.
163163

164-
- Rust items (functions, types, constants...) must be linked appropriately
165-
(``rustdoc`` will create a link automatically).
164+
- Rust items (functions, types, constants...) must be linked appropriately
165+
(``rustdoc`` will create a link automatically).
166166

167-
- Any ``unsafe`` block must be preceded by a ``// SAFETY:`` comment
168-
describing why the code inside is sound.
167+
- Any ``unsafe`` block must be preceded by a ``// SAFETY:`` comment
168+
describing why the code inside is sound.
169169

170-
While sometimes the reason might look trivial and therefore unneeded,
171-
writing these comments is not just a good way of documenting what has been
172-
taken into account, but most importantly, it provides a way to know that
173-
there are no *extra* implicit constraints.
170+
While sometimes the reason might look trivial and therefore unneeded,
171+
writing these comments is not just a good way of documenting what has been
172+
taken into account, but most importantly, it provides a way to know that
173+
there are no *extra* implicit constraints.
174174

175175
To learn more about how to write documentation for Rust and extra features,
176176
please take a look at the ``rustdoc`` book at:

Documentation/rust/quick-start.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ If GDB/Binutils is used and Rust symbols are not getting demangled, the reason
305305
is the toolchain does not support Rust's new v0 mangling scheme yet.
306306
There are a few ways out:
307307

308-
- Install a newer release (GDB >= 10.2, Binutils >= 2.36).
308+
- Install a newer release (GDB >= 10.2, Binutils >= 2.36).
309309

310-
- Some versions of GDB (e.g. vanilla GDB 10.1) are able to use
311-
the pre-demangled names embedded in the debug info (``CONFIG_DEBUG_INFO``).
310+
- Some versions of GDB (e.g. vanilla GDB 10.1) are able to use
311+
the pre-demangled names embedded in the debug info (``CONFIG_DEBUG_INFO``).

MAINTAINERS

+2-3
Original file line numberDiff line numberDiff line change
@@ -3863,7 +3863,7 @@ F: kernel/trace/blktrace.c
38633863
F: lib/sbitmap.c
38643864

38653865
BLOCK LAYER DEVICE DRIVER API [RUST]
3866-
M: Andreas Hindborg <a.hindborg@samsung.com>
3866+
M: Andreas Hindborg <a.hindborg@kernel.org>
38673867
R: Boqun Feng <[email protected]>
38683868
38693869
@@ -19907,12 +19907,11 @@ F: tools/verification/
1990719907
RUST
1990819908
M: Miguel Ojeda <[email protected]>
1990919909
M: Alex Gaynor <[email protected]>
19910-
M: Wedson Almeida Filho <[email protected]>
1991119910
R: Boqun Feng <[email protected]>
1991219911
R: Gary Guo <[email protected]>
1991319912
R: Björn Roy Baron <[email protected]>
1991419913
R: Benno Lossin <[email protected]>
19915-
R: Andreas Hindborg <a.hindborg@samsung.com>
19914+
R: Andreas Hindborg <a.hindborg@kernel.org>
1991619915
R: Alice Ryhl <[email protected]>
1991719916
R: Trevor Gross <[email protected]>
1991819917

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ KBUILD_USERLDFLAGS := $(USERLDFLAGS)
445445
# host programs.
446446
export rust_common_flags := --edition=2021 \
447447
-Zbinary_dep_depinfo=y \
448+
-Astable_features \
448449
-Dnon_ascii_idents \
449450
-Dunsafe_op_in_unsafe_fn \
450451
-Wmissing_docs \

rust/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ $(obj)/bindings/bindings_helpers_generated.rs: $(src)/helpers/helpers.c FORCE
309309
quiet_cmd_exports = EXPORTS $@
310310
cmd_exports = \
311311
$(NM) -p --defined-only $< \
312-
| awk '/ (T|R|D) / {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$3}' > $@
312+
| awk '/ (T|R|D|B) / {printf "EXPORT_SYMBOL_RUST_GPL(%s);\n",$$3}' > $@
313313

314314
$(obj)/exports_core_generated.h: $(obj)/core.o FORCE
315315
$(call if_changed,exports)

rust/kernel/alloc/box_ext.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ pub trait BoxExt<T>: Sized {
3737

3838
impl<T> BoxExt<T> for Box<T> {
3939
fn new(x: T, flags: Flags) -> Result<Self, AllocError> {
40-
let b = <Self as BoxExt<_>>::new_uninit(flags)?;
41-
Ok(Box::write(b, x))
40+
let mut b = <Self as BoxExt<_>>::new_uninit(flags)?;
41+
b.write(x);
42+
// SAFETY: We just wrote to it.
43+
Ok(unsafe { b.assume_init() })
4244
}
4345

4446
#[cfg(any(test, testlib))]

rust/kernel/block/mq/gen_disk.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//! C header: [`include/linux/blk_mq.h`](srctree/include/linux/blk_mq.h)
77
88
use crate::block::mq::{raw_writer::RawWriter, Operations, TagSet};
9-
use crate::error;
109
use crate::{bindings, error::from_err_ptr, error::Result, sync::Arc};
10+
use crate::{error, static_lock_class};
1111
use core::fmt::{self, Write};
1212

1313
/// A builder for [`GenDisk`].
@@ -93,8 +93,6 @@ impl GenDiskBuilder {
9393
name: fmt::Arguments<'_>,
9494
tagset: Arc<TagSet<T>>,
9595
) -> Result<GenDisk<T>> {
96-
let lock_class_key = crate::sync::LockClassKey::new();
97-
9896
// SAFETY: `bindings::queue_limits` contain only fields that are valid when zeroed.
9997
let mut lim: bindings::queue_limits = unsafe { core::mem::zeroed() };
10098

@@ -110,7 +108,7 @@ impl GenDiskBuilder {
110108
tagset.raw_tag_set(),
111109
&mut lim,
112110
core::ptr::null_mut(),
113-
lock_class_key.as_ptr(),
111+
static_lock_class!().as_ptr(),
114112
)
115113
})?;
116114

rust/kernel/init/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
//! }
146146
//! }
147147
//! // Implement the internal `PinData` trait that marks the pin-data struct as a pin-data
148-
//! // struct. This is important to ensure that no user can implement a rouge `__pin_data`
148+
//! // struct. This is important to ensure that no user can implement a rogue `__pin_data`
149149
//! // function without using `unsafe`.
150150
//! unsafe impl<T> ::kernel::init::__internal::PinData for __ThePinData<T> {
151151
//! type Datee = Bar<T>;
@@ -156,7 +156,7 @@
156156
//! // case no such fields exist, hence this is almost empty. The two phantomdata fields exist
157157
//! // for two reasons:
158158
//! // - `__phantom`: every generic must be used, since we cannot really know which generics
159-
//! // are used, we declere all and then use everything here once.
159+
//! // are used, we declare all and then use everything here once.
160160
//! // - `__phantom_pin`: uses the `'__pin` lifetime and ensures that this struct is invariant
161161
//! // over it. The lifetime is needed to work around the limitation that trait bounds must
162162
//! // not be trivial, e.g. the user has a `#[pin] PhantomPinned` field -- this is

rust/kernel/net/phy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl<T: Driver> Adapter<T> {
491491
pub struct DriverVTable(Opaque<bindings::phy_driver>);
492492

493493
// SAFETY: `DriverVTable` doesn't expose any &self method to access internal data, so it's safe to
494-
// share `&DriverVTable` across execution context boundries.
494+
// share `&DriverVTable` across execution context boundaries.
495495
unsafe impl Sync for DriverVTable {}
496496

497497
/// Creates a [`DriverVTable`] instance from [`Driver`].

rust/macros/module.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,11 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
217217
// freed until the module is unloaded.
218218
#[cfg(MODULE)]
219219
static THIS_MODULE: kernel::ThisModule = unsafe {{
220-
kernel::ThisModule::from_ptr(&kernel::bindings::__this_module as *const _ as *mut _)
220+
extern \"C\" {{
221+
static __this_module: kernel::types::Opaque<kernel::bindings::module>;
222+
}}
223+
224+
kernel::ThisModule::from_ptr(__this_module.get())
221225
}};
222226
#[cfg(not(MODULE))]
223227
static THIS_MODULE: kernel::ThisModule = unsafe {{

0 commit comments

Comments
 (0)