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 28f851e

Browse files
committed
Remove sync::LRef and sync::MTLockRef
With the removal of `cfg(parallel_compiler)`, these are always shared references.
1 parent 965741d commit 28f851e

File tree

3 files changed

+15
-29
lines changed

3 files changed

+15
-29
lines changed

‎compiler/rustc_data_structures/src/sync.rs‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,16 @@
1818
//!
1919
//! | Type | Serial version | Parallel version |
2020
//! | ----------------------- | ------------------- | ------------------------------- |
21-
//! | `LRef<'a, T>` [^2] | `&'a mut T` | `&'a T` |
22-
//! | | | |
2321
//! | `Lock<T>` | `RefCell<T>` | `RefCell<T>` or |
2422
//! | | | `parking_lot::Mutex<T>` |
2523
//! | `RwLock<T>` | `RefCell<T>` | `parking_lot::RwLock<T>` |
2624
//! | `MTLock<T>` [^1] | `T` | `Lock<T>` |
27-
//! | `MTLockRef<'a, T>` [^2] | `&'a mut MTLock<T>` | `&'a MTLock<T>` |
2825
//! | | | |
2926
//! | `ParallelIterator` | `Iterator` | `rayon::iter::ParallelIterator` |
3027
//!
3128
//! [^1]: `MTLock` is similar to `Lock`, but the serial version avoids the cost
3229
//! of a `RefCell`. This is appropriate when interior mutability is not
3330
//! required.
34-
//!
35-
//! [^2]: `MTRef`, `MTLockRef` are type aliases.
3631
3732
use std::collections::HashMap;
3833
use std::hash::{BuildHasher, Hash};
@@ -115,8 +110,6 @@ mod mode {
115110

116111
// FIXME(parallel_compiler): Get rid of these aliases across the compiler.
117112

118-
pub type LRef<'a, T> = &'a T;
119-
120113
#[derive(Debug, Default)]
121114
pub struct MTLock<T>(Lock<T>);
122115

@@ -151,8 +144,6 @@ impl<T> MTLock<T> {
151144
/// It is only useful when you are running in a single thread
152145
const ERROR_CHECKING: bool = false;
153146

154-
pub type MTLockRef<'a, T> = LRef<'a, MTLock<T>>;
155-
156147
#[derive(Default)]
157148
#[repr(align(64))]
158149
pub struct CacheAligned<T>(pub T);

‎compiler/rustc_monomorphize/src/collector.rs‎

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ use std::path::PathBuf;
209209

210210
use rustc_attr_parsing::InlineAttr;
211211
use rustc_data_structures::fx::FxIndexMap;
212-
use rustc_data_structures::sync::{LRef,MTLock, par_for_each_in};
212+
use rustc_data_structures::sync::{MTLock, par_for_each_in};
213213
use rustc_data_structures::unord::{UnordMap, UnordSet};
214214
use rustc_hir as hir;
215215
use rustc_hir::def::DefKind;
@@ -357,7 +357,7 @@ impl<'tcx> Extend<Spanned<MonoItem<'tcx>>> for MonoItems<'tcx> {
357357
fn collect_items_rec<'tcx>(
358358
tcx: TyCtxt<'tcx>,
359359
starting_item: Spanned<MonoItem<'tcx>>,
360-
state: LRef<'_,SharedState<'tcx>>,
360+
state: &SharedState<'tcx>,
361361
recursion_depths: &mut DefIdMap<usize>,
362362
recursion_limit: Limit,
363363
mode: CollectionMode,
@@ -1671,30 +1671,26 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
16711671

16721672
debug!("building mono item graph, beginning at roots");
16731673

1674-
let mutstate = SharedState {
1674+
let state = SharedState {
16751675
visited: MTLock::new(UnordSet::default()),
16761676
mentioned: MTLock::new(UnordSet::default()),
16771677
usage_map: MTLock::new(UsageMap::new()),
16781678
};
16791679
let recursion_limit = tcx.recursion_limit();
16801680

1681-
{
1682-
let state: LRef<'_, _> = &mut state;
1683-
1684-
tcx.sess.time("monomorphization_collector_graph_walk", || {
1685-
par_for_each_in(roots, |root| {
1686-
let mut recursion_depths = DefIdMap::default();
1687-
collect_items_rec(
1688-
tcx,
1689-
dummy_spanned(root),
1690-
state,
1691-
&mut recursion_depths,
1692-
recursion_limit,
1693-
CollectionMode::UsedItems,
1694-
);
1695-
});
1681+
tcx.sess.time("monomorphization_collector_graph_walk", || {
1682+
par_for_each_in(roots, |root| {
1683+
let mut recursion_depths = DefIdMap::default();
1684+
collect_items_rec(
1685+
tcx,
1686+
dummy_spanned(root),
1687+
&state,
1688+
&mut recursion_depths,
1689+
recursion_limit,
1690+
CollectionMode::UsedItems,
1691+
);
16961692
});
1697-
}
1693+
});
16981694

16991695
// The set of MonoItems was created in an inherently indeterministic order because
17001696
// of parallelism. We sort it here to ensure that the output is deterministic.

‎src/doc/rustc-dev-guide/src/parallel-rustc.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ are implemented differently depending on whether `parallel-compiler` is true.
4848
| -------------------------------- | --------------------------------------------------- | ------------ |
4949
| Lock\<T> | (parking_lot::Mutex\<T>) | (std::cell::RefCell) |
5050
| RwLock\<T> | (parking_lot::RwLock\<T>) | (std::cell::RefCell) |
51-
| MTRef<'a, T> | &'a T | &'a mut T |
5251
| MTLock\<T> | (Lock\<T>) | (T) |
5352
| ReadGuard | parking_lot::RwLockReadGuard | std::cell::Ref |
5453
| MappedReadGuard | parking_lot::MappedRwLockReadGuard | std::cell::Ref |

0 commit comments

Comments
(0)

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