Skip to content

Commit dc2c508

Browse files
committed
fix(core): #[default_method_body_is_const] has been superseded by #[const_trait]
96964
1 parent c476c2a commit dc2c508

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

doc/toolchain_limitations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ const _: () = assert!(matches!((2..4).next(), Some(2)));
536536
```
537537

538538

539-
### `[tag:iterator_const_default]` `Iterator`'s methods lack `#[default_method_body_is_const]`
539+
### `[tag:iterator_const_default]` `Iterator` lack `#[const_trait]`
540540

541541
Implementing `const Iterator` requires you to implement all of its methods, which is impossible to do correctly.
542542

src/r3_core/src/bag.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
use core::mem::transmute;
33

44
/// A heterogeneous collection to store property values.
5+
#[const_trait]
56
pub trait Bag: private::Sealed + Copy {
67
/// Insert an item and return a new `impl Bag`.
78
///
89
/// For `const fn`-ness, this method can't have a provided implementation.
910
#[inline]
10-
#[default_method_body_is_const]
1111
fn insert<T: 'static>(self, head: T) -> List<T, Self> {
1212
assert!(self.get::<T>().is_none(), "duplicate entry");
1313
(head, self)

src/r3_core/src/utils/alloc.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,13 @@ pub struct AllocError;
225225
/// This trait is subject to [the kernel-side API stability guarantee][1].
226226
///
227227
/// [1]: crate#stability
228+
#[const_trait]
228229
pub unsafe trait Allocator {
229230
/// Attempts to allocate a block of memory.
230231
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>;
231232

232233
/// Behaves like `allocate`, but also ensures that the returned memory is
233234
/// zero-initialized.
234-
#[default_method_body_is_const]
235235
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
236236
let ptr = const_try_result!(self.allocate(layout));
237237
// SAFETY: `alloc` returns a valid memory block
@@ -251,7 +251,6 @@ pub unsafe trait Allocator {
251251
/// # Safety
252252
///
253253
/// See [`core::alloc::Allocator::grow`]'s documentation.
254-
#[default_method_body_is_const]
255254
unsafe fn grow(
256255
&self,
257256
ptr: NonNull<u8>,
@@ -284,7 +283,6 @@ pub unsafe trait Allocator {
284283
/// # Safety
285284
///
286285
/// See [`core::alloc::Allocator::grow_zeroed`]'s documentation.
287-
#[default_method_body_is_const]
288286
unsafe fn grow_zeroed(
289287
&self,
290288
ptr: NonNull<u8>,
@@ -316,7 +314,6 @@ pub unsafe trait Allocator {
316314
/// # Safety
317315
///
318316
/// See [`core::alloc::Allocator::shrink`]'s documentation.
319-
#[default_method_body_is_const]
320317
unsafe fn shrink(
321318
&self,
322319
ptr: NonNull<u8>,
@@ -344,7 +341,6 @@ pub unsafe trait Allocator {
344341
}
345342

346343
/// Creates a “by reference” adapter for this instance of `Allocator`.
347-
#[default_method_body_is_const]
348344
fn by_ref(&self) -> &Self
349345
where
350346
Self: Sized,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ mod veclike;
1111
pub use self::veclike::*;
1212

1313
/// Context type for [`BinaryHeap`]'s operations.
14+
#[const_trait]
1415
pub trait BinaryHeapCtx<Element> {
1516
/// Return `true` iff `x < y`.
1617
fn lt(&mut self, x: &Element, y: &Element) -> bool;
1718

1819
/// Called when the element `e` is moved to the new position `new_index`.
19-
#[default_method_body_is_const]
2020
fn on_move(&mut self, e: &mut Element, new_index: usize) {
2121
let _ = (e, new_index);
2222
}

0 commit comments

Comments
 (0)