diff options
| author | Michael Goulet <michael@errs.io> | 2024-06-03 09:27:48 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-06-03 10:02:08 -0400 |
| commit | a41c44f21c1a6fd96eb8d68fbdb298610443cff5 (patch) | |
| tree | 176b96364bf630274f1eb3d65db56865d8bbfa48 /compiler/rustc_infer/src/traits/engine.rs | |
| parent | 1e72c7f536bbdf3ed8a0071d28824c071c3722b5 (diff) | |
| download | rust-a41c44f21c1a6fd96eb8d68fbdb298610443cff5.tar.gz rust-a41c44f21c1a6fd96eb8d68fbdb298610443cff5.zip | |
Nits and formatting
Diffstat (limited to 'compiler/rustc_infer/src/traits/engine.rs')
| -rw-r--r-- | compiler/rustc_infer/src/traits/engine.rs | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/compiler/rustc_infer/src/traits/engine.rs b/compiler/rustc_infer/src/traits/engine.rs index 1d6875d0f8e..026b2c1b905 100644 --- a/compiler/rustc_infer/src/traits/engine.rs +++ b/compiler/rustc_infer/src/traits/engine.rs @@ -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; } |
