Skip to content

Commit

Permalink
Apply unqualified_local_imports lint
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Nov 21, 2024
1 parent 464f393 commit 13e9580
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 47 deletions.
2 changes: 1 addition & 1 deletion bench/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ mod intrinsics;
#[path = "../../src/imp/fallback/mod.rs"]
mod seqlock_fallback;
#[allow(unused_imports)]
use seqlock_fallback as fallback;
use self::seqlock_fallback as fallback;
#[allow(dead_code, unused_imports)]
#[path = "imp/spinlock_fallback.rs"]
mod spinlock_fallback;
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#[path = "version.rs"]
mod version;
use version::{rustc_version, Version};
use self::version::{rustc_version, Version};

use std::{env, str};

Expand Down
2 changes: 1 addition & 1 deletion portable-atomic-util/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#[allow(dead_code)]
#[path = "version.rs"]
mod version;
use version::{rustc_version, Version};
use self::version::{rustc_version, Version};

use std::env;

Expand Down
2 changes: 1 addition & 1 deletion portable-atomic-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extern crate std as alloc;
#[cfg_attr(docsrs, doc(cfg(any(feature = "alloc", feature = "std"))))]
mod arc;
#[cfg(any(all(feature = "alloc", not(portable_atomic_no_alloc)), feature = "std"))]
pub use arc::{Arc, Weak};
pub use self::arc::{Arc, Weak};

#[cfg(not(portable_atomic_no_futures_api))]
#[cfg(any(all(feature = "alloc", not(portable_atomic_no_alloc)), feature = "std"))]
Expand Down
2 changes: 1 addition & 1 deletion src/cfgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ mod check {
crate::cfg_has_atomic_cas! { type __AtomicPtr = (); }
crate::cfg_no_atomic_cas! { type __AtomicPtr = (); }
#[allow(unused_imports)]
use {
use self::{
_Atomic128 as _, _Atomic16 as _, _Atomic32 as _, _Atomic64 as _, _Atomic8 as _,
_AtomicPtr as _, __AtomicPtr as _,
};
Expand Down
18 changes: 9 additions & 9 deletions src/imp/atomic128/aarch64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ Note:
// if compile_time(FEAT_LSE2) => ldp:
// cfg guarantee that the CPU supports FEAT_LSE2.
#[cfg(any(target_feature = "lse2", portable_atomic_target_feature = "lse2"))]
use _atomic_load_ldp as atomic_load;
use self::_atomic_load_ldp as atomic_load;
#[cfg(not(any(target_feature = "lse2", portable_atomic_target_feature = "lse2")))]
#[inline]
unsafe fn atomic_load(src: *mut u128, order: Ordering) -> u128 {
Expand Down Expand Up @@ -883,7 +883,7 @@ Note:
// if compile_time(FEAT_LSE2) => stp:
// cfg guarantee that the CPU supports FEAT_LSE2.
#[cfg(any(target_feature = "lse2", portable_atomic_target_feature = "lse2"))]
use _atomic_store_stp as atomic_store;
use self::_atomic_store_stp as atomic_store;
#[cfg(not(any(target_feature = "lse2", portable_atomic_target_feature = "lse2")))]
#[inline]
unsafe fn atomic_store(dst: *mut u128, val: u128, order: Ordering) {
Expand Down Expand Up @@ -1579,15 +1579,15 @@ Note:
any(target_feature = "lse", portable_atomic_target_feature = "lse"),
not(portable_atomic_ll_sc_rmw),
))]
use _atomic_swap_casp as atomic_swap;
use self::_atomic_swap_casp as atomic_swap;
#[cfg(not(any(target_feature = "lse128", portable_atomic_target_feature = "lse128")))]
#[cfg(not(all(
any(target_feature = "lse", portable_atomic_target_feature = "lse"),
not(portable_atomic_ll_sc_rmw),
)))]
use _atomic_swap_ldxp_stxp as atomic_swap;
use self::_atomic_swap_ldxp_stxp as atomic_swap;
#[cfg(any(target_feature = "lse128", portable_atomic_target_feature = "lse128"))]
use _atomic_swap_swpp as atomic_swap;
use self::_atomic_swap_swpp as atomic_swap;
#[cfg(any(
target_feature = "lse128",
portable_atomic_target_feature = "lse128",
Expand Down Expand Up @@ -1750,7 +1750,7 @@ macro_rules! atomic_rmw_ll_sc_3 {
any(target_feature = "lse", portable_atomic_target_feature = "lse"),
not(portable_atomic_ll_sc_rmw),
)))]
use $name as $reexport_name;
use self::$name as $reexport_name;
#[cfg(any(
test,
not(all(
Expand Down Expand Up @@ -1808,7 +1808,7 @@ macro_rules! atomic_rmw_cas_3 {
any(target_feature = "lse", portable_atomic_target_feature = "lse"),
not(portable_atomic_ll_sc_rmw),
))]
use $name as $reexport_name;
use self::$name as $reexport_name;
#[cfg(any(test, not(portable_atomic_ll_sc_rmw)))]
#[cfg(any(target_feature = "lse", portable_atomic_target_feature = "lse"))]
#[inline]
Expand Down Expand Up @@ -1876,7 +1876,7 @@ macro_rules! atomic_rmw_ll_sc_2 {
any(target_feature = "lse", portable_atomic_target_feature = "lse"),
not(portable_atomic_ll_sc_rmw),
)))]
use $name as $reexport_name;
use self::$name as $reexport_name;
#[cfg(any(
test,
not(all(
Expand Down Expand Up @@ -1930,7 +1930,7 @@ macro_rules! atomic_rmw_cas_2 {
any(target_feature = "lse", portable_atomic_target_feature = "lse"),
not(portable_atomic_ll_sc_rmw),
))]
use $name as $reexport_name;
use self::$name as $reexport_name;
#[cfg(any(test, not(portable_atomic_ll_sc_rmw)))]
#[cfg(any(target_feature = "lse", portable_atomic_target_feature = "lse"))]
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/imp/atomic128/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ unsafe fn atomic_compare_exchange(
}

#[cfg(target_arch = "x86_64")]
use atomic_compare_exchange as atomic_compare_exchange_weak;
use self::atomic_compare_exchange as atomic_compare_exchange_weak;
#[cfg(not(target_arch = "x86_64"))]
#[inline]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
Expand Down
8 changes: 4 additions & 4 deletions src/imp/atomic128/powerpc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn extract_cr0(r: u64) -> bool {
target_feature = "quadword-atomics",
portable_atomic_target_feature = "quadword-atomics",
))]
use atomic_load_pwr8 as atomic_load;
use self::atomic_load_pwr8 as atomic_load;
// Otherwise, we need to do run-time detection and can use pwr8_fn only if quadword-atomics is available.
#[cfg(not(any(
target_feature = "quadword-atomics",
Expand Down Expand Up @@ -250,7 +250,7 @@ unsafe fn atomic_load_pwr8(src: *mut u128, order: Ordering) -> u128 {
target_feature = "quadword-atomics",
portable_atomic_target_feature = "quadword-atomics",
))]
use atomic_store_pwr8 as atomic_store;
use self::atomic_store_pwr8 as atomic_store;
// Otherwise, we need to do run-time detection and can use pwr8_fn only if quadword-atomics is available.
#[cfg(not(any(
target_feature = "quadword-atomics",
Expand Down Expand Up @@ -428,7 +428,7 @@ unsafe fn atomic_compare_exchange_pwr8(
target_feature = "quadword-atomics",
portable_atomic_target_feature = "quadword-atomics",
)))]
use atomic_compare_exchange as atomic_compare_exchange_weak;
use self::atomic_compare_exchange as atomic_compare_exchange_weak;
#[cfg(any(
target_feature = "quadword-atomics",
portable_atomic_target_feature = "quadword-atomics",
Expand Down Expand Up @@ -747,7 +747,7 @@ macro_rules! select_atomic_rmw {
target_feature = "quadword-atomics",
portable_atomic_target_feature = "quadword-atomics",
))]
use $pwr8_fn as $name;
use self::$pwr8_fn as $name;
// Otherwise, we need to do run-time detection and can use pwr8_fn only if quadword-atomics is available.
#[cfg(not(any(
target_feature = "quadword-atomics",
Expand Down
6 changes: 3 additions & 3 deletions src/imp/atomic128/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ macro_rules! atomic_rmw_amocas_order_insn {
target_feature = "experimental-zacas",
portable_atomic_target_feature = "experimental-zacas",
))]
use atomic_load_zacas as atomic_load;
use self::atomic_load_zacas as atomic_load;
// Otherwise, we need to do run-time detection and can use zacas_fn only if zacas is available.
#[cfg(not(any(
target_feature = "experimental-zacas",
Expand Down Expand Up @@ -367,7 +367,7 @@ unsafe fn atomic_compare_exchange_zacas(
}

// amocas is always strong.
use atomic_compare_exchange as atomic_compare_exchange_weak;
use self::atomic_compare_exchange as atomic_compare_exchange_weak;

// 128-bit atomic load by two 64-bit atomic loads. (see arm_linux.rs for more)
#[inline]
Expand Down Expand Up @@ -424,7 +424,7 @@ macro_rules! select_atomic_rmw {
target_feature = "experimental-zacas",
portable_atomic_target_feature = "experimental-zacas",
))]
use $zacas_fn as $name;
use self::$zacas_fn as $name;
// Otherwise, we need to do run-time detection and can use zacas_fn only if zacas is available.
#[cfg(not(any(
target_feature = "experimental-zacas",
Expand Down
2 changes: 1 addition & 1 deletion src/imp/atomic128/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ unsafe fn atomic_compare_exchange(
}

// cdsg is always strong.
use atomic_compare_exchange as atomic_compare_exchange_weak;
use self::atomic_compare_exchange as atomic_compare_exchange_weak;

#[cfg(not(any(
target_feature = "load-store-on-cond",
Expand Down
4 changes: 2 additions & 2 deletions src/imp/atomic128/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ unsafe fn atomic_compare_exchange(
}

// cmpxchg16b is always strong.
use atomic_compare_exchange as atomic_compare_exchange_weak;
use self::atomic_compare_exchange as atomic_compare_exchange_weak;

// See cmpxchg16b() for target_feature(enable).
#[cfg_attr(
Expand Down Expand Up @@ -747,7 +747,7 @@ macro_rules! select_atomic_rmw {
) => {
// If cmpxchg16b is available at compile-time, we can always use cmpxchg16b_fn.
#[cfg(any(target_feature = "cmpxchg16b", portable_atomic_target_feature = "cmpxchg16b"))]
use $cmpxchg16b_fn as $name;
use self::$cmpxchg16b_fn as $name;
// Otherwise, we need to do run-time detection and can use cmpxchg16b_fn only if cmpxchg16b is available.
#[cfg(not(any(
target_feature = "cmpxchg16b",
Expand Down
6 changes: 3 additions & 3 deletions src/imp/atomic64/riscv32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ macro_rules! atomic_rmw_amocas_order_insn {
target_feature = "experimental-zacas",
portable_atomic_target_feature = "experimental-zacas",
))]
use atomic_load_zacas as atomic_load;
use self::atomic_load_zacas as atomic_load;
// Otherwise, we need to do run-time detection and can use zacas_fn only if zacas is available.
#[cfg(not(any(
target_feature = "experimental-zacas",
Expand Down Expand Up @@ -369,7 +369,7 @@ unsafe fn atomic_compare_exchange_zacas(
}

// amocas is always strong.
use atomic_compare_exchange as atomic_compare_exchange_weak;
use self::atomic_compare_exchange as atomic_compare_exchange_weak;

// 64-bit atomic load by two 32-bit atomic loads. (see arm_linux.rs for more)
#[inline]
Expand Down Expand Up @@ -426,7 +426,7 @@ macro_rules! select_atomic_rmw {
target_feature = "experimental-zacas",
portable_atomic_target_feature = "experimental-zacas",
))]
use $zacas_fn as $name;
use self::$zacas_fn as $name;
// Otherwise, we need to do run-time detection and can use zacas_fn only if zacas is available.
#[cfg(not(any(
target_feature = "experimental-zacas",
Expand Down
4 changes: 2 additions & 2 deletions src/imp/detect/auxv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ so we use it (see aarch64_aa64reg.rs).

include!("common.rs");

use os::ffi;
use self::os::ffi;
#[cfg(any(target_os = "linux", target_os = "android"))]
mod os {
// core::ffi::c_* (except c_void) requires Rust 1.64, libc requires Rust 1.63
Expand Down Expand Up @@ -409,7 +409,7 @@ mod os {

// Basically, Linux/FreeBSD/OpenBSD use the same hwcap values.
// FreeBSD and OpenBSD usually support a subset of the hwcap values supported by Linux.
use arch::_detect;
use self::arch::_detect;
#[cfg(target_arch = "aarch64")]
mod arch {
use super::{ffi, os, CpuInfo};
Expand Down
8 changes: 5 additions & 3 deletions src/imp/fallback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ cfg_no_fast_atomic_64! {

use core::{cell::UnsafeCell, mem, sync::atomic::Ordering};

use seq_lock::{SeqLock, SeqLockWriteGuard};
use utils::CachePadded;
use self::{
seq_lock::{SeqLock, SeqLockWriteGuard},
utils::CachePadded,
};

// Some 64-bit architectures have ABI with 32-bit pointer width (e.g., x86_64 X32 ABI,
// AArch64 ILP32 ABI, mips64 N32 ABI). On those targets, AtomicU64 is fast,
// so use it to reduce chunks of byte-wise atomic memcpy.
use seq_lock::{AtomicChunk, Chunk};
use self::seq_lock::{AtomicChunk, Chunk};

// Adapted from https://github.com/crossbeam-rs/crossbeam/blob/crossbeam-utils-0.8.7/crossbeam-utils/src/atomic/atomic_cell.rs#L969-L1016.
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/imp/interrupt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See also README.md of this directory.
// called while interrupts are disabled, and since the load/store is
// atomic, it is not affected by interrupts even if interrupts are enabled.
#[cfg(not(any(target_arch = "avr", feature = "critical-section")))]
use arch::atomic;
use self::arch::atomic;

#[cfg(not(feature = "critical-section"))]
#[cfg_attr(
Expand Down
22 changes: 11 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,13 @@ extern crate std;
#[macro_use]
mod cfgs;
#[cfg(target_pointer_width = "128")]
pub use {cfg_has_atomic_128 as cfg_has_atomic_ptr, cfg_no_atomic_128 as cfg_no_atomic_ptr};
pub use self::{cfg_has_atomic_128 as cfg_has_atomic_ptr, cfg_no_atomic_128 as cfg_no_atomic_ptr};
#[cfg(target_pointer_width = "16")]
pub use {cfg_has_atomic_16 as cfg_has_atomic_ptr, cfg_no_atomic_16 as cfg_no_atomic_ptr};
pub use self::{cfg_has_atomic_16 as cfg_has_atomic_ptr, cfg_no_atomic_16 as cfg_no_atomic_ptr};
#[cfg(target_pointer_width = "32")]
pub use {cfg_has_atomic_32 as cfg_has_atomic_ptr, cfg_no_atomic_32 as cfg_no_atomic_ptr};
pub use self::{cfg_has_atomic_32 as cfg_has_atomic_ptr, cfg_no_atomic_32 as cfg_no_atomic_ptr};
#[cfg(target_pointer_width = "64")]
pub use {cfg_has_atomic_64 as cfg_has_atomic_ptr, cfg_no_atomic_64 as cfg_no_atomic_ptr};
pub use self::{cfg_has_atomic_64 as cfg_has_atomic_ptr, cfg_no_atomic_64 as cfg_no_atomic_ptr};

#[macro_use]
mod utils;
Expand All @@ -470,12 +470,12 @@ mod tests;
#[doc(no_inline)]
pub use core::sync::atomic::Ordering;

#[doc(no_inline)]
// LLVM doesn't support fence/compiler_fence for MSP430.
#[cfg(target_arch = "msp430")]
pub use self::imp::msp430::{compiler_fence, fence};
#[doc(no_inline)]
#[cfg(not(target_arch = "msp430"))]
pub use core::sync::atomic::{compiler_fence, fence};
#[cfg(target_arch = "msp430")]
pub use imp::msp430::{compiler_fence, fence};

mod imp;

Expand Down Expand Up @@ -4768,17 +4768,17 @@ cfg_has_atomic_128! {
cfg_no_atomic_cas! {
cfg_no_atomic_cas_or_amo32! {
#[cfg(feature = "float")]
use diagnostic_helper::HasFetchAbs;
use diagnostic_helper::{
use self::diagnostic_helper::HasFetchAbs;
use self::diagnostic_helper::{
HasAnd, HasBitClear, HasBitSet, HasBitToggle, HasFetchAnd, HasFetchByteAdd, HasFetchByteSub,
HasFetchNot, HasFetchOr, HasFetchPtrAdd, HasFetchPtrSub, HasFetchXor, HasNot, HasOr, HasXor,
};
} // cfg_no_atomic_cas_or_amo32!
cfg_no_atomic_cas_or_amo8! {
use diagnostic_helper::{HasAdd, HasSub, HasSwap};
use self::diagnostic_helper::{HasAdd, HasSub, HasSwap};
} // cfg_no_atomic_cas_or_amo8!
#[cfg_attr(not(feature = "float"), allow(unused_imports))]
use diagnostic_helper::{
use self::diagnostic_helper::{
HasCompareExchange, HasCompareExchangeWeak, HasFetchAdd, HasFetchMax, HasFetchMin,
HasFetchNand, HasFetchNeg, HasFetchSub, HasFetchUpdate, HasNeg,
};
Expand Down
2 changes: 1 addition & 1 deletion src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ fn test_is_lock_free() {
// test version parsing code used in the build script.
#[test]
fn test_rustc_version() {
use version::Version;
use self::version::Version;

// rustc 1.34 (rustup)
let v = Version::parse(
Expand Down
4 changes: 3 additions & 1 deletion tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ else
base_args=(hack "${subcmd}")
fi
nightly=''
base_rustflags="${RUSTFLAGS:-}"
if [[ "${rustc_version}" =~ nightly|dev ]]; then
nightly=1
if [[ -z "${is_custom_toolchain}" ]]; then
Expand All @@ -246,6 +247,7 @@ if [[ "${rustc_version}" =~ nightly|dev ]]; then
subcmd=clippy
retry rustup ${pre_args[@]+"${pre_args[@]}"} component add clippy &>/dev/null
base_args=(hack "${subcmd}")
base_rustflags+=' -Z crate-attr=feature(unqualified_local_imports) -W unqualified_local_imports'
fi
fi
export CARGO_TARGET_DIR="${target_dir}"
Expand All @@ -262,7 +264,7 @@ build() {
local target="$1"
shift
local args=("${base_args[@]}")
local target_rustflags="${RUSTFLAGS:-}"
local target_rustflags="${base_rustflags}"
if ! grep -Eq "^${target}$" <<<"${rustc_target_list}" || [[ -f "target-specs/${target}.json" ]]; then
if [[ ! -f "target-specs/${target}.json" ]]; then
printf '%s\n' "target '${target}' not available on ${rustc_version} (skipped all checks)"
Expand Down

0 comments on commit 13e9580

Please sign in to comment.