about summary refs log tree commit diff
path: root/compiler/rustc_arena/src
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2021-03-17 10:28:52 -0400
committerJoshua Nelson <jyn514@gmail.com>2021-03-17 10:31:30 -0400
commit620ecc01a2eb28848f5f3d8039bdb1f23d8cc21f (patch)
treee20ad511734f529cc8dfafd1e009db4ced925a86 /compiler/rustc_arena/src
parent5c6d3bf3896b465e15550f49c2861e3d18102270 (diff)
Move some test-only code to test files
This also relaxes the bounds on some structs and moves them to the impl
block instead.
Diffstat (limited to 'compiler/rustc_arena/src')
-rw-r--r--compiler/rustc_arena/src/lib.rs16
-rw-r--r--compiler/rustc_arena/src/tests.rs18
2 files changed, 18 insertions, 16 deletions
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs
index 721cfdd4459..f99c05ce91f 100644
--- a/compiler/rustc_arena/src/lib.rs
+++ b/compiler/rustc_arena/src/lib.rs
@@ -297,22 +297,6 @@ impl<T> TypedArena<T> {
         }
     }
 
-    /// Clears the arena. Deallocates all but the longest chunk which may be reused.
-    pub fn clear(&mut self) {
-        unsafe {
-            // Clear the last chunk, which is partially filled.
-            let mut chunks_borrow = self.chunks.borrow_mut();
-            if let Some(mut last_chunk) = chunks_borrow.last_mut() {
-                self.clear_last_chunk(&mut last_chunk);
-                let len = chunks_borrow.len();
-                // If `T` is ZST, code below has no effect.
-                for mut chunk in chunks_borrow.drain(..len - 1) {
-                    chunk.destroy(chunk.entries);
-                }
-            }
-        }
-    }
-
     // Drops the contents of the last chunk. The last chunk is partially empty, unlike all other
     // chunks.
     fn clear_last_chunk(&self, last_chunk: &mut TypedArenaChunk<T>) {
diff --git a/compiler/rustc_arena/src/tests.rs b/compiler/rustc_arena/src/tests.rs
index e8a1f2db1a1..911e577c1ed 100644
--- a/compiler/rustc_arena/src/tests.rs
+++ b/compiler/rustc_arena/src/tests.rs
@@ -11,6 +11,24 @@ struct Point {
     z: i32,
 }
 
+impl<T> TypedArena<T> {
+    /// Clears the arena. Deallocates all but the longest chunk which may be reused.
+    fn clear(&mut self) {
+        unsafe {
+            // Clear the last chunk, which is partially filled.
+            let mut chunks_borrow = self.chunks.borrow_mut();
+            if let Some(mut last_chunk) = chunks_borrow.last_mut() {
+                self.clear_last_chunk(&mut last_chunk);
+                let len = chunks_borrow.len();
+                // If `T` is ZST, code below has no effect.
+                for mut chunk in chunks_borrow.drain(..len - 1) {
+                    chunk.destroy(chunk.entries);
+                }
+            }
+        }
+    }
+}
+
 #[test]
 pub fn test_unused() {
     let arena: TypedArena<Point> = TypedArena::default();