Auto merge of #131263 - compiler-errors:solver-relating, r=lcnr
Introduce SolverRelating type relation to the new solver Redux of #128744. Splits out relate for the new solver so that implementors don't need to implement it themselves. r? lcnr
This commit is contained in:
commit
8d94e06ec9
31 changed files with 912 additions and 518 deletions
|
@ -12,6 +12,5 @@
|
|||
pub mod canonicalizer;
|
||||
pub mod coherence;
|
||||
pub mod delegate;
|
||||
pub mod relate;
|
||||
pub mod resolve;
|
||||
pub mod solve;
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
pub use rustc_type_ir::relate::*;
|
||||
|
||||
pub mod combine;
|
||||
|
||||
/// Whether aliases should be related structurally or not. Used
|
||||
/// to adjust the behavior of generalization and combine.
|
||||
///
|
||||
/// This should always be `No` unless in a few special-cases when
|
||||
/// instantiating canonical responses and in the new solver. Each
|
||||
/// such case should have a comment explaining why it is used.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum StructurallyRelateAliases {
|
||||
Yes,
|
||||
No,
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
pub use rustc_type_ir::relate::*;
|
||||
use rustc_type_ir::solve::Goal;
|
||||
use rustc_type_ir::{InferCtxtLike, Interner, Upcast};
|
||||
|
||||
use super::StructurallyRelateAliases;
|
||||
|
||||
pub trait PredicateEmittingRelation<Infcx, I = <Infcx as InferCtxtLike>::Interner>:
|
||||
TypeRelation<I>
|
||||
where
|
||||
Infcx: InferCtxtLike<Interner = I>,
|
||||
I: Interner,
|
||||
{
|
||||
fn span(&self) -> I::Span;
|
||||
|
||||
fn param_env(&self) -> I::ParamEnv;
|
||||
|
||||
/// Whether aliases should be related structurally. This is pretty much
|
||||
/// always `No` unless you're equating in some specific locations of the
|
||||
/// new solver. See the comments in these use-cases for more details.
|
||||
fn structurally_relate_aliases(&self) -> StructurallyRelateAliases;
|
||||
|
||||
/// Register obligations that must hold in order for this relation to hold
|
||||
fn register_goals(&mut self, obligations: impl IntoIterator<Item = Goal<I, I::Predicate>>);
|
||||
|
||||
/// Register predicates that must hold in order for this relation to hold.
|
||||
/// This uses the default `param_env` of the obligation.
|
||||
fn register_predicates(
|
||||
&mut self,
|
||||
obligations: impl IntoIterator<Item: Upcast<I, I::Predicate>>,
|
||||
);
|
||||
|
||||
/// Register `AliasRelate` obligation(s) that both types must be related to each other.
|
||||
fn register_alias_relate_predicate(&mut self, a: I::Ty, b: I::Ty);
|
||||
}
|
|
@ -14,6 +14,7 @@ use std::iter;
|
|||
use rustc_index::IndexVec;
|
||||
use rustc_type_ir::fold::TypeFoldable;
|
||||
use rustc_type_ir::inherent::*;
|
||||
use rustc_type_ir::relate::solver_relating::RelateExt;
|
||||
use rustc_type_ir::{self as ty, Canonical, CanonicalVarValues, InferCtxtLike, Interner};
|
||||
use tracing::{instrument, trace};
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use rustc_type_ir::data_structures::{HashMap, HashSet, ensure_sufficient_stack};
|
|||
use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
|
||||
use rustc_type_ir::inherent::*;
|
||||
use rustc_type_ir::relate::Relate;
|
||||
use rustc_type_ir::relate::solver_relating::RelateExt;
|
||||
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
|
||||
use rustc_type_ir::{self as ty, CanonicalVarValues, InferCtxtLike, Interner};
|
||||
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
|
||||
|
@ -871,7 +872,7 @@ where
|
|||
lhs: T,
|
||||
rhs: T,
|
||||
) -> Result<Vec<Goal<I, I::Predicate>>, NoSolution> {
|
||||
self.delegate.relate(param_env, lhs, ty::Variance::Invariant, rhs)
|
||||
Ok(self.delegate.relate(param_env, lhs, ty::Variance::Invariant, rhs)?)
|
||||
}
|
||||
|
||||
pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<I> + Copy>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue