Nits and formatting
This commit is contained in:
parent
1e72c7f536
commit
a41c44f21c
17 changed files with 130 additions and 142 deletions
|
@ -15,8 +15,8 @@ use crate::infer::canonical::{
|
|||
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
|
||||
use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult};
|
||||
use crate::traits::query::NoSolution;
|
||||
use crate::traits::{FulfillmentErrorLike, TraitEngine};
|
||||
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
|
||||
use crate::traits::{ScrubbedTraitError, TraitEngine};
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_index::Idx;
|
||||
use rustc_index::IndexVec;
|
||||
|
@ -50,11 +50,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
/// - Finally, if any of the obligations result in a hard error,
|
||||
/// then `Err(NoSolution)` is returned.
|
||||
#[instrument(skip(self, inference_vars, answer, fulfill_cx), level = "trace")]
|
||||
pub fn make_canonicalized_query_response<T, E: FulfillmentErrorLike<'tcx>>(
|
||||
pub fn make_canonicalized_query_response<T>(
|
||||
&self,
|
||||
inference_vars: CanonicalVarValues<'tcx>,
|
||||
answer: T,
|
||||
fulfill_cx: &mut dyn TraitEngine<'tcx, E>,
|
||||
fulfill_cx: &mut dyn TraitEngine<'tcx, ScrubbedTraitError<'tcx>>,
|
||||
) -> Result<CanonicalQueryResponse<'tcx, T>, NoSolution>
|
||||
where
|
||||
T: Debug + TypeFoldable<TyCtxt<'tcx>>,
|
||||
|
@ -97,11 +97,11 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
/// Helper for `make_canonicalized_query_response` that does
|
||||
/// everything up until the final canonicalization.
|
||||
#[instrument(skip(self, fulfill_cx), level = "debug")]
|
||||
fn make_query_response<T, E: FulfillmentErrorLike<'tcx>>(
|
||||
fn make_query_response<T>(
|
||||
&self,
|
||||
inference_vars: CanonicalVarValues<'tcx>,
|
||||
answer: T,
|
||||
fulfill_cx: &mut dyn TraitEngine<'tcx, E>,
|
||||
fulfill_cx: &mut dyn TraitEngine<'tcx, ScrubbedTraitError<'tcx>>,
|
||||
) -> Result<QueryResponse<'tcx, T>, NoSolution>
|
||||
where
|
||||
T: Debug + TypeFoldable<TyCtxt<'tcx>>,
|
||||
|
|
|
@ -12,8 +12,7 @@ pub use SubregionOrigin::*;
|
|||
pub use ValuePairs::*;
|
||||
|
||||
use crate::traits::{
|
||||
self, FulfillmentErrorLike, ObligationCause, ObligationInspector, PredicateObligations,
|
||||
TraitEngine,
|
||||
self, ObligationCause, ObligationInspector, PredicateObligations, TraitEngine,
|
||||
};
|
||||
use error_reporting::TypeErrCtxt;
|
||||
use free_regions::RegionRelations;
|
||||
|
@ -738,7 +737,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
|
|||
|
||||
impl<'tcx, T> InferOk<'tcx, T> {
|
||||
/// Extracts `value`, registering any obligations into `fulfill_cx`.
|
||||
pub fn into_value_registering_obligations<E: FulfillmentErrorLike<'tcx>>(
|
||||
pub fn into_value_registering_obligations<E: 'tcx>(
|
||||
self,
|
||||
infcx: &InferCtxt<'tcx>,
|
||||
fulfill_cx: &mut dyn TraitEngine<'tcx, E>,
|
||||
|
|
|
@ -7,7 +7,32 @@ use rustc_middle::ty::{self, Ty, Upcast};
|
|||
|
||||
use super::{ObligationCause, PredicateObligation};
|
||||
|
||||
pub trait TraitEngine<'tcx, E: FulfillmentErrorLike<'tcx>>: 'tcx {
|
||||
/// A trait error with most of its information removed. This is the error
|
||||
/// returned by an `ObligationCtxt` by default, and suitable if you just
|
||||
/// want to see if a predicate holds, and don't particularly care about the
|
||||
/// error itself (except for if it's an ambiguity or true error).
|
||||
///
|
||||
/// use `ObligationCtxt::new_with_diagnostics` to get a `FulfillmentError`.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum ScrubbedTraitError<'tcx> {
|
||||
/// A real error. This goal definitely does not hold.
|
||||
TrueError,
|
||||
/// An ambiguity. This goal may hold if further inference is done.
|
||||
Ambiguity,
|
||||
/// An old-solver-style cycle error, which will fatal.
|
||||
Cycle(Vec<PredicateObligation<'tcx>>),
|
||||
}
|
||||
|
||||
impl<'tcx> ScrubbedTraitError<'tcx> {
|
||||
pub fn is_true_error(&self) -> bool {
|
||||
match self {
|
||||
ScrubbedTraitError::TrueError => true,
|
||||
ScrubbedTraitError::Ambiguity | ScrubbedTraitError::Cycle(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TraitEngine<'tcx, E: 'tcx>: 'tcx {
|
||||
/// Requires that `ty` must implement the trait with `def_id` in
|
||||
/// the given environment. This trait must not have any type
|
||||
/// parameters (except for `Self`).
|
||||
|
@ -73,10 +98,6 @@ pub trait TraitEngine<'tcx, E: FulfillmentErrorLike<'tcx>>: 'tcx {
|
|||
) -> Vec<PredicateObligation<'tcx>>;
|
||||
}
|
||||
|
||||
pub trait FulfillmentErrorLike<'tcx>: Debug + 'tcx {
|
||||
fn is_true_error(&self) -> bool;
|
||||
}
|
||||
|
||||
pub trait FromSolverError<'tcx, E>: FulfillmentErrorLike<'tcx> {
|
||||
pub trait FromSolverError<'tcx, E>: Debug + 'tcx {
|
||||
fn from_solver_error(infcx: &InferCtxt<'tcx>, error: E) -> Self;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ pub use self::ImplSource::*;
|
|||
pub use self::SelectionError::*;
|
||||
use crate::infer::InferCtxt;
|
||||
|
||||
pub use self::engine::{FromSolverError, FulfillmentErrorLike, TraitEngine};
|
||||
pub use self::engine::{FromSolverError, ScrubbedTraitError, TraitEngine};
|
||||
pub use self::project::MismatchedProjectionTypes;
|
||||
pub(crate) use self::project::UndoLog;
|
||||
pub use self::project::{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue