Skip to content

Commit f91ccd6

Browse files
committed
Fixed migration issues
1 parent 90369eb commit f91ccd6

File tree

7 files changed

+47
-27
lines changed

7 files changed

+47
-27
lines changed

rust/kernel/init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ use core::{
108108

109109
#[doc(hidden)]
110110
pub mod __private;
111+
mod pin_project;
111112

112113
/// Initialize a type on the stack.
113114
///
@@ -510,8 +511,7 @@ macro_rules! init {
510511
}}
511512
}
512513

513-
// use the proc macro instead
514-
include!("init/pin_project.rs");
514+
//include!("init/pin_project.rs");
515515

516516
/// An initializer for `T`.
517517
///

rust/kernel/init/pin_project.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// use the proc macro instead
2+
#[doc(hidden)]
13
#[macro_export]
24
macro_rules! pin_project {
35
(parse_input:
@@ -9,7 +11,7 @@ macro_rules! pin_project {
911
),
1012
@body({ $($fields:tt)* })
1113
) => {
12-
$crate::init::pin_project!(find_pinned_fields:
14+
$crate::pin_project!(find_pinned_fields:
1315
@struct_attrs($(#[$($struct_attr)*])*),
1416
@vis($vis),
1517
@name($name),
@@ -34,7 +36,7 @@ macro_rules! pin_project {
3436
),
3537
@body({ $($fields:tt)* })
3638
) => {
37-
$crate::init::pin_project!(find_pinned_fields:
39+
$crate::pin_project!(find_pinned_fields:
3840
@struct_attrs($(#[$($struct_attr)*])*),
3941
@vis($vis),
4042
@name($name),
@@ -65,7 +67,7 @@ macro_rules! pin_project {
6567
@is_pinned(yes),
6668
@pinned_drop($($pinned_drop:ident)?),
6769
) => {
68-
$crate::init::pin_project!(find_pinned_fields:
70+
$crate::pin_project!(find_pinned_fields:
6971
@struct_attrs($($struct_attrs)*),
7072
@vis($vis),
7173
@name($name),
@@ -96,7 +98,7 @@ macro_rules! pin_project {
9698
@is_pinned(),
9799
@pinned_drop($($pinned_drop:ident)?),
98100
) => {
99-
$crate::init::pin_project!(find_pinned_fields:
101+
$crate::pin_project!(find_pinned_fields:
100102
@struct_attrs($($struct_attrs)*),
101103
@vis($vis),
102104
@name($name),
@@ -127,7 +129,7 @@ macro_rules! pin_project {
127129
@is_pinned($($is_pinned:ident)?),
128130
@pinned_drop($($pinned_drop:ident)?),
129131
) => {
130-
$crate::init::pin_project!(find_pinned_fields:
132+
$crate::pin_project!(find_pinned_fields:
131133
@struct_attrs($($struct_attrs)*),
132134
@vis($vis),
133135
@name($name),
@@ -158,7 +160,7 @@ macro_rules! pin_project {
158160
@is_pinned($($is_pinned:ident)?),
159161
@pinned_drop($($pinned_drop:ident)?),
160162
) => {
161-
$crate::init::pin_project!(find_pinned_fields:
163+
$crate::pin_project!(find_pinned_fields:
162164
@struct_attrs($($struct_attrs)*),
163165
@vis($vis),
164166
@name($name),
@@ -189,7 +191,7 @@ macro_rules! pin_project {
189191
@is_pinned($($is_pinned:ident)?),
190192
@pinned_drop($($pinned_drop:ident)?),
191193
) => {
192-
$crate::init::pin_project!(find_pinned_fields:
194+
$crate::pin_project!(find_pinned_fields:
193195
@struct_attrs($($struct_attrs)*),
194196
@vis($vis),
195197
@name($name),
@@ -234,8 +236,7 @@ macro_rules! pin_project {
234236
__phantom: ::core::marker::PhantomData<fn($name<$($ty_generics)*>) -> $name<$($ty_generics)*>>,
235237
}
236238

237-
$crate::init::pin_project!(make_pin_data:
238-
@slot($name<$($ty_generics)*>),
239+
$crate::pin_project!(make_pin_data:
239240
@pin_data(__ThePinData),
240241
@impl_generics($($impl_generics)*),
241242
@ty_generics($($ty_generics)*),
@@ -244,10 +245,10 @@ macro_rules! pin_project {
244245
@not_pinned($($not_pinned)*),
245246
);
246247

247-
impl<$($impl_generics)*> __PinData for $name<$($ty_generics)*>
248+
unsafe impl<$($impl_generics)*> $crate::init::__private::__PinData for $name<$($ty_generics)*>
248249
where $($whr)*
249250
{
250-
type PinData = __ThePinData<$($ty_generics)*>;
251+
type __PinData = __ThePinData<$($ty_generics)*>;
251252
}
252253

253254
#[allow(dead_code)]
@@ -265,7 +266,7 @@ macro_rules! pin_project {
265266
$($whr)*
266267
{}
267268

268-
$crate::init::pin_project!(drop_prevention:
269+
$crate::pin_project!(drop_prevention:
269270
@name($name),
270271
@impl_generics($($impl_generics)*),
271272
@ty_generics($($ty_generics)*),
@@ -305,7 +306,6 @@ macro_rules! pin_project {
305306
}
306307
};
307308
(make_pin_data:
308-
@slot($slot:ty),
309309
@pin_data($pin_data:ident),
310310
@impl_generics($($impl_generics:tt)*),
311311
@ty_generics($($ty_generics:tt)*),
@@ -314,16 +314,24 @@ macro_rules! pin_project {
314314
@not_pinned($($(#[$($attr:tt)*])* $fvis:vis $field:ident : $type:ty),* $(,)?),
315315
) => {
316316
#[allow(dead_code)]
317-
impl<$($impl_generics)*> $pin_data<$($ty_generics)*> {
317+
impl<$($impl_generics)*> $pin_data<$($ty_generics)*>
318+
where $($whr)*
319+
{
318320
$(
319-
$pvis unsafe fn $p_field<E, W>(
320-
slot: *mut $slot,
321-
init: impl PinInit<$p_type, E, W>,
321+
$pvis unsafe fn $p_field<E, W: $crate::init::__private::InitWay>(
322+
slot: *mut $p_type,
323+
init: impl $crate::init::__private::__PinInitImpl<$p_type, E, W>,
322324
) -> ::core::result::Result<(), E> {
325+
unsafe { $crate::init::__private::__PinInitImpl::__pinned_init(init, slot) }
323326
}
324327
)*
325328
$(
326-
$fvis unsafe fn $field() -> () {}
329+
$fvis unsafe fn $field<E, W: $crate::init::__private::InitWay>(
330+
slot: *mut $type,
331+
init: impl $crate::init::__private::__InitImpl<$type, E, W>,
332+
) -> ::core::result::Result<(), E> {
333+
unsafe { $crate::init::__private::__InitImpl::__init(init, slot) }
334+
}
327335
)*
328336
}
329337
};

rust/kernel/sync/mutex.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ macro_rules! new_mutex {
3535
/// [`struct mutex`]: ../../../include/linux/mutex.h
3636
/// [init]: ../init/index.html
3737
#[pin_project]
38-
pub struct Mutex<T: ?Sized> {
38+
pub struct Mutex<T>
39+
where
40+
T: ?Sized,
41+
{
3942
/// The kernel `struct mutex` object.
4043
#[pin]
4144
mutex: Opaque<bindings::mutex>,

rust/kernel/sync/revocable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ where
107107
F: LockFactory,
108108
{
109109
#[pin]
110-
inner: F::LockedType<Inner<T>>,
110+
inner: <F as LockFactory>::LockedType<Inner<T>>,
111111
}
112112

113113
/// Safely initialises a [`Revocable`] instance with the given name, generating a new lock class.

rust/kernel/sync/rwsem.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ macro_rules! new_rwsemaphore {
4040
/// [`struct rw_semaphore`]: ../../../include/linux/rwsem.h
4141
/// [init]: ../init/index.html
4242
#[pin_project]
43-
pub struct RwSemaphore<T: ?Sized> {
43+
pub struct RwSemaphore<T>
44+
where
45+
T: ?Sized,
46+
{
4447
/// The kernel `struct rw_semaphore` object.
4548
#[pin]
4649
rwsem: Opaque<bindings::rw_semaphore>,

rust/kernel/sync/seqlock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ use core::{cell::UnsafeCell, marker::PhantomPinned, ops::Deref};
6262
/// }
6363
/// ```
6464
#[pin_project]
65-
pub struct SeqLock<L: ?Sized>
65+
pub struct SeqLock<L>
6666
where
67-
L: Lock,
67+
L: ?Sized + Lock,
6868
{
6969
#[pin]
7070
_p: PhantomPinned,

rust/kernel/sync/spinlock.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ macro_rules! new_spinlock {
8383
/// [`spinlock_t`]: ../../../include/linux/spinlock.h
8484
/// [init]: ../init/index.html
8585
#[pin_project]
86-
pub struct SpinLock<T: ?Sized> {
86+
pub struct SpinLock<T>
87+
where
88+
T: ?Sized,
89+
{
8790
#[pin]
8891
spin_lock: Opaque<bindings::spinlock>,
8992

@@ -274,7 +277,10 @@ macro_rules! new_rawspinlock {
274277
///
275278
/// [`raw_spinlock_t`]: ../../../include/linux/spinlock.h
276279
#[pin_project]
277-
pub struct RawSpinLock<T: ?Sized> {
280+
pub struct RawSpinLock<T>
281+
where
282+
T: ?Sized,
283+
{
278284
#[pin]
279285
spin_lock: Opaque<bindings::raw_spinlock>,
280286

0 commit comments

Comments
 (0)