Skip to content

Commit bc7f7b2

Browse files
author
Markus Westerlind
committed
refactor: Rename Logs to InferCtxtUndoLogs
1 parent e6d7f15 commit bc7f7b2

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

Cargo.lock

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ version = "0.0.212"
485485
dependencies = [
486486
"cargo_metadata 0.9.1",
487487
"if_chain",
488-
"itertools 0.8.0",
488+
"itertools 0.9.0",
489489
"lazy_static 1.4.0",
490490
"pulldown-cmark 0.7.1",
491491
"quine-mc_cluskey",
@@ -1629,6 +1629,15 @@ dependencies = [
16291629
"either",
16301630
]
16311631

1632+
[[package]]
1633+
name = "itertools"
1634+
version = "0.9.0"
1635+
source = "registry+https://github.com/rust-lang/crates.io-index"
1636+
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
1637+
dependencies = [
1638+
"either",
1639+
]
1640+
16321641
[[package]]
16331642
name = "itoa"
16341643
version = "0.4.4"
@@ -2179,6 +2188,7 @@ dependencies = [
21792188
"rustc-workspace-hack",
21802189
"rustc_version",
21812190
"serde",
2191+
"serde_json",
21822192
"shell-escape",
21832193
"vergen",
21842194
]

src/librustc_infer/infer/mod.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ pub struct InferCtxtInner<'tcx> {
147147
/// that might instantiate a general type variable have an order,
148148
/// represented by its upper and lower bounds.
149149
type_variables: type_variable::TypeVariableStorage<'tcx>,
150-
undo_log: Logs<'tcx>,
151150

152151
/// Map from const parameter variable to the kind of const it represents.
153152
const_unification_table: ut::UnificationStorage<ty::ConstVid<'tcx>>,
@@ -197,14 +196,16 @@ pub struct InferCtxtInner<'tcx> {
197196
/// obligations within. This is expected to be done 'late enough'
198197
/// that all type inference variables have been bound and so forth.
199198
region_obligations: Vec<(hir::HirId, RegionObligation<'tcx>)>,
199+
200+
undo_log: InferCtxtUndoLogs<'tcx>,
200201
}
201202

202203
impl<'tcx> InferCtxtInner<'tcx> {
203204
fn new() -> InferCtxtInner<'tcx> {
204205
InferCtxtInner {
205206
projection_cache: Default::default(),
206207
type_variables: type_variable::TypeVariableStorage::new(),
207-
undo_log: Logs::default(),
208+
undo_log: InferCtxtUndoLogs::default(),
208209
const_unification_table: ut::UnificationStorage::new(),
209210
int_unification_table: ut::UnificationStorage::new(),
210211
float_unification_table: ut::UnificationStorage::new(),
@@ -228,15 +229,23 @@ impl<'tcx> InferCtxtInner<'tcx> {
228229
fn int_unification_table(
229230
&mut self,
230231
) -> ut::UnificationTable<
231-
ut::InPlace<ty::IntVid, &mut ut::UnificationStorage<ty::IntVid>, &mut Logs<'tcx>>,
232+
ut::InPlace<
233+
ty::IntVid,
234+
&mut ut::UnificationStorage<ty::IntVid>,
235+
&mut InferCtxtUndoLogs<'tcx>,
236+
>,
232237
> {
233238
ut::UnificationTable::with_log(&mut self.int_unification_table, &mut self.undo_log)
234239
}
235240

236241
fn float_unification_table(
237242
&mut self,
238243
) -> ut::UnificationTable<
239-
ut::InPlace<ty::FloatVid, &mut ut::UnificationStorage<ty::FloatVid>, &mut Logs<'tcx>>,
244+
ut::InPlace<
245+
ty::FloatVid,
246+
&mut ut::UnificationStorage<ty::FloatVid>,
247+
&mut InferCtxtUndoLogs<'tcx>,
248+
>,
240249
> {
241250
ut::UnificationTable::with_log(&mut self.float_unification_table, &mut self.undo_log)
242251
}
@@ -247,7 +256,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
247256
ut::InPlace<
248257
ty::ConstVid<'tcx>,
249258
&mut ut::UnificationStorage<ty::ConstVid<'tcx>>,
250-
&mut Logs<'tcx>,
259+
&mut InferCtxtUndoLogs<'tcx>,
251260
>,
252261
> {
253262
ut::UnificationTable::with_log(&mut self.const_unification_table, &mut self.undo_log)
@@ -343,8 +352,9 @@ impl<'tcx> From<traits::UndoLog<'tcx>> for UndoLog<'tcx> {
343352
}
344353
}
345354

346-
pub(crate) type UnificationTable<'a, 'tcx, T> =
347-
ut::UnificationTable<ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut Logs<'tcx>>>;
355+
pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
356+
ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'tcx>>,
357+
>;
348358

349359
struct RollbackView<'tcx, 'a> {
350360
type_variables: &'a mut type_variable::TypeVariableStorage<'tcx>,
@@ -375,18 +385,18 @@ impl<'tcx> Rollback<UndoLog<'tcx>> for RollbackView<'tcx, '_> {
375385
}
376386
}
377387

378-
pub(crate) struct Logs<'tcx> {
388+
pub(crate) struct InferCtxtUndoLogs<'tcx> {
379389
logs: Vec<UndoLog<'tcx>>,
380390
num_open_snapshots: usize,
381391
}
382392

383-
impl Default for Logs<'_> {
393+
impl Default for InferCtxtUndoLogs<'_> {
384394
fn default() -> Self {
385395
Self { logs: Default::default(), num_open_snapshots: Default::default() }
386396
}
387397
}
388398

389-
impl<'tcx, T> UndoLogs<T> for Logs<'tcx>
399+
impl<'tcx, T> UndoLogs<T> for InferCtxtUndoLogs<'tcx>
390400
where
391401
UndoLog<'tcx>: From<T>,
392402
{
@@ -413,7 +423,7 @@ where
413423
}
414424
}
415425

416-
impl<'tcx> Snapshots<UndoLog<'tcx>> for Logs<'tcx> {
426+
impl<'tcx> Snapshots<UndoLog<'tcx>> for InferCtxtUndoLogs<'tcx> {
417427
type Snapshot = Snapshot<'tcx>;
418428
fn actions_since_snapshot(&self, snapshot: &Self::Snapshot) -> &[UndoLog<'tcx>] {
419429
&self.logs[snapshot.undo_len..]
@@ -464,7 +474,7 @@ impl<'tcx> Snapshots<UndoLog<'tcx>> for Logs<'tcx> {
464474
}
465475
}
466476

467-
impl<'tcx> Logs<'tcx> {
477+
impl<'tcx> InferCtxtUndoLogs<'tcx> {
468478
pub(crate) fn region_constraints(
469479
&self,
470480
after: usize,

src/librustc_infer/infer/region_constraints/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use self::CombineMapType::*;
44
use self::UndoLog::*;
55

66
use super::unify_key;
7-
use super::{Logs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin};
7+
use super::{
8+
InferCtxtUndoLogs, MiscVariable, RegionVariableOrigin, Rollback, Snapshot, SubregionOrigin,
9+
};
810

911
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1012
use rustc_data_structures::sync::Lrc;
@@ -61,7 +63,7 @@ pub struct RegionConstraintStorage<'tcx> {
6163

6264
pub struct RegionConstraintCollector<'tcx, 'a> {
6365
storage: &'a mut RegionConstraintStorage<'tcx>,
64-
undo_log: &'a mut Logs<'tcx>,
66+
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
6567
}
6668

6769
impl std::ops::Deref for RegionConstraintCollector<'tcx, '_> {
@@ -346,7 +348,7 @@ impl<'tcx> RegionConstraintStorage<'tcx> {
346348

347349
pub(crate) fn with_log<'a>(
348350
&'a mut self,
349-
undo_log: &'a mut Logs<'tcx>,
351+
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
350352
) -> RegionConstraintCollector<'tcx, 'a> {
351353
RegionConstraintCollector { storage: self, undo_log }
352354
}

src/librustc_infer/infer/type_variable.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_middle::ty::{self, Ty, TyVid};
33
use rustc_span::symbol::Symbol;
44
use rustc_span::Span;
55

6-
use crate::infer::Logs;
6+
use crate::infer::InferCtxtUndoLogs;
77

88
use rustc_data_structures::snapshot_vec as sv;
99
use rustc_data_structures::unify as ut;
@@ -88,7 +88,7 @@ pub struct TypeVariableTable<'tcx, 'a> {
8888

8989
sub_relations: &'a mut ut::UnificationStorage<ty::TyVid>,
9090

91-
undo_log: &'a mut Logs<'tcx>,
91+
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
9292
}
9393

9494
#[derive(Copy, Clone, Debug)]
@@ -167,7 +167,7 @@ impl<'tcx> TypeVariableStorage<'tcx> {
167167

168168
pub(crate) fn with_log<'a>(
169169
&'a mut self,
170-
undo_log: &'a mut Logs<'tcx>,
170+
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
171171
) -> TypeVariableTable<'tcx, 'a> {
172172
let TypeVariableStorage { values, eq_relations, sub_relations } = self;
173173
TypeVariableTable { values, eq_relations, sub_relations, undo_log }
@@ -327,7 +327,9 @@ impl<'tcx> TypeVariableTable<'tcx, '_> {
327327
Snapshot { value_count: self.eq_relations().len() as u32, _marker: PhantomData }
328328
}
329329

330-
fn values(&mut self) -> sv::SnapshotVec<Delegate, &mut Vec<TypeVariableData>, &mut Logs<'tcx>> {
330+
fn values(
331+
&mut self,
332+
) -> sv::SnapshotVec<Delegate, &mut Vec<TypeVariableData>, &mut InferCtxtUndoLogs<'tcx>> {
331333
sv::SnapshotVec::with_log(self.values, self.undo_log)
332334
}
333335

src/librustc_infer/traits/project.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use super::PredicateObligation;
44

5-
use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
5+
use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage};
66
use rustc_middle::ty::fold::TypeFoldable;
77
use rustc_middle::ty::{self, Ty};
88

@@ -63,7 +63,7 @@ impl<'tcx, T> Normalized<'tcx, T> {
6363
// reduce the amount of duplication. Let's see what we get with the Chalk reforms.
6464
pub struct ProjectionCache<'tcx, 'a> {
6565
map: &'a mut SnapshotMapStorage<ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>>,
66-
undo_log: &'a mut Logs<'tcx>,
66+
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
6767
}
6868

6969
#[derive(Default)]
@@ -93,7 +93,7 @@ pub enum ProjectionCacheEntry<'tcx> {
9393
impl<'tcx> ProjectionCacheStorage<'tcx> {
9494
pub(crate) fn with_log<'a>(
9595
&'a mut self,
96-
undo_log: &'a mut Logs<'tcx>,
96+
undo_log: &'a mut InferCtxtUndoLogs<'tcx>,
9797
) -> ProjectionCache<'tcx, 'a> {
9898
ProjectionCache { map: &mut self.map, undo_log }
9999
}
@@ -102,7 +102,12 @@ impl<'tcx> ProjectionCacheStorage<'tcx> {
102102
impl<'tcx> ProjectionCache<'tcx, '_> {
103103
fn map(
104104
&mut self,
105-
) -> SnapshotMapRef<'_, ProjectionCacheKey<'tcx>, ProjectionCacheEntry<'tcx>, Logs<'tcx>> {
105+
) -> SnapshotMapRef<
106+
'_,
107+
ProjectionCacheKey<'tcx>,
108+
ProjectionCacheEntry<'tcx>,
109+
InferCtxtUndoLogs<'tcx>,
110+
> {
106111
self.map.with_log(self.undo_log)
107112
}
108113

0 commit comments

Comments
 (0)