From 7cc05f16265237a42f98062c64755d4832412316 Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:32:10 +0000 Subject: [PATCH] fix(data_structures): fix compilation failure on older Rust versions (#6526) I thought I was being clever, but too clever = stupid. The dummy code designed to flag when our MSRV is bumped and supports `NonNull::add` would fail to compile on Rust versions below 1.80.0. Precisely because of the condition this code is testing - it's not supported! Fix this by skipping compilation unless running clippy. --- crates/oxc_data_structures/src/stack/non_null.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/oxc_data_structures/src/stack/non_null.rs b/crates/oxc_data_structures/src/stack/non_null.rs index fdc6ca05202b9..573e0fe4c5ada 100644 --- a/crates/oxc_data_structures/src/stack/non_null.rs +++ b/crates/oxc_data_structures/src/stack/non_null.rs @@ -14,8 +14,9 @@ use std::{cmp::Ordering, ptr::NonNull as NativeNonNull}; #[derive(Debug)] pub struct NonNull(NativeNonNull); -#[expect(dead_code, clippy::incompatible_msrv)] -unsafe fn non_null_add_is_not_stable(ptr: NativeNonNull) -> NativeNonNull { +#[cfg(clippy)] +#[expect(clippy::incompatible_msrv)] +unsafe fn _non_null_add_is_not_stable(ptr: NativeNonNull) -> NativeNonNull { ptr.add(1) }