Skip to content

Commit 674e364

Browse files
authored
Migrate to Rust 2021 edition (#181)
Notably, imports relative to the current crate starts with `crate::`. Also changed some macro definitions to use `$crate::` to refer to identifiers in the current crate.
1 parent 00ffbae commit 674e364

15 files changed

+45
-48
lines changed

mmtk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "mmtk_jikesrvm"
33
version = "0.26.0"
44
authors = [" <>"]
55
rust-version = "1.71.1"
6+
edition = "2021"
67

78
[lib]
89
name = "mmtk_jikesrvm"

mmtk/src/active_plan.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use collection::VMCollection;
2-
use entrypoint::*;
1+
use crate::collection::VMCollection;
2+
use crate::entrypoint::*;
3+
use crate::JikesRVM;
4+
use crate::JTOC_BASE;
35
use mmtk::util::opaque_pointer::*;
46
use mmtk::util::Address;
57
use mmtk::vm::ActivePlan;
68
use mmtk::Mutator;
79
use std::mem;
8-
use JikesRVM;
9-
use JTOC_BASE;
1010

1111
use std::sync::{Mutex, MutexGuard};
1212

mmtk/src/api.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
use crate::collection::VMCollection;
2+
use crate::collection::BOOT_THREAD;
13
use crate::object_model::JikesObj;
24
use crate::scanning::SLOTS_BUFFER_CAPACITY;
3-
use collection::VMCollection;
4-
use collection::BOOT_THREAD;
5+
use crate::JikesRVM;
6+
use crate::BUILDER;
7+
use crate::JTOC_BASE;
8+
use crate::SINGLETON;
59
use libc::c_char;
610
use libc::c_void;
711
use mmtk::memory_manager;
@@ -13,10 +17,6 @@ use mmtk::Mutator;
1317
use std::convert::TryFrom;
1418
use std::ffi::CStr;
1519
use std::sync::atomic::Ordering;
16-
use JikesRVM;
17-
use BUILDER;
18-
use JTOC_BASE;
19-
use SINGLETON;
2020

2121
/// # Safety
2222
/// Caller needs to make sure the ptr is a valid vector pointer.

mmtk/src/collection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use entrypoint::*;
1+
use crate::entrypoint::*;
2+
use crate::JikesRVM;
3+
use crate::JTOC_BASE;
24
use mmtk::util::alloc::AllocationError;
35
use mmtk::util::opaque_pointer::*;
46
use mmtk::util::Address;
57
use mmtk::vm::ActivePlan;
68
use mmtk::vm::{Collection, GCThreadContext};
79
use mmtk::Mutator;
8-
use JikesRVM;
9-
use JTOC_BASE;
1010

1111
use crate::jikesrvm_calls;
1212

mmtk/src/heap_layout_constants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use boot_image_size::CODE_SIZE_ADJUSTMENT;
2-
use boot_image_size::DATA_SIZE_ADJUSTMENT;
1+
use crate::boot_image_size::CODE_SIZE_ADJUSTMENT;
2+
use crate::boot_image_size::DATA_SIZE_ADJUSTMENT;
33
use mmtk::util::Address;
44

55
/** The traditional 32-bit heap layout */

mmtk/src/java_header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use java_header_constants;
2-
use java_header_constants::*;
1+
use crate::java_header_constants;
2+
use crate::java_header_constants::*;
33
use std::sync::atomic::AtomicUsize;
44

55
pub const SCALAR_HEADER_SIZE: usize = JAVA_HEADER_BYTES + OTHER_HEADER_BYTES;

mmtk/src/java_header_constants.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use crate::java_size_constants::*;
2+
use crate::memory_manager_constants;
3+
use crate::memory_manager_constants::*;
4+
use crate::misc_header_constants::*;
15
use crate::unboxed_size_constants::*;
2-
use java_size_constants::*;
3-
use memory_manager_constants;
4-
use memory_manager_constants::*;
5-
use misc_header_constants::*;
66

77
/** Number of bytes in object's TIB pointer */
88
pub const TIB_BYTES: usize = BYTES_IN_ADDRESS;

mmtk/src/jikesrvm_calls/helpers.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use crate::object_model::JikesObj;
1313
#[macro_export]
1414
macro_rules! jtoc_call {
1515
($offset:ident, $tls:ident $(, $arg:ident)*) => ({
16-
use JTOC_BASE;
17-
let call_addr = (JTOC_BASE + $offset).load::<fn()>();
16+
let call_addr = ($crate::JTOC_BASE + $offset).load::<fn()>();
1817
jikesrvm_call!(call_addr, $tls $(, $arg)*)
1918
});
2019
}
@@ -23,8 +22,7 @@ macro_rules! jtoc_call {
2322
#[macro_export]
2423
macro_rules! jikesrvm_instance_call {
2524
($obj:ident, $offset:ident, $tls:ident $(, $arg:ident)*) => ({
26-
use java_header::TIB_OFFSET;
27-
let tib = ($obj + TIB_OFFSET).load::<Address>();
25+
let tib = ($obj + $crate::java_header::TIB_OFFSET).load::<Address>();
2826
let call_addr = (tib + $offset).load::<fn()>();
2927
jikesrvm_call!(call_addr, $tls $(, $arg)*)
3028
});

mmtk/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate libc;
2-
extern crate mmtk;
31
#[macro_use]
42
extern crate lazy_static;
53
#[macro_use]
@@ -13,8 +11,8 @@ use mmtk::vm::VMBinding;
1311
use mmtk::MMTKBuilder;
1412
use mmtk::MMTK;
1513

16-
use collection::BOOT_THREAD;
17-
use object_model::JikesObj;
14+
use crate::collection::BOOT_THREAD;
15+
use crate::object_model::JikesObj;
1816

1917
pub mod active_plan;
2018
pub mod api;

mmtk/src/misc_header_constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::memory_manager_constants::*;
12
use crate::unboxed_size_constants::*;
2-
use memory_manager_constants::*;
33

44
/* amount by which tracing causes headers to grow */
55
// XXX: workaround for not having const if-expressions

0 commit comments

Comments
 (0)