Skip to content

Commit 9b9aed3

Browse files
committed
it sound
1 parent d13506f commit 9b9aed3

File tree

1 file changed

+18
-19
lines changed
  • compiler/rustc_type_ir/src/search_graph

1 file changed

+18
-19
lines changed

compiler/rustc_type_ir/src/search_graph/mod.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -199,27 +199,27 @@ impl UsageKind {
199199
/// This is a necessary condition to rebase provisional cache
200200
/// entries.
201201
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
202-
pub enum AllPathsToHeadCoinductive {
202+
pub enum AllPathsToHeadForcedAmbiguity {
203203
Yes,
204204
No,
205205
}
206-
impl From<PathKind> for AllPathsToHeadCoinductive {
207-
fn from(path: PathKind) -> AllPathsToHeadCoinductive {
206+
impl From<PathKind> for AllPathsToHeadForcedAmbiguity {
207+
fn from(path: PathKind) -> AllPathsToHeadForcedAmbiguity {
208208
match path {
209-
PathKind::Coinductive => AllPathsToHeadCoinductive::Yes,
210-
_ => AllPathsToHeadCoinductive::No,
209+
PathKind::ForcedAmbiguity => AllPathsToHeadForcedAmbiguity::Yes,
210+
_ => AllPathsToHeadForcedAmbiguity::No,
211211
}
212212
}
213213
}
214-
impl AllPathsToHeadCoinductive {
214+
impl AllPathsToHeadForcedAmbiguity {
215215
#[must_use]
216216
fn merge(self, other: impl Into<Self>) -> Self {
217217
match (self, other.into()) {
218-
(AllPathsToHeadCoinductive::Yes, AllPathsToHeadCoinductive::Yes) => {
219-
AllPathsToHeadCoinductive::Yes
218+
(AllPathsToHeadForcedAmbiguity::Yes, AllPathsToHeadForcedAmbiguity::Yes) => {
219+
AllPathsToHeadForcedAmbiguity::Yes
220220
}
221-
(AllPathsToHeadCoinductive::No, _) | (_, AllPathsToHeadCoinductive::No) => {
222-
AllPathsToHeadCoinductive::No
221+
(AllPathsToHeadForcedAmbiguity::No, _) | (_, AllPathsToHeadForcedAmbiguity::No) => {
222+
AllPathsToHeadForcedAmbiguity::No
223223
}
224224
}
225225
}
@@ -269,7 +269,7 @@ impl AvailableDepth {
269269
/// when rebasing provisional cache results.
270270
#[derive(Clone, Debug, PartialEq, Eq, Default)]
271271
struct CycleHeads {
272-
heads: BTreeMap<StackDepth, AllPathsToHeadCoinductive>,
272+
heads: BTreeMap<StackDepth, AllPathsToHeadForcedAmbiguity>,
273273
}
274274

275275
impl CycleHeads {
@@ -297,19 +297,19 @@ impl CycleHeads {
297297
fn insert(
298298
&mut self,
299299
head: StackDepth,
300-
path_from_entry: impl Into<AllPathsToHeadCoinductive> + Copy,
300+
path_from_entry: impl Into<AllPathsToHeadForcedAmbiguity> + Copy,
301301
) {
302302
self.heads.entry(head).or_insert(path_from_entry.into()).and_merge(path_from_entry);
303303
}
304304

305305
fn merge(&mut self, heads: &CycleHeads) {
306306
for (&head, &path_from_entry) in heads.heads.iter() {
307307
self.insert(head, path_from_entry);
308-
debug_assert!(matches!(self.heads[&head], AllPathsToHeadCoinductive::Yes));
308+
debug_assert!(matches!(self.heads[&head], AllPathsToHeadForcedAmbiguity::Yes));
309309
}
310310
}
311311

312-
fn iter(&self) -> impl Iterator<Item = (StackDepth, AllPathsToHeadCoinductive)> + '_ {
312+
fn iter(&self) -> impl Iterator<Item = (StackDepth, AllPathsToHeadForcedAmbiguity)> + '_ {
313313
self.heads.iter().map(|(k, v)| (*k, *v))
314314
}
315315

@@ -325,9 +325,8 @@ impl CycleHeads {
325325
}
326326

327327
let path_from_entry = match step_kind {
328-
PathKind::Coinductive => AllPathsToHeadCoinductive::Yes,
329-
// TODO
330-
PathKind::Unknown | PathKind::Inductive | PathKind::ForcedAmbiguity => {
328+
PathKind::ForcedAmbiguity => AllPathsToHeadForcedAmbiguity::Yes,
329+
PathKind::Unknown | PathKind::Inductive | PathKind::Coinductive => {
331330
path_from_entry
332331
}
333332
};
@@ -873,12 +872,12 @@ impl<D: Delegate<Cx = X>, X: Cx> SearchGraph<D> {
873872
// to its heads are coinductive. In this case these cycle
874873
// kinds won't change, no matter the goals between these
875874
// heads and the provisional cache entry.
876-
if heads.iter().any(|(_, p)| matches!(p, AllPathsToHeadCoinductive::No)) {
875+
if heads.iter().any(|(_, p)| matches!(p, AllPathsToHeadForcedAmbiguity::No)) {
877876
return false;
878877
}
879878

880879
// The same for nested goals of the cycle head.
881-
if stack_entry.heads.iter().any(|(_, p)| matches!(p, AllPathsToHeadCoinductive::No))
880+
if stack_entry.heads.iter().any(|(_, p)| matches!(p, AllPathsToHeadForcedAmbiguity::No))
882881
{
883882
return false;
884883
}

0 commit comments

Comments
 (0)