Skip to content

Commit 90f4d79

Browse files
Assorted feature gate updates / other adjustments to fix compilation on the latest nightly compiler
1 parent 0fcb4d8 commit 90f4d79

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

demo/main_demo.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// of a single program.
1010
#![feature(
1111
const_fn_floating_point_arithmetic,
12-
const_fn_trait_bound,
1312
const_mut_refs,
1413
const_precise_live_drops,
1514
// Weirdly named feature, as it doesn't necessarily relate to `Cell` at all.

src/heap/heap_trait_impls.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ impl<T: Copy, const N: usize> const Clone for StaticHeap<T, N> {
3232

3333
#[inline(always)]
3434
fn clone_from(&mut self, source: &Self) {
35-
self.data.clone_from(&source.data);
35+
// Calling `clone_from` directly through `self.data` is not accepted by the compiler currently
36+
// for some reason in the context of this impl being `const`.
37+
unsafe {
38+
self
39+
.data
40+
.as_mut_ptr()
41+
.copy_from_nonoverlapping(source.data.as_ptr(), source.data.length);
42+
self.data.set_len(source.data.length);
43+
}
3644
}
3745
}
3846

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
const_assume,
3434
const_eval_select,
3535
const_fn_floating_point_arithmetic,
36-
const_fn_fn_ptr_basics,
37-
const_fn_trait_bound,
3836
const_intrinsic_copy,
3937
const_maybe_uninit_as_mut_ptr,
4038
const_maybe_uninit_assume_init,

src/string/string_trait_impls.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ impl<const N: usize> const Clone for StaticString<N> {
8080

8181
#[inline(always)]
8282
fn clone_from(&mut self, other: &Self) {
83-
self.vec.clone_from(&other.vec);
83+
// Calling `clone_from` directly through `self.vec` is not accepted by the compiler currently
84+
// for some reason in the context of this impl being `const`.
85+
unsafe {
86+
self
87+
.vec
88+
.as_mut_ptr()
89+
.copy_from_nonoverlapping(other.vec.as_ptr(), other.vec.length);
90+
self.vec.set_len(other.vec.length);
91+
}
8492
}
8593
}
8694

test/test_staticvec.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
adt_const_params,
44
box_syntax,
55
const_fn_floating_point_arithmetic,
6-
const_fn_trait_bound,
76
const_trait_impl,
87
exact_size_is_empty,
98
generic_const_exprs,
@@ -602,7 +601,7 @@ fn extend_from_slice() {
602601
assert_eq!(vec, [1, 2, 3, 4]);
603602
let mut vec2 = StaticVec::<i32, 0>::new();
604603
vec2.extend_from_slice(&[2, 3, 4]);
605-
assert_eq!(vec2, []);
604+
assert_eq!(vec2, []);
606605
}
607606

608607
#[test]
@@ -617,10 +616,10 @@ fn filled_with() {
617616
assert_eq!(v[1], 2);
618617
assert_eq!(v[2], 3);
619618
assert_eq!(v[3], 4);
620-
let v2 = StaticVec::<i32, 0>::filled_with(|| { 0 });
619+
let v2 = StaticVec::<i32, 0>::filled_with(|| 0);
621620
assert_eq!(v2.len(), 0);
622621
assert_eq!(v2.capacity(), 0);
623-
assert_eq!(v2.remaining_capacity(), 0);
622+
assert_eq!(v2.remaining_capacity(), 0);
624623
}
625624

626625
#[test]

0 commit comments

Comments
 (0)