Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 965741d

Browse files
committed
Tidy imports in rustc_data_structures::sync
1 parent 44ff785 commit 965741d

File tree

1 file changed

+29
-23
lines changed
  • compiler/rustc_data_structures/src

1 file changed

+29
-23
lines changed

‎compiler/rustc_data_structures/src/sync.rs‎

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,42 @@
3636
3737
use std::collections::HashMap;
3838
use std::hash::{BuildHasher, Hash};
39+
pub use std::sync::OnceLock;
3940

40-
pub use crate::marker::*;
41+
pub use parking_lot::{
42+
MappedRwLockReadGuard as MappedReadGuard, MappedRwLockWriteGuard as MappedWriteGuard,
43+
RwLockReadGuard as ReadGuard, RwLockWriteGuard as WriteGuard,
44+
};
4145

42-
mod lock;
46+
pub use self::atomic::AtomicU64;
47+
pub use self::freeze::{FreezeLock, FreezeReadGuard, FreezeWriteGuard};
4348
#[doc(no_inline)]
44-
pub use lock::{Lock, LockGuard, Mode};
45-
46-
mod worker_local;
47-
pub use worker_local::{Registry, WorkerLocal};
49+
pub use self::lock::{Lock, LockGuard, Mode};
50+
pub use self::mode::{is_dyn_thread_safe, set_dyn_thread_safe_mode};
51+
pub use self::parallel::{
52+
join, par_for_each_in, par_map, parallel_guard, scope, try_par_for_each_in,
53+
};
54+
pub use self::vec::{AppendOnlyIndexVec, AppendOnlyVec};
55+
pub use self::worker_local::{Registry, WorkerLocal};
56+
pub use crate::marker::*;
4857

58+
mod freeze;
59+
mod lock;
4960
mod parallel;
50-
pub use parallel::{join, par_for_each_in, par_map, parallel_guard, scope, try_par_for_each_in};
51-
pub use vec::{AppendOnlyIndexVec, AppendOnlyVec};
52-
5361
mod vec;
62+
mod worker_local;
5463

55-
mod freeze;
56-
pub use freeze::{FreezeLock, FreezeReadGuard, FreezeWriteGuard};
64+
/// Keep the conditional imports together in a submodule, so that import-sorting
65+
/// doesn't split them up.
66+
mod atomic {
67+
// Most hosts can just use a regular AtomicU64.
68+
#[cfg(target_has_atomic = "64")]
69+
pub use std::sync::atomic::AtomicU64;
70+
71+
// Some 32-bit hosts don't have AtomicU64, so use a fallback.
72+
#[cfg(not(target_has_atomic = "64"))]
73+
pub use portable_atomic::AtomicU64;
74+
}
5775

5876
mod mode {
5977
use std::sync::atomic::{AtomicU8, Ordering};
@@ -97,18 +115,6 @@ mod mode {
97115

98116
// FIXME(parallel_compiler): Get rid of these aliases across the compiler.
99117

100-
// Use portable AtomicU64 for targets without native 64-bit atomics
101-
#[cfg(target_has_atomic = "64")]
102-
pub use std::sync::atomic::AtomicU64;
103-
104-
pub use mode::{is_dyn_thread_safe, set_dyn_thread_safe_mode};
105-
pub use parking_lot::{
106-
MappedRwLockReadGuard as MappedReadGuard, MappedRwLockWriteGuard as MappedWriteGuard,
107-
RwLockReadGuard as ReadGuard, RwLockWriteGuard as WriteGuard,
108-
};
109-
#[cfg(not(target_has_atomic = "64"))]
110-
pub use portable_atomic::AtomicU64;
111-
112118
pub type LRef<'a, T> = &'a T;
113119

114120
#[derive(Debug, Default)]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /