Skip to content

Commit 7fe0e05

Browse files
authored
Move lint config to Cargo.toml. Adapt to Rust 1.88 (#1335)
This PR fixes issues for Rust 1.88 style check. * Move lint configurations to Cargo.toml from `lib.rs` (Lint configs in `Cargo.toml` is effective for the `bench` source code, but `lib.rs` does not effect `bench`) * Disable `uninlined_format_args`. * Allow one more case of `mut_from_ref`, identified by clippy. * Set `enum-map` to `2.7.3` (We use `EnumMap::from_fn`. [`2.7.3`](https://docs.rs/enum-map/latest/enum_map/struct.EnumMap.html#method.from_fn) has this function, but [`2.6.3`](https://docs.rs/enum-map/2.6.3/enum_map/struct.EnumMap.html#) does not have this function)
1 parent efe7b41 commit 7fe0e05

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

Cargo.toml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cfg-if = "1.0"
2828
crossbeam = "0.8.1"
2929
delegate = "0.13.2"
3030
downcast-rs = "2.0.1"
31-
enum-map = "2.4.2"
31+
enum-map = "2.7.3"
3232
env_logger = { version = "0.11.3", optional = true }
3333
is-terminal = "0.4.7"
3434
itertools = "0.14.0"
@@ -77,6 +77,23 @@ built = { version = "0.7.7", features = ["git2"] }
7777
# We move away from ICU4X completely following the instruction in https://docs.rs/crate/idna_adapter/1.2.0
7878
idna_adapter = "=1.1.0"
7979

80+
[lints.clippy]
81+
# Allow this. Clippy suggests we should use Sft, Mmtk, rather than SFT and MMTK.
82+
# According to its documentation (https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms),
83+
# with upper-case-acronyms-aggressive turned on, it should also warn us about SFTMap, VMBinding, GCWorker.
84+
# However, it seems clippy does not catch all these patterns at the moment. So it would be hard for us to
85+
# find all the patterns and consistently change all of them. I think it would be a better idea to just allow this.
86+
# We may reconsider this in the future. Plus, using upper case letters for acronyms does not sound a big issue
87+
# to me - considering it will break our API and all the efforts for all the developers to make the change, it may
88+
# not worth it.
89+
upper_case_acronyms = "allow"
90+
# Temporarily allow this -- 9 July 2025. Clippy suggests that we should always inline format args if possible.
91+
# We see pushbacks on this lint in Rust 1.67, and the lint was downgraded to pedantic in 1.67.1. It was upgraded
92+
# again in Rust 1.88. We temporarily disable this lint and see the reaction from the community.
93+
# If there is no pushback for this lint in a few momnths' time, we should remove the following line and migrate the codebase.
94+
# See https://github.com/mmtk/mmtk-core/issues/1334.
95+
uninlined_format_args = "allow"
96+
8097
[[bench]]
8198
name = "main"
8299
harness = false

src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
// Allow this for now. Clippy suggests we should use Sft, Mmtk, rather than SFT and MMTK.
2-
// According to its documentation (https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms),
3-
// with upper-case-acronyms-aggressive turned on, it should also warn us about SFTMap, VMBinding, GCWorker.
4-
// However, it seems clippy does not catch all these patterns at the moment. So it would be hard for us to
5-
// find all the patterns and consistently change all of them. I think it would be a better idea to just allow this.
6-
// We may reconsider this in the future. Plus, using upper case letters for acronyms does not sound a big issue
7-
// to me - considering it will break our API and all the efforts for all the developers to make the change, it may
8-
// not worth it.
9-
#![allow(clippy::upper_case_acronyms)]
101
// Use the `{likely, unlikely}` provided by compiler when using nightly
112
#![cfg_attr(feature = "nightly", feature(core_intrinsics))]
123

src/util/heap/layout/map32.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ impl Map32 {
265265
&mut *self.inner.get()
266266
}
267267

268+
/// Get a mutable reference to the inner Map32Inner with a lock.
269+
/// The caller should only use the mutable reference while holding the lock.
270+
#[allow(clippy::mut_from_ref)]
268271
fn mut_self_with_sync(&self) -> (MutexGuard<()>, &mut Map32Inner) {
269272
let guard = self.sync.lock().unwrap();
270273
(guard, unsafe { self.mut_self() })

0 commit comments

Comments
 (0)