Clean up code for Clippy on Rust 1.31

The latest version of Clippy introduced some new lints, and will now
complain about the deprecated syntax. Unfortunately, the new tool_lints
syntax doesn't work on older Rust versions so we can not yet start
using it.

This commit also refactors various disabled Clippy lints away. Some of
the disable lines are still necessary as Clippy is overly pedantic, but
this at least gets rid of a large portion of them.
parent f0b6fde0
Pipeline #39256581 failed with stages
in 21 minutes and 2 seconds
......@@ -31,7 +31,11 @@ test:
clippy:
touch src/lib.rs
${CARGO_CMD} clippy -- -Dwarnings
${CARGO_CMD} clippy -- -Dwarnings \
-Arenamed_and_removed_lints \
-Aclippy::new_without_default \
-Aclippy::new_without_default_derive \
-Aclippy::needless_range_loop
rustfmt-check:
rustfmt --check src/lib.rs src/bin/ivm.rs
......
......@@ -23,7 +23,6 @@ fn print_stderr(message: &str) {
stderr.flush().unwrap();
}
#[cfg_attr(feature = "cargo-clippy", allow(print_literal))]
fn run() -> i32 {
let args: Vec<String> = env::args().collect();
let mut options = Options::new();
......@@ -82,7 +81,8 @@ fn run() -> i32 {
config.populate_from_env();
let machine = Machine::default(State::new(config, &matches.free[1..]));
let machine =
Machine::default(State::with_rc(config, &matches.free[1..]));
machine.start(path);
machine.state.current_exit_status()
......
......@@ -34,7 +34,7 @@ pub type RcBinding = ArcWithoutWeak<Binding>;
impl Binding {
/// Returns a new binding.
pub fn new(locals: usize, receiver: ObjectPointer) -> RcBinding {
pub fn with_rc(locals: usize, receiver: ObjectPointer) -> RcBinding {
let bind = Binding {
locals: UnsafeCell::new(Chunk::new(locals)),
receiver,
......@@ -59,7 +59,7 @@ impl Binding {
}
/// Sets a local variable.
pub fn set_local(&self, index: usize, value: ObjectPointer) {
pub fn set_local(&mut self, index: usize, value: ObjectPointer) {
self.locals_mut()[index] = value;
}
......@@ -95,8 +95,7 @@ impl Binding {
}
/// Returns a mutable reference to this binding's local variables.
#[cfg_attr(feature = "cargo-clippy", allow(mut_from_ref))]
pub fn locals_mut(&self) -> &mut Chunk<ObjectPointer> {
pub fn locals_mut(&mut self) -> &mut Chunk<ObjectPointer> {
unsafe { &mut *self.locals.get() }
}
......@@ -146,7 +145,6 @@ impl Binding {
}
// Moves all pointers in this binding to the given heap.
#[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
pub fn move_pointers_to<H: CopyObject>(&mut self, heap: &mut H) {
if let Some(ref mut bind) = self.parent {
bind.move_pointers_to(heap);
......@@ -212,7 +210,7 @@ mod tests {
use object_value;
fn binding_with_parent(parent: RcBinding, locals: usize) -> RcBinding {
let mut binding = Binding::new(locals, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(locals, ObjectPointer::integer(1));
binding.parent = Some(parent.clone());
......@@ -221,14 +219,14 @@ mod tests {
#[test]
fn test_new() {
let binding = Binding::new(2, ObjectPointer::integer(1));
let binding = Binding::with_rc(2, ObjectPointer::integer(1));
assert_eq!(binding.locals().len(), 2);
}
#[test]
fn test_with_parent() {
let binding1 = Binding::new(0, ObjectPointer::integer(1));
let binding1 = Binding::with_rc(0, ObjectPointer::integer(1));
let binding2 = binding_with_parent(binding1.clone(), 1);
assert!(binding2.parent.is_some());
......@@ -238,7 +236,7 @@ mod tests {
#[test]
fn test_get_local_valid() {
let ptr = ObjectPointer::integer(5);
let binding = Binding::new(1, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(1, ObjectPointer::integer(1));
binding.set_local(0, ptr);
......@@ -248,7 +246,7 @@ mod tests {
#[test]
fn test_set_local() {
let ptr = ObjectPointer::integer(5);
let binding = Binding::new(1, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(1, ObjectPointer::integer(1));
binding.set_local(0, ptr);
......@@ -257,7 +255,7 @@ mod tests {
#[test]
fn test_local_exists_non_existing_local() {
let binding = Binding::new(1, ObjectPointer::integer(1));
let binding = Binding::with_rc(1, ObjectPointer::integer(1));
assert_eq!(binding.local_exists(0), false);
}
......@@ -265,7 +263,7 @@ mod tests {
#[test]
fn test_local_exists_existing_local() {
let ptr = ObjectPointer::integer(5);
let binding = Binding::new(1, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(1, ObjectPointer::integer(1));
binding.set_local(0, ptr);
......@@ -274,14 +272,14 @@ mod tests {
#[test]
fn test_parent_without_parent() {
let binding = Binding::new(0, ObjectPointer::integer(1));
let binding = Binding::with_rc(0, ObjectPointer::integer(1));
assert!(binding.parent().is_none());
}
#[test]
fn test_parent_with_parent() {
let binding1 = Binding::new(0, ObjectPointer::integer(1));
let binding1 = Binding::with_rc(0, ObjectPointer::integer(1));
let binding2 = binding_with_parent(binding1, 0);
assert!(binding2.parent().is_some());
......@@ -289,14 +287,14 @@ mod tests {
#[test]
fn test_find_parent_without_parent() {
let binding = Binding::new(0, ObjectPointer::integer(1));
let binding = Binding::with_rc(0, ObjectPointer::integer(1));
assert!(binding.find_parent(0).is_none());
}
#[test]
fn test_find_parent_with_parent() {
let binding1 = Binding::new(0, ObjectPointer::integer(1));
let binding1 = Binding::with_rc(0, ObjectPointer::integer(1));
let binding2 = binding_with_parent(binding1, 0);
let binding3 = binding_with_parent(binding2, 0);
let binding4 = binding_with_parent(binding3, 0);
......@@ -316,7 +314,7 @@ mod tests {
#[test]
fn test_locals() {
let ptr = ObjectPointer::integer(5);
let binding = Binding::new(1, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(1, ObjectPointer::integer(1));
binding.set_local(0, ptr);
......@@ -326,7 +324,7 @@ mod tests {
#[test]
fn test_locals_mut() {
let ptr = ObjectPointer::integer(5);
let binding = Binding::new(1, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(1, ObjectPointer::integer(1));
binding.set_local(0, ptr);
......@@ -336,16 +334,16 @@ mod tests {
#[test]
fn test_push_pointers() {
let mut alloc =
LocalAllocator::new(GlobalAllocator::new(), &Config::new());
LocalAllocator::new(GlobalAllocator::with_rc(), &Config::new());
let local1 = alloc.allocate_empty();
let receiver = alloc.allocate_empty();
let binding1 = Binding::new(1, receiver);
let mut binding1 = Binding::with_rc(1, receiver);
binding1.set_local(0, local1);
let local2 = alloc.allocate_empty();
let mut binding2 = Binding::new(1, receiver);
let mut binding2 = Binding::with_rc(1, receiver);
binding2.parent = Some(binding1.clone());
binding2.set_local(0, local2);
......@@ -364,19 +362,19 @@ mod tests {
#[test]
fn test_pointers() {
let mut alloc =
LocalAllocator::new(GlobalAllocator::new(), &Config::new());
LocalAllocator::new(GlobalAllocator::with_rc(), &Config::new());
let b1_local1 = alloc.allocate_empty();
let b1_local2 = alloc.allocate_empty();
let receiver = alloc.allocate_empty();
let b1 = Binding::new(2, receiver);
let mut b1 = Binding::with_rc(2, receiver);
b1.set_local(0, b1_local1);
b1.set_local(1, b1_local2);
let b2_local1 = alloc.allocate_empty();
let b2_local2 = alloc.allocate_empty();
let mut b2 = Binding::new(2, receiver);
let mut b2 = Binding::with_rc(2, receiver);
b2.parent = Some(b1.clone());
b2.set_local(0, b2_local1);
......@@ -397,7 +395,7 @@ mod tests {
#[test]
fn test_clone_to() {
let global_alloc = GlobalAllocator::new();
let global_alloc = GlobalAllocator::with_rc();
let mut alloc1 =
LocalAllocator::new(global_alloc.clone(), &Config::new());
let mut alloc2 = LocalAllocator::new(global_alloc, &Config::new());
......@@ -406,8 +404,8 @@ mod tests {
let ptr2 = alloc1.allocate_without_prototype(object_value::float(2.0));
let ptr3 = alloc1.allocate_without_prototype(object_value::float(8.0));
let src_bind1 = Binding::new(1, ptr3);
let mut src_bind2 = Binding::new(1, ptr3);
let mut src_bind1 = Binding::with_rc(1, ptr3);
let mut src_bind2 = Binding::with_rc(1, ptr3);
src_bind2.parent = Some(src_bind1.clone());
src_bind1.set_local(0, ptr1);
......@@ -431,7 +429,7 @@ mod tests {
#[test]
fn test_move_pointers_to() {
let galloc = GlobalAllocator::new();
let galloc = GlobalAllocator::with_rc();
let mut alloc1 = LocalAllocator::new(galloc.clone(), &Config::new());
let mut alloc2 = LocalAllocator::new(galloc, &Config::new());
......@@ -439,8 +437,8 @@ mod tests {
let ptr2 = alloc1.allocate_without_prototype(object_value::float(2.0));
let ptr3 = alloc1.allocate_without_prototype(object_value::float(8.0));
let src_bind1 = Binding::new(1, ptr3);
let mut src_bind2 = Binding::new(1, ptr3);
let mut src_bind1 = Binding::with_rc(1, ptr3);
let mut src_bind2 = Binding::with_rc(1, ptr3);
src_bind2.parent = Some(src_bind1.clone());
src_bind1.set_local(0, ptr1);
......@@ -460,7 +458,7 @@ mod tests {
#[test]
fn test_receiver_with_receiver() {
let pointer = ObjectPointer::integer(5);
let binding = Binding::new(1, pointer);
let binding = Binding::with_rc(1, pointer);
assert!(binding.receiver == pointer);
}
......
......@@ -88,7 +88,7 @@ pub type BytecodeResult = ParserResult<CompiledCode>;
///
/// # Examples
///
/// let state = State::new(Config::new(), &[]);
/// let state = State::with_rc(Config::new(), &[]);
/// let result = bytecode_parser::parse_file(&state, "path/to/file.inkoc");
pub fn parse_file(state: &RcState, path: &str) -> BytecodeResult {
match File::open(path) {
......@@ -102,7 +102,7 @@ pub fn parse_file(state: &RcState, path: &str) -> BytecodeResult {
/// # Examples
///
/// let mut bytes = File::open("path/to/file.inkoc").unwrap().bytes();
/// let state = State::new(Config::new(), &[]);
/// let state = State::with_rc(Config::new(), &[]);
/// let result = bytecode_parser::parse(&state, &mut bytes);
pub fn parse<T: Read>(state: &RcState, bytes: &mut Bytes<T>) -> BytecodeResult {
// Verify the bytecode signature.
......@@ -165,7 +165,6 @@ fn read_bool<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<bool> {
Ok(u8::from_be(value) == 1)
}
#[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
fn read_u16<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<u16> {
let mut buff: [u8; 2] = [0, 0];
......@@ -178,7 +177,6 @@ fn read_u16<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<u16> {
Ok(u16::from_be(value))
}
#[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
fn read_u16_as_usize<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<usize> {
let mut buff: [u8; 2] = [0, 0];
......@@ -191,7 +189,6 @@ fn read_u16_as_usize<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<usize> {
Ok(u16::from_be(value) as usize)
}
#[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
fn read_i64<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<i64> {
let mut buff: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];
......@@ -208,7 +205,6 @@ fn read_u64<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<u64> {
Ok(read_i64(bytes)? as u64)
}
#[cfg_attr(feature = "cargo-clippy", allow(needless_range_loop))]
fn read_f64<T: Read>(bytes: &mut Bytes<T>) -> ParserResult<f64> {
let mut buff: [u8; 8] = [0, 0, 0, 0, 0, 0, 0, 0];
......@@ -284,7 +280,7 @@ fn read_compiled_code<T: Read>(
return Err(ParserError::MissingReturnInstruction(
file_string,
line,
))
));
}
};
} else {
......@@ -390,7 +386,7 @@ mod tests {
use vm::state::{RcState, State};
fn state() -> RcState {
State::new(Config::new(), &[])
State::with_rc(Config::new(), &[])
}
macro_rules! unwrap {
......
......@@ -3,8 +3,6 @@
//! A CatchTable is used to track which instruction sequences may catch a value
//! that is being thrown. Whenever the VM finds a match it will jump to a target
//! instruction, set a register, and continue execution.
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
pub struct CatchEntry {
/// The start position of the instruction range for which to catch a value.
pub start: usize,
......
......@@ -172,7 +172,7 @@ mod tests {
use vm::state::{RcState, State};
fn state() -> RcState {
State::new(Config::new(), &[])
State::with_rc(Config::new(), &[])
}
fn new_compiled_code(state: &RcState) -> CompiledCode {
......
......@@ -6,8 +6,6 @@
//!
//! These settings are all stored in the Config struct, allowing various parts
//! of the VM to easily access these configuration details.
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
use immix::block::BLOCK_SIZE;
use num_cpus;
use std::env;
......
......@@ -79,7 +79,7 @@ impl ExecutionContext {
pub fn from_isolated_block(block: &Block) -> ExecutionContext {
ExecutionContext {
register: Register::new(block.code.registers as usize),
binding: Binding::new(block.locals(), block.receiver),
binding: Binding::with_rc(block.locals(), block.receiver),
code: block.code,
deferred_blocks: Vec::new(),
parent: None,
......
......@@ -28,7 +28,7 @@
//! use ffi::{Library;
//! use process::Process;
//!
//! let state = State::new(Config::new());
//! let state = State::with_rc(Config::new());
//! let process = Process.new(...);
//!
//! let lib = Library.new("libc.so.6").unwrap();
......@@ -310,7 +310,7 @@ pub enum Argument {
impl Argument {
// Creates a new Argument wrapping the value of `ptr` according to the needs
// of the FFI type specified in `ffi_type`.
unsafe fn new(
unsafe fn wrap(
ffi_type: *mut ffi_type,
ptr: ObjectPointer,
) -> Result<Argument, String> {
......@@ -435,11 +435,11 @@ impl Library {
names.push(name.string_value()?.as_slice());
}
Self::new(&names)
Self::open(&names)
}
/// Opens a library using one or more possible names.
pub fn new<P: AsRef<OsStr> + Debug + Display>(
pub fn open<P: AsRef<OsStr> + Debug + Display>(
search_for: &[P],
) -> Result<RcLibrary, String> {
let mut errors = Vec::new();
......@@ -665,11 +665,11 @@ impl Function {
ffi_arg_types.push(ffi_type_for(*ptr)?);
}
Self::new(func_ptr, ffi_arg_types, ffi_rtype)
Self::create(func_ptr, ffi_arg_types, ffi_rtype)
}
/// Creates a new prepared function.
pub unsafe fn new(
pub unsafe fn create(
pointer: Pointer,
arguments: Vec<TypePointer>,
return_type: TypePointer,
......@@ -720,7 +720,7 @@ impl Function {
let mut arguments = Vec::with_capacity(arg_ptrs.len());
for (index, arg) in arg_ptrs.iter().enumerate() {
arguments.push(Argument::new(self.arguments[index], *arg)?);
arguments.push(Argument::wrap(self.arguments[index], *arg)?);
}
// libffi expects an array of _pointers_ to the arguments to pass,
......@@ -804,12 +804,12 @@ mod tests {
#[test]
fn test_library_new() {
assert!(Library::new(&[LIBM]).is_ok());
assert!(Library::open(&[LIBM]).is_ok());
}
#[test]
fn test_library_get() {
let lib = Library::new(&[LIBM]).unwrap();
let lib = Library::open(&[LIBM]).unwrap();
let sym = unsafe { lib.get("floor") };
assert!(sym.is_ok());
......@@ -817,12 +817,12 @@ mod tests {
#[test]
fn test_function_new() {
let lib = Library::new(&[LIBM]).unwrap();
let lib = Library::open(&[LIBM]).unwrap();
unsafe {
let sym = lib.get("floor").unwrap();
let fun = Function::new(
let fun = Function::create(
sym,
vec![&mut types::double],
&mut types::double,
......@@ -844,13 +844,13 @@ mod tests {
#[test]
fn test_function_call() {
let lib = Library::new(&[LIBM]).unwrap();
let lib = Library::open(&[LIBM]).unwrap();
let (machine, _, process) = setup();
let arg = process.allocate_without_prototype(object_value::float(3.15));
unsafe {
let sym = lib.get("floor").unwrap();
let fun = Function::new(
let fun = Function::create(
sym,
vec![&mut types::double],
&mut types::double,
......@@ -898,7 +898,7 @@ mod tests_for_all_platforms {
#[test]
fn test_library_new_invalid() {
let lib = Library::new(&["inko-test-1", "inko-test-2"]);
let lib = Library::open(&["inko-test-1", "inko-test-2"]);
assert!(lib.is_err());
}
......
......@@ -170,7 +170,7 @@ mod tests {
#[test]
fn test_collect() {
let (_machine, _block, process) = setup();
let state = State::new(Config::new(), &[]);
let state = State::with_rc(Config::new(), &[]);
let pointer = process.allocate_empty();
let mut profile = Profile::young();
......@@ -495,7 +495,7 @@ mod tests {
let receiver = process.allocate_empty();
let code = process.context().code.clone();
let binding = Binding::new(1, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(1, ObjectPointer::integer(1));
binding.set_local(0, local);
......@@ -526,7 +526,7 @@ mod tests {
let receiver = process.allocate_empty();
let code = process.context().code.clone();
let binding = Binding::new(1, ObjectPointer::integer(1));
let mut binding = Binding::with_rc(1, ObjectPointer::integer(1));
binding.set_local(0, local);
......
......@@ -61,7 +61,7 @@ mod tests {
#[test]
fn test_collect() {
let (_machine, _block, process) = setup();
let state = State::new(Config::new(), &[]);
let state = State::with_rc(Config::new(), &[]);
let mut profile = Profile::young();
let local_data = process.local_data_mut();
......
......@@ -101,7 +101,7 @@ mod tests {
#[test]
fn test_new() {
let (_machine, _block, process) = setup();
let state = State::new(Config::new(), &[]);
let state = State::with_rc(Config::new(), &[]);
let request = Request::new(CollectionType::Heap, state, process);
assert!(match request.collection_type {
......@@ -113,7 +113,7 @@ mod tests {
#[test]
fn test_heap() {
let (_machine, _block, process) = setup();
let state = State::new(Config::new(), &[]);
let state = State::with_rc(Config::new(), &[]);
let request = Request::heap(state, process);
assert!(match request.collection_type {
......@@ -125,7 +125,7 @@ mod tests {
#[test]
fn test_mailbox() {
let (_machine, _block, process) = setup();
let state = State::new(Config::new(), &[]);
let state = State::with_rc(Config::new(), &[]);
let request = Request::mailbox(state, process);
assert!(match request.collection_type {
......@@ -137,7 +137,7 @@ mod tests {
#[test]
fn test_perform() {
let (_machine, _block, process) = setup();
let state = State::new(Config::new(), &[]);
let state = State::with_rc(Config::new(), &[]);
let mut request = Request::heap(state, process.clone());
process.set_register(0, process.allocate_empty());
......
//! Statistics produced by tracing object graphs.
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
use std::ops::Add;
pub struct TraceResult {
......
......@@ -15,8 +15,6 @@
//! performance drastically compared to just prefetching one pointer at a time.
//! In the best case scenario using this technique can improve tracing
//! performance by 20-30%.
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
use object_pointer::ObjectPointerPointer;
use prefetch;
use std::collections::VecDeque;
......
//! Scopes for module-local global variables.
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
use deref_pointer::DerefPointer;
use object_pointer::ObjectPointer;
use std::cell::UnsafeCell;
......@@ -36,7 +34,7 @@ impl GlobalScope {
}
/// Sets a global variable.
pub fn set(&self, index: usize, value: ObjectPointer) {
pub fn set(&mut self, index: usize, value: ObjectPointer) {
if !value.is_permanent() {
panic!("Only permanent objects can be stored in a global scope");
}
......@@ -54,8 +52,7 @@ impl GlobalScope {
unsafe { &*self.variables.get() }
}
#[cfg_attr(feature = "cargo-clippy", allow(mut_from_ref))]
fn locals_mut(&self) -> &mut Vec<ObjectPointer> {
fn locals_mut(&mut self) -> &mut Vec<ObjectPointer> {
unsafe { &mut *self.variables.get() }
}
}
......@@ -80,9 +77,9 @@ mod tests {
#[test]
#[should_panic]
fn test_set_not_permanent() {
let scope = GlobalScope::new();
let mut scope = GlobalScope::new();
let mut alloc =
LocalAllocator::new(GlobalAllocator::new(), &Config::new());
LocalAllocator::new(GlobalAllocator::with_rc(), &Config::new());
let pointer = alloc.allocate_empty();
scope.set(0, pointer);
......@@ -90,7 +87,7 @@ mod tests {
#[test]
fn test_get_set() {
let scope = GlobalScope::new();
let mut scope = GlobalScope::new();
scope.set(0, ObjectPointer::integer(5));
......
//! Types and methods for hashing objects.
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default_derive))]
use num_bigint::BigInt;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher as HasherTrait};
......
......@@ -4,7 +4,6 @@
//! in use. An ObjectMap is used for marking objects and can hold at most 1024
//! entries while a LineMap is used for marking lines and can hold at most 256
//! entries.
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default))]
/// The number of entries in an object map.
const OBJECT_ENTRIES: usize = 1024;
......
......@@ -105,8 +105,7 @@ impl BlockHeader {
/// Returns a mutable reference to the block.
#[inline(always)]
#[cfg_attr(feature = "cargo-clippy", allow(mut_from_ref))]
pub fn block_mut(&self) -> &mut Block {
pub fn block_mut(&mut self) -> &mut Block {
unsafe { &mut *self.block }
}
......@@ -183,7 +182,7 @@ unsafe impl Sync for Block {}
impl Block {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
pub fn new() -> Box<Block> {
pub fn boxed() -> Box<Block> {
let layout = unsafe { heap_layout_for_block() };
let lines = unsafe { alloc::alloc(layout) as RawObjectPointer };
......@@ -659,7 +658,7 @@ mod tests {
#[test]
fn test_block_header_new() {
let mut block = Block::new();
let mut block = Block::boxed();
let header = BlockHeader::new(&mut *block as *mut Block);
assert_eq!(header.block.is_null(), false);
......@@ -667,7 +666,7 @@ mod tests {
#[test]
fn test_block_header_block() {
let mut block = Block::new();
let mut block = Block::boxed();
let header = BlockHeader::new(&mut *block as *mut Block);
assert_eq!(header.block().holes(), 1);
......@@ -675,15 +674,15 @@ mod tests {
#[test]
fn test_block_header_block_mut() {
let mut block = Block::new();
let header = BlockHeader::new(&mut *block as *mut Block);
let mut block = Block::boxed();
let mut header = BlockHeader::new(&mut *block as *mut Block);
assert_eq!(header.block_mut().holes(), 1);
}
#[test]
fn test_block_new() {
let block = Block::new();
let block = Block::boxed();
assert_eq!(block.lines.is_null(), false);
assert_eq!(block.free_pointer().is_null(), false);
......@@ -693,7 +692,7 @@ mod tests {
#[test]
fn test_block_prepare_for_collection() {
let mut block = Block::new();
let mut block = Block::boxed();
block.used_lines_bitmap.set(1);
block.marked_objects_bitmap.set(1);
......@@ -705,7 +704,7 @@ mod tests {
#[test]
fn test_block_update_line_map() {
let mut block = Block::new();
let mut block = Block::boxed();
block.used_lines_bitmap.set(1);
block.prepare_for_collection();
......@@ -716,14 +715,14 @@ mod tests {
#[test]
fn test_block_bucket_without_bucket() {
let block = Block::new();
let block = Block::boxed();
assert!(block.bucket().is_none());
}
#[test]
fn test_block_bucket_with_bucket() {
let mut block = Block::new();
let mut block = Block::boxed();
let mut bucket = Bucket::new();
block.set_bucket(&mut bucket as *mut Bucket);
......@@ -733,7 +732,7 @@ mod tests {