Move FulfillmentErrorCode to rustc_trait_selection too
This commit is contained in:
parent
94a524ed11
commit
27f5eccd1f
8 changed files with 51 additions and 52 deletions
|
@ -15,8 +15,7 @@ use hir::def_id::LocalDefId;
|
|||
use rustc_hir as hir;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
use rustc_middle::traits::solve::Certainty;
|
||||
use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
||||
use rustc_middle::ty::{self, Const, Ty, TyCtxt, Upcast};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, Upcast};
|
||||
use rustc_span::Span;
|
||||
|
||||
pub use self::ImplSource::*;
|
||||
|
@ -124,24 +123,6 @@ pub type Selection<'tcx> = ImplSource<'tcx, PredicateObligation<'tcx>>;
|
|||
pub type ObligationInspector<'tcx> =
|
||||
fn(&InferCtxt<'tcx>, &PredicateObligation<'tcx>, Result<Certainty, NoSolution>);
|
||||
|
||||
// TODO: Pull this down too
|
||||
#[derive(Clone)]
|
||||
pub enum FulfillmentErrorCode<'tcx> {
|
||||
/// Inherently impossible to fulfill; this trait is implemented if and only
|
||||
/// if it is already implemented.
|
||||
Cycle(Vec<PredicateObligation<'tcx>>),
|
||||
Select(SelectionError<'tcx>),
|
||||
Project(MismatchedProjectionTypes<'tcx>),
|
||||
Subtype(ExpectedFound<Ty<'tcx>>, TypeError<'tcx>), // always comes from a SubtypePredicate
|
||||
ConstEquate(ExpectedFound<Const<'tcx>>, TypeError<'tcx>),
|
||||
Ambiguity {
|
||||
/// Overflow is only `Some(suggest_recursion_limit)` when using the next generation
|
||||
/// trait solver `-Znext-solver`. With the old solver overflow is eagerly handled by
|
||||
/// emitting a fatal error instead.
|
||||
overflow: Option<bool>,
|
||||
},
|
||||
}
|
||||
|
||||
impl<'tcx, O> Obligation<'tcx, O> {
|
||||
pub fn new(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
|
|
@ -29,27 +29,6 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for traits::FulfillmentErrorCode<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
use traits::FulfillmentErrorCode::*;
|
||||
match *self {
|
||||
Select(ref e) => write!(f, "{e:?}"),
|
||||
Project(ref e) => write!(f, "{e:?}"),
|
||||
Subtype(ref a, ref b) => {
|
||||
write!(f, "CodeSubtypeError({a:?}, {b:?})")
|
||||
}
|
||||
ConstEquate(ref a, ref b) => {
|
||||
write!(f, "CodeConstEquateError({a:?}, {b:?})")
|
||||
}
|
||||
Ambiguity { overflow: None } => write!(f, "Ambiguity"),
|
||||
Ambiguity { overflow: Some(suggest_increasing_limit) } => {
|
||||
write!(f, "Overflow({suggest_increasing_limit})")
|
||||
}
|
||||
Cycle(ref cycle) => write!(f, "Cycle({cycle:?})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "MismatchedProjectionTypes({:?})", self.err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue