Skip to content

Commit ce775bc

Browse files
Rollup merge of #79036 - cjgillot:steal, r=oli-obk
Move Steal to rustc_data_structures.
2 parents b0178f4 + 41c44b4 commit ce775bc

File tree

11 files changed

+18
-20
lines changed

11 files changed

+18
-20
lines changed

compiler/rustc_data_structures/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub mod work_queue;
102102
pub use atomic_ref::AtomicRef;
103103
pub mod frozen;
104104
pub mod sso;
105+
pub mod steal;
105106
pub mod tagged_ptr;
106107
pub mod temp_dir;
107108
pub mod unhash;

compiler/rustc_middle/src/ty/steal.rs compiler/rustc_data_structures/src/steal.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use rustc_data_structures::sync::{MappedReadGuard, ReadGuard, RwLock};
1+
use crate::stable_hasher::{HashStable, StableHasher};
2+
use crate::sync::{MappedReadGuard, ReadGuard, RwLock};
23

34
/// The `Steal` struct is intended to used as the value for a query.
45
/// Specifically, we sometimes have queries (*cough* MIR *cough*)
@@ -31,7 +32,7 @@ impl<T> Steal<T> {
3132

3233
pub fn borrow(&self) -> MappedReadGuard<'_, T> {
3334
ReadGuard::map(self.value.borrow(), |opt| match *opt {
34-
None => bug!("attempted to read from stolen value"),
35+
None => panic!("attempted to read from stolen value"),
3536
Some(ref v) => v,
3637
})
3738
}
@@ -42,3 +43,9 @@ impl<T> Steal<T> {
4243
value.expect("attempt to read from stolen value")
4344
}
4445
}
46+
47+
impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T> {
48+
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
49+
self.borrow().hash_stable(hcx, hasher);
50+
}
51+
}

compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rustc_ast::mut_visit::MutVisitor;
66
use rustc_ast::{self as ast, visit};
77
use rustc_codegen_ssa::back::link::emit_metadata;
88
use rustc_codegen_ssa::traits::CodegenBackend;
9+
use rustc_data_structures::steal::Steal;
910
use rustc_data_structures::sync::{par_iter, Lrc, OnceCell, ParallelIterator, WorkerLocal};
1011
use rustc_data_structures::temp_dir::MaybeTempDir;
1112
use rustc_data_structures::{box_region_allow_access, declare_box_region_type, parallel};
@@ -20,7 +21,6 @@ use rustc_middle::dep_graph::DepGraph;
2021
use rustc_middle::middle;
2122
use rustc_middle::middle::cstore::{CrateStore, MetadataLoader, MetadataLoaderDyn};
2223
use rustc_middle::ty::query::Providers;
23-
use rustc_middle::ty::steal::Steal;
2424
use rustc_middle::ty::{self, GlobalCtxt, ResolverOutputs, TyCtxt};
2525
use rustc_mir as mir;
2626
use rustc_mir_build as mir_build;

compiler/rustc_interface/src/queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::passes::{self, BoxedResolver, QueryContext};
33

44
use rustc_ast as ast;
55
use rustc_codegen_ssa::traits::CodegenBackend;
6+
use rustc_data_structures::steal::Steal;
67
use rustc_data_structures::svh::Svh;
78
use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal};
89
use rustc_errors::ErrorReported;
@@ -12,7 +13,6 @@ use rustc_incremental::DepGraphFuture;
1213
use rustc_lint::LintStore;
1314
use rustc_middle::arena::Arena;
1415
use rustc_middle::dep_graph::DepGraph;
15-
use rustc_middle::ty::steal::Steal;
1616
use rustc_middle::ty::{GlobalCtxt, ResolverOutputs, TyCtxt};
1717
use rustc_serialize::json;
1818
use rustc_session::config::{self, OutputFilenames, OutputType};

compiler/rustc_middle/src/arena.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ macro_rules! arena_types {
1414
[] layouts: rustc_target::abi::Layout,
1515
// AdtDef are interned and compared by address
1616
[] adt_def: rustc_middle::ty::AdtDef,
17-
[] steal_mir: rustc_middle::ty::steal::Steal<rustc_middle::mir::Body<$tcx>>,
17+
[] steal_mir: rustc_data_structures::steal::Steal<rustc_middle::mir::Body<$tcx>>,
1818
[decode] mir: rustc_middle::mir::Body<$tcx>,
1919
[] steal_promoted:
20-
rustc_middle::ty::steal::Steal<
20+
rustc_data_structures::steal::Steal<
2121
rustc_index::vec::IndexVec<
2222
rustc_middle::mir::Promoted,
2323
rustc_middle::mir::Body<$tcx>

compiler/rustc_middle/src/ich/impls_ty.rs

-9
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::FloatVid {
184184
}
185185
}
186186

187-
impl<'a, T> HashStable<StableHashingContext<'a>> for ty::steal::Steal<T>
188-
where
189-
T: HashStable<StableHashingContext<'a>>,
190-
{
191-
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
192-
self.borrow().hash_stable(hcx, hasher);
193-
}
194-
}
195-
196187
impl<'a> HashStable<StableHashingContext<'a>> for crate::middle::privacy::AccessLevels {
197188
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
198189
hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
1414
use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
1515
use crate::traits;
1616
use crate::ty::query::{self, TyCtxtAt};
17-
use crate::ty::steal::Steal;
1817
use crate::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, Subst, SubstsRef, UserSubsts};
1918
use crate::ty::TyKind::*;
2019
use crate::ty::{
@@ -33,6 +32,7 @@ use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap};
3332
use rustc_data_structures::stable_hasher::{
3433
hash_stable_hashmap, HashStable, StableHasher, StableVec,
3534
};
35+
use rustc_data_structures::steal::Steal;
3636
use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal};
3737
use rustc_data_structures::unhash::UnhashMap;
3838
use rustc_errors::ErrorReported;

compiler/rustc_middle/src/ty/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ pub mod outlives;
106106
pub mod print;
107107
pub mod query;
108108
pub mod relate;
109-
pub mod steal;
110109
pub mod subst;
111110
pub mod trait_def;
112111
pub mod util;

compiler/rustc_middle/src/ty/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ use crate::traits::query::{
2828
};
2929
use crate::traits::specialization_graph;
3030
use crate::traits::{self, ImplSource};
31-
use crate::ty::steal::Steal;
3231
use crate::ty::subst::{GenericArg, SubstsRef};
3332
use crate::ty::util::AlwaysRequiresDrop;
3433
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
3534
use rustc_data_structures::fingerprint::Fingerprint;
3635
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
3736
use rustc_data_structures::stable_hasher::StableVec;
37+
use rustc_data_structures::steal::Steal;
3838
use rustc_data_structures::svh::Svh;
3939
use rustc_data_structures::sync::Lrc;
4040
use rustc_errors::ErrorReported;

compiler/rustc_mir/src/transform/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use crate::{shim, util};
22
use required_consts::RequiredConstsVisitor;
33
use rustc_data_structures::fx::FxHashSet;
4+
use rustc_data_structures::steal::Steal;
45
use rustc_hir as hir;
56
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
67
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
78
use rustc_index::vec::IndexVec;
89
use rustc_middle::mir::visit::Visitor as _;
910
use rustc_middle::mir::{traversal, Body, ConstQualifs, MirPhase, Promoted};
1011
use rustc_middle::ty::query::Providers;
11-
use rustc_middle::ty::steal::Steal;
1212
use rustc_middle::ty::{self, TyCtxt, TypeFoldable};
1313
use rustc_span::{Span, Symbol};
1414
use std::borrow::Cow;

compiler/rustc_mir_build/src/build/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use super::lints;
2424
crate fn mir_built<'tcx>(
2525
tcx: TyCtxt<'tcx>,
2626
def: ty::WithOptConstParam<LocalDefId>,
27-
) -> &'tcx ty::steal::Steal<Body<'tcx>> {
27+
) -> &'tcx rustc_data_structures::steal::Steal<Body<'tcx>> {
2828
if let Some(def) = def.try_upgrade(tcx) {
2929
return tcx.mir_built(def);
3030
}

0 commit comments

Comments
 (0)