|
1 | 1 | use std::convert::Infallible; |
2 | 2 | use std::marker::PhantomData; |
3 | 3 |
|
4 | | -use rustc_type_ir::Interner; |
5 | 4 | use rustc_type_ir::search_graph::{self, PathKind}; |
6 | 5 | use rustc_type_ir::solve::{CanonicalInput, Certainty, NoSolution, QueryResult}; |
| 6 | +use rustc_type_ir::{Interner, TypingMode}; |
7 | 7 |
|
8 | 8 | use super::inspect::ProofTreeBuilder; |
9 | 9 | use super::{FIXPOINT_STEP_LIMIT, has_no_inference_or_external_constraints}; |
|
48 | 48 | match kind { |
49 | 49 | PathKind::Coinductive => response_no_constraints(cx, input, Certainty::Yes), |
50 | 50 | PathKind::Unknown => response_no_constraints(cx, input, Certainty::overflow(false)), |
51 | | - PathKind::Inductive => Err(NoSolution), |
| 51 | + // Even though we know these cycles to be unproductive, we still return |
| 52 | + // overflow during coherence. This is both as we are not 100% confident in |
| 53 | + // the implementation yet and any incorrect errors would be unsound there. |
| 54 | + // The affected cases are also fairly artificial and not necessarily desirable |
| 55 | + // so keeping this as ambiguity is fine for now. |
| 56 | + // |
| 57 | + // See `tests/ui/traits/next-solver/cycles/unproductive-in-coherence.rs` for an |
| 58 | + // example where this would matter. We likely should change these cycles to `NoSolution` |
| 59 | + // even in coherence once this is a bit more settled. |
| 60 | + PathKind::Inductive => match input.typing_mode { |
| 61 | + TypingMode::Coherence => { |
| 62 | + response_no_constraints(cx, input, Certainty::overflow(false)) |
| 63 | + } |
| 64 | + TypingMode::Analysis { .. } |
| 65 | + | TypingMode::PostBorrowckAnalysis { .. } |
| 66 | + | TypingMode::PostAnalysis => Err(NoSolution), |
| 67 | + }, |
52 | 68 | } |
53 | 69 | } |
54 | 70 |
|
|
0 commit comments