Skip to content

Commit 2c40e82

Browse files
committed
Move TypedArena declaration next to its impls.
1 parent 56a99fa commit 2c40e82

File tree

1 file changed

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

1 file changed

+17
-17
lines changed

compiler/rustc_arena/src/lib.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,6 @@ fn outline<F: FnOnce() -> R, R>(f: F) -> R {
4444
f()
4545
}
4646

47-
/// An arena that can hold objects of only one type.
48-
pub struct TypedArena<T> {
49-
/// A pointer to the next object to be allocated.
50-
ptr: Cell<*mut T>,
51-
52-
/// A pointer to the end of the allocated area. When this pointer is
53-
/// reached, a new chunk is allocated.
54-
end: Cell<*mut T>,
55-
56-
/// A vector of arena chunks.
57-
chunks: RefCell<Vec<ArenaChunk<T>>>,
58-
59-
/// Marker indicating that dropping the arena causes its owned
60-
/// instances of `T` to be dropped.
61-
_own: PhantomData<T>,
62-
}
63-
6447
struct ArenaChunk<T = u8> {
6548
/// The raw storage for the arena chunk.
6649
storage: NonNull<[MaybeUninit<T>]>,
@@ -130,6 +113,23 @@ impl<T> ArenaChunk<T> {
130113
const PAGE: usize = 4096;
131114
const HUGE_PAGE: usize = 2 * 1024 * 1024;
132115

116+
/// An arena that can hold objects of only one type.
117+
pub struct TypedArena<T> {
118+
/// A pointer to the next object to be allocated.
119+
ptr: Cell<*mut T>,
120+
121+
/// A pointer to the end of the allocated area. When this pointer is
122+
/// reached, a new chunk is allocated.
123+
end: Cell<*mut T>,
124+
125+
/// A vector of arena chunks.
126+
chunks: RefCell<Vec<ArenaChunk<T>>>,
127+
128+
/// Marker indicating that dropping the arena causes its owned
129+
/// instances of `T` to be dropped.
130+
_own: PhantomData<T>,
131+
}
132+
133133
impl<T> Default for TypedArena<T> {
134134
/// Creates a new `TypedArena`.
135135
fn default() -> TypedArena<T> {

0 commit comments

Comments
 (0)