Skip to content

Commit f9b85bc

Browse files
authored
Fix style check for Rust 1.80 (#1178)
1 parent 9a49d6a commit f9b85bc

14 files changed

+21
-58
lines changed

.github/scripts/ci-style.sh

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ export RUSTFLAGS="-D warnings -A unknown-lints"
66
cargo fmt -- --check
77
cargo fmt --manifest-path=macros/Cargo.toml -- --check
88

9-
# All versions of Clippy randomly crash on Darwin. We disable Clippy tests for Darwin for now.
10-
if [[ $(uname) == "Darwin" ]]; then
11-
exit 0
12-
fi
13-
149
# Workaround the clippy issue on Rust 1.72: https://github.com/mmtk/mmtk-core/issues/929.
1510
# If we are not testing with Rust 1.72, or there is no problem running the following clippy checks, we can remove this export.
1611
CLIPPY_VERSION=$(cargo clippy --version)

.github/workflows/api-check.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ jobs:
3535
- run: cargo +nightly --version
3636

3737
- name: Install cargo-public-api
38-
run: cargo install cargo-public-api
38+
run: cargo +nightly install cargo-public-api
3939
- name: API Diff
40-
run: cargo public-api diff origin/${GITHUB_BASE_REF}..${{ github.event.pull_request.head.sha }} --deny=all
40+
run: cargo +nightly public-api diff origin/${GITHUB_BASE_REF}..${{ github.event.pull_request.head.sha }} --deny=all
4141

4242
check-api-migration-update:
4343
needs: check-public-api-changes

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pfm = { version = "0.1.1", optional = true }
4545
portable-atomic = "1.4.3"
4646
probe = "0.5"
4747
regex = "1.7.0"
48+
rustversion = "1.0"
4849
spin = "0.9.5"
4950
static_assertions = "1.1.0"
5051
strum = "0.26.2"

src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ extern crate strum_macros;
3333
extern crate lazy_static;
3434
#[macro_use]
3535
extern crate log;
36-
#[cfg(target = "x86_64-unknown-linux-gnu")]
37-
extern crate atomic;
3836
extern crate atomic_traits;
3937
extern crate crossbeam;
4038
extern crate num_cpus;

src/memory_manager.rs

+1
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ pub fn find_object_from_internal_pointer<VM: VMBinding>(
644644
/// - only MMTk can allocate into, or
645645
/// - only MMTk's delegated memory allocator (such as a malloc implementation) can allocate into
646646
/// for allocation requests from MMTk.
647+
///
647648
/// Return false otherwise. This function never panics.
648649
///
649650
/// Particularly, if this function returns true, `object` cannot be an object allocated by the VM

src/mmtk.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,13 @@ impl<VM: VMBinding> MMTK<VM> {
257257
/// requires the users to do some preparation before calling it.
258258
///
259259
/// - **Multi-threading**: If `fork()` is called when the process has multiple threads, it
260-
/// will only duplicate the current thread into the child process, and the child process can
261-
/// only call async-signal-safe functions, notably `exec()`. For VMs that that use
262-
/// multi-process concurrency, it is imperative that when calling `fork()`, only one thread may
263-
/// exist in the process.
260+
/// will only duplicate the current thread into the child process, and the child process can
261+
/// only call async-signal-safe functions, notably `exec()`. For VMs that that use
262+
/// multi-process concurrency, it is imperative that when calling `fork()`, only one thread may
263+
/// exist in the process.
264264
///
265265
/// - **File descriptors**: The child process inherits copies of the parent's set of open
266-
/// file descriptors. This may or may not be desired depending on use cases.
266+
/// file descriptors. This may or may not be desired depending on use cases.
267267
///
268268
/// This function helps VMs that use `fork()` for multi-process concurrency. It instructs all
269269
/// GC threads to save their contexts and return from their entry-point functions. Currently,

src/util/heap/blockpageresource.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ impl<B: Region> BlockPool<B> {
402402

403403
/// Iterate all the blocks in the BlockQueue
404404
pub fn iterate_blocks(&self, f: &mut impl FnMut(B)) {
405-
for array in &*self.head_global_freed_blocks.read() {
406-
array.iterate_blocks(f)
405+
if let Some(array) = &*self.head_global_freed_blocks.read() {
406+
array.iterate_blocks(f);
407407
}
408408
for array in &*self.global_freed_blocks.read() {
409409
array.iterate_blocks(f);

src/util/heap/monotonepageresource.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<VM: VMBinding> PageResource<VM> for MonotonePageResource<VM> {
8585
sync.cursor, sync.sentinel, sync.current_chunk
8686
);
8787

88-
if cfg!(debug = "true") {
88+
if cfg!(debug_assertions) {
8989
/*
9090
* Cursor should always be zero, or somewhere in the current chunk. If we have just
9191
* allocated exactly enough pages to exhaust the current chunk, then cursor can point

src/util/malloc/library.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// Export one of the malloc libraries.
22

3-
#[cfg(feature = "malloc_hoard")]
4-
pub use self::hoard::*;
53
#[cfg(feature = "malloc_jemalloc")]
64
pub use self::jemalloc::*;
7-
#[cfg(not(any(
8-
feature = "malloc_jemalloc",
9-
feature = "malloc_mimalloc",
10-
feature = "malloc_hoard",
11-
)))]
5+
#[cfg(not(any(feature = "malloc_jemalloc", feature = "malloc_mimalloc",)))]
126
pub use self::libc_malloc::*;
137
#[cfg(feature = "malloc_mimalloc")]
148
pub use self::mimalloc::*;
@@ -48,24 +42,8 @@ mod mimalloc {
4842
pub use mimalloc_sys::mi_malloc_usable_size as malloc_usable_size;
4943
}
5044

51-
#[cfg(feature = "malloc_hoard")]
52-
mod hoard {
53-
// Normal 4K page
54-
pub const LOG_BYTES_IN_MALLOC_PAGE: u8 = crate::util::constants::LOG_BYTES_IN_PAGE;
55-
// ANSI C
56-
pub use hoard_sys::{calloc, free, malloc, realloc};
57-
// Posix
58-
pub use hoard_sys::posix_memalign;
59-
// GNU
60-
pub use hoard_sys::malloc_usable_size;
61-
}
62-
6345
/// If no malloc lib is specified, use the libc implementation
64-
#[cfg(not(any(
65-
feature = "malloc_jemalloc",
66-
feature = "malloc_mimalloc",
67-
feature = "malloc_hoard",
68-
)))]
46+
#[cfg(not(any(feature = "malloc_jemalloc", feature = "malloc_mimalloc",)))]
6947
mod libc_malloc {
7048
// Normal 4K page
7149
pub const LOG_BYTES_IN_MALLOC_PAGE: u8 = crate::util::constants::LOG_BYTES_IN_PAGE;

src/util/malloc/malloc_ms_util.rs

-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ pub fn alloc<VM: VMBinding>(size: usize, align: usize, offset: usize) -> (Addres
7777
debug_assert!(address.is_aligned_to(align));
7878
} else if align > 16 && offset == 0 {
7979
address = align_alloc(size, align);
80-
#[cfg(feature = "malloc_hoard")]
81-
{
82-
is_offset_malloc = true;
83-
}
8480
debug_assert!(
8581
address.is_aligned_to(align),
8682
"Address: {:x} is not aligned to the given alignment: {}",

src/util/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ macro_rules! options {
222222
///
223223
/// Arguments:
224224
/// * `options`: a string that is key value pairs separated by white spaces or commas, e.g. `threads=1 stress_factor=4096`,
225-
/// or `threads=1,stress_factor=4096`
225+
/// or `threads=1,stress_factor=4096`
226226
pub fn set_bulk_from_command_line(&mut self, options: &str) -> bool {
227227
for opt in options.replace(",", " ").split_ascii_whitespace() {
228228
let kv_pair: Vec<&str> = opt.split('=').collect();

src/util/rust_util/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ pub const fn min_of_usize(a: usize, b: usize) -> usize {
1414
}
1515
}
1616

17-
#[cfg(feature = "nightly")]
18-
use core::intrinsics::{likely, unlikely};
17+
#[rustversion::nightly]
18+
pub use core::intrinsics::{likely, unlikely};
1919

2020
// likely() and unlikely() compiler hints in stable Rust
2121
// [1]: https://github.com/rust-lang/hashbrown/blob/a41bd76de0a53838725b997c6085e024c47a0455/src/raw/mod.rs#L48-L70
2222
// [2]: https://users.rust-lang.org/t/compiler-hint-for-unlikely-likely-for-if-branches/62102/3
23-
#[cfg(not(feature = "nightly"))]
23+
#[rustversion::not(nightly)]
2424
#[cold]
2525
fn cold() {}
2626

27-
#[cfg(not(feature = "nightly"))]
27+
#[rustversion::not(nightly)]
2828
pub fn likely(b: bool) -> bool {
2929
if !b {
3030
cold();
3131
}
3232
b
3333
}
34-
#[cfg(not(feature = "nightly"))]
34+
#[rustversion::not(nightly)]
3535
pub fn unlikely(b: bool) -> bool {
3636
if b {
3737
cold();

src/vm/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! lto = true
1414
//! ```
1515
//! 2. Make sure that the crate type for a VM binding supports LTO. To our knowledge, `staticlib` and `cdylib` support LTO, and
16-
//! `rlib` does *not* support LTO.
16+
//! `rlib` does *not* support LTO.
1717
1818
mod active_plan;
1919
mod collection;

src/vm/tests/mock_tests/mock_test_malloc_ms.rs

-6
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ fn test_malloc() {
1818
assert!((address4 + 4_isize).is_aligned_to(64));
1919

2020
assert!(!bool1);
21-
#[cfg(feature = "malloc_hoard")]
22-
assert!(bool2);
23-
#[cfg(not(feature = "malloc_hoard"))]
2421
assert!(!bool2);
2522
assert!(bool3);
2623
assert!(bool4);
@@ -33,9 +30,6 @@ fn test_malloc() {
3330
unsafe {
3431
malloc_ms_util::free(address1.to_mut_ptr());
3532
}
36-
#[cfg(feature = "malloc_hoard")]
37-
malloc_ms_util::offset_free(address2);
38-
#[cfg(not(feature = "malloc_hoard"))]
3933
unsafe {
4034
malloc_ms_util::free(address2.to_mut_ptr());
4135
}

0 commit comments

Comments
 (0)