Skip to content

Commit 669bd19

Browse files
committed
Remove that whole ~const bound thing
Definitely not worth it.
1 parent 6eca72c commit 669bd19

File tree

7 files changed

+4
-115
lines changed

7 files changed

+4
-115
lines changed

libs/context/src/collector.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,6 @@ unsafe impl<C: RawCollectorImpl> ::zerogc::CollectorId for CollectorId<C> {
336336
&*(self as *const CollectorId<C> as *const CollectorRef<C>)
337337
}
338338
}
339-
unsafe impl<C: ~const ConstRawCollectorImpl> const zerogc::internals::ConstCollectorId for CollectorId<C> {
340-
#[inline]
341-
fn resolve_array_len_const<T>(repr: &GcArray<'_, T, CollectorId<C>>) -> usize {
342-
C::resolve_array_len_const(repr)
343-
}
344-
}
345339
zerogc::impl_nulltrace_for_static!(CollectorId<C>, params => [C: RawCollectorImpl]);
346340

347341
pub struct WeakCollectorRef<C: RawCollectorImpl> {

libs/context/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
negative_impls, // !Send is much cleaner than `PhantomData<Rc>`
33
untagged_unions, // I want to avoid ManuallyDrop in unions
44
generic_associated_types, // Finally!
5-
const_trait_impl,
65
ptr_metadata
76
)]
87
#![allow(

src/array.rs

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use core::fmt::{self, Formatter, Debug, Display};
88
use core::hash::{Hash, Hasher};
99
use core::marker::PhantomData;
1010

11-
use crate::{CollectorId, internals::ConstCollectorId, GcSafe, GcRebrand, Gc};
11+
use crate::{CollectorId, GcSafe, GcRebrand, Gc};
1212
use zerogc_derive::{Trace, unsafe_gc_impl};
1313

1414
use self::repr::{GcArrayPtr};
@@ -64,29 +64,6 @@ impl<'gc, Id: CollectorId> GcString<'gc, Id> {
6464
unsafe { str::from_utf8_unchecked(self.as_bytes().as_slice()) }
6565
}
6666
}
67-
/// Const access to [GcString]
68-
pub trait ConstStringAccess<'gc> {
69-
/// Get this string as a slice of bytes
70-
fn as_bytes_const(&self) -> &'gc [u8];
71-
/// Convert this string to a `str` slice
72-
fn as_str_const(&self) -> &'gc str;
73-
/// Get the length of this string (in bytes)
74-
fn len_const(&self) -> usize;
75-
}
76-
impl<'gc, Id: ~const ConstCollectorId> const ConstStringAccess<'gc> for GcString<'gc, Id> {
77-
#[inline]
78-
fn as_bytes_const(&self) -> &'gc [u8] {
79-
self.bytes.as_slice_const()
80-
}
81-
#[inline]
82-
fn as_str_const(&self) -> &'gc str {
83-
unsafe { str::from_utf8_unchecked(self.as_bytes_const()) }
84-
}
85-
#[inline]
86-
fn len_const(&self) -> usize {
87-
self.bytes.len_const()
88-
}
89-
}
9067
impl<'gc, Id: CollectorId> Deref for GcString<'gc, Id> {
9168
type Target = str;
9269
#[inline]
@@ -180,59 +157,6 @@ unsafe impl<'gc, T, Id> Sync for GcArray<'gc, T, Id>
180157
where T: Sync, Id: CollectorId + Sync {}
181158
unsafe impl<'gc, T, Id> Send for GcArray<'gc, T, Id>
182159
where T: Sync, Id: CollectorId + Sync {}
183-
/// Const access to [GcString]
184-
pub trait ConstArrayAccess<'gc, T> {
185-
/// The value of the array as a slice
186-
fn as_slice_const<'a>(&self) -> &'a [T] where 'gc: 'a;
187-
/// Load a raw pointer to the array's value
188-
fn as_raw_ptr_const(&self) -> *mut T;
189-
/// The length of this array
190-
fn len_const(&self) -> usize;
191-
}
192-
// Relax T: GcSafe bound
193-
impl<'gc, T, Id: ~const ConstCollectorId> const ConstArrayAccess<'gc, T> for GcArray<'gc, T, Id> {
194-
#[inline]
195-
fn as_slice_const<'a>(&self) -> &'a [T] where 'gc: 'a {
196-
/*
197-
* TODO: This is horrible, but currently nessicarry
198-
* to do this in a const-fn context.
199-
*/
200-
match Id::ArrayPtr::UNCHECKED_KIND {
201-
repr::ArrayPtrKind::Fat => {
202-
unsafe {
203-
core::mem::transmute_copy::<
204-
Id::ArrayPtr,
205-
&'a [T]
206-
>(&self.ptr)
207-
}
208-
},
209-
repr::ArrayPtrKind::Thin => {
210-
unsafe {
211-
let ptr = core::mem::transmute_copy::<
212-
Id::ArrayPtr,
213-
NonNull<T>
214-
>(&self.ptr);
215-
&*core::ptr::slice_from_raw_parts(
216-
ptr.as_ptr(),
217-
Id::resolve_array_len_const(
218-
self
219-
)
220-
)
221-
}
222-
},
223-
}
224-
}
225-
/// Load a raw pointer to the array's value
226-
#[inline]
227-
fn as_raw_ptr_const(&self) -> *mut T {
228-
self.as_slice_const().as_ptr() as *mut T
229-
}
230-
/// Load the length of the array
231-
#[inline]
232-
fn len_const(&self) -> usize {
233-
self.as_slice_const().len()
234-
}
235-
}
236160
impl<'gc, T, I, Id: CollectorId> Index<I> for GcArray<'gc, T, Id>
237161
where I: SliceIndex<[T]> {
238162
type Output = I::Output;

src/epsilon.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ mod alloc;
1313
mod handle;
1414

1515

16-
use crate::{CollectorId, GcContext, GcSafe, GcSimpleAlloc, GcSystem, Trace, internals::ConstCollectorId};
16+
use crate::{CollectorId, GcContext, GcSafe, GcSimpleAlloc, GcSystem, Trace};
1717
use std::ptr::NonNull;
1818
use std::alloc::Layout;
1919
use std::rc::Rc;
@@ -382,12 +382,6 @@ pub struct EpsilonCollectorId {
382382
_priv: ()
383383
}
384384
crate::impl_nulltrace_for_static!(EpsilonCollectorId);
385-
unsafe impl const ConstCollectorId for EpsilonCollectorId {
386-
#[inline]
387-
fn resolve_array_len_const<T>(repr: &GcArray<'_, T>) -> usize {
388-
unsafe { repr.as_internal_ptr_repr() }.len()
389-
}
390-
}
391385
unsafe impl CollectorId for EpsilonCollectorId {
392386
type System = EpsilonSystem;
393387
type Context = EpsilonContext;

src/internals.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
alloc_layout_extra,
1111
const_mut_refs,
1212
const_option,
13-
const_trait_impl, // EXPERIMENTAL: const Deref
1413
const_slice_from_raw_parts,
1514
const_transmute_copy,
1615
slice_range, // Convenient for bounds checking :)
@@ -78,7 +77,6 @@ pub mod prelude;
7877
pub mod epsilon;
7978
pub mod array;
8079
pub mod vec;
81-
pub mod internals;
8280
#[cfg(feature = "errors")]
8381
pub mod errors;
8482
#[cfg(feature = "allocator-api")]
@@ -675,7 +673,7 @@ pub unsafe trait CollectorId: Copy + Eq + Hash + Debug + NullTrace + TrustedDrop
675673
type RawVec<'gc, T: GcSafe<'gc, Self>>: crate::vec::raw::GcRawVec<'gc, T, Id=Self>;
676674
/// The raw representation of `GcArray` pointers
677675
/// in this collector.
678-
type ArrayPtr: ~const crate::array::repr::GcArrayPtr<Id=Self>;
676+
type ArrayPtr: crate::array::repr::GcArrayPtr<Id=Self>;
679677

680678
/// Get the runtime id of the collector that allocated the [Gc]
681679
///
@@ -869,7 +867,7 @@ unsafe impl<'gc, T: ?Sized + GcSafe<'gc, Id>, Id: CollectorId> Trace for Gc<'gc,
869867
}
870868
}
871869
}
872-
impl<'gc, T: GcSafe<'gc, Id> + ?Sized, Id: CollectorId> const Deref for Gc<'gc, T, Id> {
870+
impl<'gc, T: GcSafe<'gc, Id> + ?Sized, Id: CollectorId> Deref for Gc<'gc, T, Id> {
873871
type Target = T;
874872

875873
#[inline(always)]

tests/epsilon.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
#![feature(const_trait_impl)]
21
use std::fmt::Debug;
32

43
use zerogc_derive::Trace;
54

65
use zerogc::{
76
Gc, GcArray, GcSimpleAlloc, safepoint_recurse,
87
};
9-
use zerogc::array::ConstArrayAccess;
108
use zerogc::epsilon::{self, EpsilonCollectorId, EpsilonContext, EpsilonSystem};
119

1210
#[derive(Trace)]
@@ -73,11 +71,5 @@ fn static_alloc() {
7371
recurse_array(&ctx, &*FOO, array);
7472
}
7573

76-
pub const fn const_gc<'gc, T: 'gc>(gc: Gc<'gc, T, EpsilonCollectorId>) {
77-
gc.value();
78-
}
7974

80-
pub const fn const_array<'gc, T: 'gc>(gc: GcArray<'gc, T, EpsilonCollectorId>) {
81-
gc.as_slice_const();
82-
}
8375

0 commit comments

Comments
 (0)