Skip to content

Commit a2a8309

Browse files
committed
change inductive cycles to be fatal outside of coherence
1 parent e81a865 commit a2a8309

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

compiler/rustc_next_trait_solver/src/solve/search_graph.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use std::convert::Infallible;
22
use std::marker::PhantomData;
33

4-
use rustc_type_ir::Interner;
5-
use rustc_type_ir::inherent::*;
64
use rustc_type_ir::search_graph::{self, PathKind};
7-
use rustc_type_ir::solve::{CanonicalInput, Certainty, QueryResult};
5+
use rustc_type_ir::solve::{CanonicalInput, Certainty, NoSolution, QueryResult};
6+
use rustc_type_ir::{Interner, TypingMode};
87

98
use super::inspect::ProofTreeBuilder;
109
use super::{FIXPOINT_STEP_LIMIT, has_no_inference_or_external_constraints};
@@ -48,7 +47,14 @@ where
4847
) -> QueryResult<I> {
4948
match kind {
5049
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes),
51-
PathKind::Inductive => response_no_constraints(cx, input, Certainty::overflow(false)),
50+
PathKind::Inductive => match input.typing_mode {
51+
TypingMode::Coherence => {
52+
response_no_constraints(cx, input, Certainty::overflow(false))
53+
}
54+
TypingMode::Analysis { .. }
55+
| TypingMode::PostBorrowckAnalysis { .. }
56+
| TypingMode::PostAnalysis => Err(NoSolution),
57+
},
5258
}
5359
}
5460

@@ -58,12 +64,7 @@ where
5864
input: CanonicalInput<I>,
5965
result: QueryResult<I>,
6066
) -> bool {
61-
match kind {
62-
PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes) == result,
63-
PathKind::Inductive => {
64-
response_no_constraints(cx, input, Certainty::overflow(false)) == result
65-
}
66-
}
67+
Self::initial_provisional_result(cx, kind, input) == result
6768
}
6869

6970
fn on_stack_overflow(

0 commit comments

Comments
 (0)