Skip to content

Commit 3bb2017

Browse files
committed
fix: mark some traits with #[const_trait]
Implementing `const Trait` requires `Trait` to be marked with `#[const_trait]` starting from [rust-lang/rust#100982][1]. [1]: rust-lang/rust#100982
1 parent 3b0f163 commit 3bb2017

File tree

12 files changed

+26
-0
lines changed

12 files changed

+26
-0
lines changed

src/r3/src/sync/source.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use r3_core::{
1919
/// This trait is unstable.
2020
///
2121
/// [1]: crate::sync::mutex::StaticMutex
22+
#[const_trait]
2223
pub trait Source<System> {
2324
type Target: 'static;
2425

src/r3_core/src/bag.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl<Left: ~const Bag, Right: ~const Bag> const Bag for Either<Left, Right> {
8181
mod private {
8282
use super::Bag;
8383

84+
#[const_trait]
8485
pub trait Sealed {}
8586

8687
impl const Sealed for () {}

src/r3_core/src/bind.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ impl<'pool, System, T> DivideBind<'pool, System, T> {
706706
/// This trait is covered by the application-side API stability guarantee.
707707
/// External implementation of this trait is not allowed.
708708
#[doc = include_str!("./common.md")]
709+
#[const_trait]
709710
pub trait UnzipBind {
710711
type Target;
711712
/// Destruct [`Bind`][] into individual bindings.
@@ -1072,6 +1073,7 @@ enum BindBorrowType {
10721073
///
10731074
/// At any point of time, the provided [`Closure`] must never be invoked by two
10741075
/// threads simultaneously. It can be called for multiple times, however.
1076+
#[const_trait]
10751077
pub unsafe trait ExecutableDefiner: Sized + private::Sealed {
10761078
/// Use the specified function as the entry point of the executable object
10771079
/// being defined.
@@ -1081,6 +1083,7 @@ pub unsafe trait ExecutableDefiner: Sized + private::Sealed {
10811083
mod private {
10821084
use super::*;
10831085

1086+
#[const_trait]
10841087
pub trait Sealed {}
10851088

10861089
impl<System: raw::KernelBase> const Sealed for kernel::task::TaskDefiner<System> {}
@@ -1118,6 +1121,7 @@ unsafe impl<System: raw::KernelTimer> const ExecutableDefiner
11181121
/// attach an entry point with materialized [bindings][1].
11191122
///
11201123
/// [1]: Bind
1124+
#[const_trait]
11211125
pub trait ExecutableDefinerExt {
11221126
/// Use the specified function with dependency as the entry point of the
11231127
/// executable object being defined.
@@ -1160,6 +1164,7 @@ impl<T: ~const ExecutableDefiner> const ExecutableDefinerExt for T {
11601164
///
11611165
/// This trait is covered by the application-side API stability guarantee with
11621166
/// the exception of its members, which are implementation details.
1167+
#[const_trait]
11631168
pub trait FnBind<Binder> {
11641169
type Output: 'static;
11651170
type BoundFn: FnOnce() -> Self::Output + Copy + Send + 'static;
@@ -1393,6 +1398,7 @@ where
13931398
///
13941399
/// [1]: Bind
13951400
/// [2]: index.html#binders
1401+
#[const_trait]
13961402
pub trait Binder {
13971403
/// The runtime representation of `Self`.
13981404
///

src/r3_core/src/bind/sorter.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use crate::utils::{
6161
Init,
6262
};
6363

64+
#[const_trait]
6465
pub(super) trait SorterCallback {
6566
/// Push a binding to the end of the initialization order.
6667
fn push_bind_order(&mut self, bind_i: usize);
@@ -535,11 +536,13 @@ pub(super) const fn sort_bindings<Callback, SorterUseInfoList, VertexList>(
535536
// `const Iterator` is currently very hard to implement
536537
// [ref:iterator_const_default]
537538
/// An [`Iterator`][] usable in `const fn`.
539+
#[const_trait]
538540
trait MyIterator {
539541
type Item;
540542
fn next(&mut self) -> Option<Self::Item>;
541543
}
542544

545+
#[const_trait]
543546
trait GraphAccess<VertexRef> {
544547
type VertexIter<'a>: ~const MyIterator<Item = VertexRef> + ~const Destruct + 'a
545548
where
@@ -566,6 +569,7 @@ impl Init for TopologicalSortVertexInfo {
566569
};
567570
}
568571

572+
#[const_trait]
569573
trait TopologicalSortOutputSink<VertexRef> {
570574
fn push(&mut self, v: VertexRef);
571575
}

src/r3_core/src/closure.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ unsafe extern "C" fn trampoline_indirect<T: FnOnce()>(env: ClosureEnv) {
209209
/// // `(usize, impl FnOnce(usize))` → `Closure`
210210
/// const _: Closure = (42usize, |_: usize| {}).into_closure_const();
211211
/// ```
212+
#[const_trait]
212213
pub trait IntoClosureConst {
213214
/// Perform conversion to [`Closure`], potentially using a compile-time
214215
/// heap.

src/r3_core/src/kernel/cfg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ macro array_item_from_fn($(
763763
/// todo!()
764764
/// }
765765
/// ```
766+
#[const_trait]
766767
pub trait CfgStatic: ~const raw_cfg::CfgBase<System: KernelStatic> {}
767768

768769
impl<C> const CfgStatic for C

src/r3_core/src/kernel/macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ macro_rules! define_object {
7878
/// [`$&Name`][] and [`$&NameRef`][].
7979
///
8080
/// [`$&RawId`]: $&Trait::$&RawId
81+
#[const_trait]
8182
pub unsafe trait $NameHandle {
8283
/// The system type this object pertains to.
8384
type System: $Trait;

src/r3_core/src/kernel/raw_cfg.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ use crate::{bag::Bag, closure::Closure, kernel::raw, time::Duration, utils::Phan
5454
/// [2]: crate::kernel::cfg::KernelStatic
5555
/// [3]: self#stability
5656
/// [4]: self#safety
57+
#[const_trait]
5758
pub unsafe trait CfgBase {
5859
type System: raw::KernelBase;
5960
fn num_task_priority_levels(&mut self, new_value: usize);
@@ -81,6 +82,7 @@ pub unsafe trait CfgBase {
8182
/// [2]: crate::kernel::cfg::KernelStatic
8283
/// [3]: self#stability
8384
/// [4]: self#safety
85+
#[const_trait]
8486
pub unsafe trait CfgTask: ~const CfgBase {
8587
fn task_define<Properties: ~const Bag>(
8688
&mut self,
@@ -114,6 +116,7 @@ pub struct TaskDescriptor<System> {
114116
/// [2]: crate::kernel::cfg::KernelStatic
115117
/// [3]: self#stability
116118
/// [4]: self#safety
119+
#[const_trait]
117120
pub unsafe trait CfgEventGroup: ~const CfgBase<System: raw::KernelEventGroup> {
118121
fn event_group_define<Properties: ~const Bag>(
119122
&mut self,
@@ -145,6 +148,7 @@ pub struct EventGroupDescriptor<System> {
145148
/// [2]: crate::kernel::cfg::KernelStatic
146149
/// [3]: self#stability
147150
/// [4]: self#safety
151+
#[const_trait]
148152
pub unsafe trait CfgMutex: ~const CfgBase<System: raw::KernelMutex> {
149153
fn mutex_define<Properties: ~const Bag>(
150154
&mut self,
@@ -175,6 +179,7 @@ pub struct MutexDescriptor<System> {
175179
/// [2]: crate::kernel::cfg::KernelStatic
176180
/// [3]: self#stability
177181
/// [4]: self#safety
182+
#[const_trait]
178183
pub unsafe trait CfgSemaphore: ~const CfgBase<System: raw::KernelSemaphore> {
179184
fn semaphore_define<Properties: ~const Bag>(
180185
&mut self,
@@ -207,6 +212,7 @@ pub struct SemaphoreDescriptor<System> {
207212
/// [2]: crate::kernel::cfg::KernelStatic
208213
/// [3]: self#stability
209214
/// [4]: self#safety
215+
#[const_trait]
210216
pub unsafe trait CfgTimer: ~const CfgBase<System: raw::KernelTimer> {
211217
fn timer_define<Properties: ~const Bag>(
212218
&mut self,
@@ -240,6 +246,7 @@ pub struct TimerDescriptor<System> {
240246
/// [2]: crate::kernel::cfg::KernelStatic
241247
/// [3]: self#stability
242248
/// [4]: self#safety
249+
#[const_trait]
243250
pub unsafe trait CfgInterruptLine: ~const CfgBase<System: raw::KernelInterruptLine> {
244251
fn interrupt_line_define<Properties: ~const Bag>(
245252
&mut self,

src/r3_core/src/utils/alloc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ impl ConstAllocator {
162162
}
163163

164164
/// The trait for types accepted by [`ConstAllocator::with_inner`].
165+
#[const_trait]
165166
trait FnOnceConstAllocator {
166167
type Output;
167168
fn call(self, allocator: &ConstAllocator) -> Self::Output;

src/r3_core/src/utils/binary_heap/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ impl<T: ~const Ord + ~const PartialOrd> const BinaryHeapCtx<T> for () {
2929
}
3030

3131
/// Min-heap.
32+
#[const_trait]
3233
pub trait BinaryHeap: VecLike {
3334
/// Remove the least item from the heap and return it.
3435
fn heap_pop<Ctx>(&mut self, ctx: Ctx) -> Option<Self::Element>

0 commit comments

Comments
 (0)