Skip to content

Commit 0c17893

Browse files
committed
Rename TypedArenaChunk as ArenaChunk.
Because it's used within both `TypedArena` and `DroplessArena`. The commit also makes `<u8>` the default parameter.
1 parent 84322ef commit 0c17893

File tree

1 file changed

+9
-9
lines changed
  • compiler/rustc_arena/src

1 file changed

+9
-9
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,24 @@ pub struct TypedArena<T> {
4545
end: Cell<*mut T>,
4646

4747
/// A vector of arena chunks.
48-
chunks: RefCell<Vec<TypedArenaChunk<T>>>,
48+
chunks: RefCell<Vec<ArenaChunk<T>>>,
4949

5050
/// Marker indicating that dropping the arena causes its owned
5151
/// instances of `T` to be dropped.
5252
_own: PhantomData<T>,
5353
}
5454

55-
struct TypedArenaChunk<T> {
55+
struct ArenaChunk<T = u8> {
5656
/// The raw storage for the arena chunk.
5757
storage: Box<[MaybeUninit<T>]>,
5858
/// The number of valid entries in the chunk.
5959
entries: usize,
6060
}
6161

62-
impl<T> TypedArenaChunk<T> {
62+
impl<T> ArenaChunk<T> {
6363
#[inline]
64-
unsafe fn new(capacity: usize) -> TypedArenaChunk<T> {
65-
TypedArenaChunk { storage: Box::new_uninit_slice(capacity), entries: 0 }
64+
unsafe fn new(capacity: usize) -> ArenaChunk<T> {
65+
ArenaChunk { storage: Box::new_uninit_slice(capacity), entries: 0 }
6666
}
6767

6868
/// Destroys this arena chunk.
@@ -272,7 +272,7 @@ impl<T> TypedArena<T> {
272272
// Also ensure that this chunk can fit `additional`.
273273
new_cap = cmp::max(additional, new_cap);
274274

275-
let mut chunk = TypedArenaChunk::<T>::new(new_cap);
275+
let mut chunk = ArenaChunk::<T>::new(new_cap);
276276
self.ptr.set(chunk.start());
277277
self.end.set(chunk.end());
278278
chunks.push(chunk);
@@ -281,7 +281,7 @@ impl<T> TypedArena<T> {
281281

282282
// Drops the contents of the last chunk. The last chunk is partially empty, unlike all other
283283
// chunks.
284-
fn clear_last_chunk(&self, last_chunk: &mut TypedArenaChunk<T>) {
284+
fn clear_last_chunk(&self, last_chunk: &mut ArenaChunk<T>) {
285285
// Determine how much was filled.
286286
let start = last_chunk.start() as usize;
287287
// We obtain the value of the pointer to the first uninitialized element.
@@ -340,7 +340,7 @@ pub struct DroplessArena {
340340
end: Cell<*mut u8>,
341341

342342
/// A vector of arena chunks.
343-
chunks: RefCell<Vec<TypedArenaChunk<u8>>>,
343+
chunks: RefCell<Vec<ArenaChunk>>,
344344
}
345345

346346
unsafe impl Send for DroplessArena {}
@@ -378,7 +378,7 @@ impl DroplessArena {
378378
// Also ensure that this chunk can fit `additional`.
379379
new_cap = cmp::max(additional, new_cap);
380380

381-
let mut chunk = TypedArenaChunk::<u8>::new(new_cap);
381+
let mut chunk = ArenaChunk::new(new_cap);
382382
self.start.set(chunk.start());
383383
self.end.set(chunk.end());
384384
chunks.push(chunk);

0 commit comments

Comments
 (0)