about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits/mod.rs
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-06-01 14:51:31 -0400
committerMichael Goulet <michael@errs.io>2024-06-03 09:27:52 -0400
commiteb0a70a5578be0ae164cb802898ea98d41e95f13 (patch)
tree46f44c5a9e7c8a39a83a365d20612b30cede5b47 /compiler/rustc_trait_selection/src/traits/mod.rs
parent54b2b7d460fd0847508b781219d380231c4fee72 (diff)
downloadrust-eb0a70a5578be0ae164cb802898ea98d41e95f13.tar.gz
rust-eb0a70a5578be0ae164cb802898ea98d41e95f13.zip
Opt-in diagnostics reporting to avoid doing extra work in the new solver
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/mod.rs')
-rw-r--r--compiler/rustc_trait_selection/src/traits/mod.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs
index 990a88f748e..aabd687f0a5 100644
--- a/compiler/rustc_trait_selection/src/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/mod.rs
@@ -46,7 +46,7 @@ pub use self::coherence::{add_placeholder_note, orphan_check_trait_ref, overlapp
 pub use self::coherence::{InCrate, IsFirstInputType, UncoveredTyParams};
 pub use self::coherence::{OrphanCheckErr, OrphanCheckMode, OverlapResult};
 pub use self::engine::{ObligationCtxt, TraitEngineExt};
-pub use self::fulfill::{FulfillmentContext, PendingPredicateObligation};
+pub use self::fulfill::{FulfillmentContext, OldSolverError, PendingPredicateObligation};
 pub use self::normalize::NormalizeExt;
 pub use self::object_safety::hir_ty_lowering_object_safety_violations;
 pub use self::object_safety::is_vtable_safe_method;
@@ -70,6 +70,28 @@ pub use self::util::{with_replaced_escaping_bound_vars, BoundVarReplacer, Placeh
 
 pub use rustc_infer::traits::*;
 
+// A trait error without any information in it. You likely want to alternately use [`ObligationCtxt::new_with_diagnostics`] to get a [`FulfillmentError`].
+#[derive(Copy, Clone, Debug)]
+pub enum ScrubbedTraitError {
+    TrueError,
+    Ambiguity,
+}
+
+impl ScrubbedTraitError {
+    fn is_true_error(&self) -> bool {
+        match self {
+            ScrubbedTraitError::TrueError => true,
+            ScrubbedTraitError::Ambiguity => false,
+        }
+    }
+}
+
+impl<'tcx> FulfillmentErrorLike<'tcx> for ScrubbedTraitError {
+    fn is_true_error(&self) -> bool {
+        self.is_true_error()
+    }
+}
+
 pub struct FulfillmentError<'tcx> {
     pub obligation: PredicateObligation<'tcx>,
     pub code: FulfillmentErrorCode<'tcx>,
@@ -450,7 +472,7 @@ pub fn fully_normalize<'tcx, T>(
 where
     T: TypeFoldable<TyCtxt<'tcx>>,
 {
-    let ocx = ObligationCtxt::new(infcx);
+    let ocx = ObligationCtxt::new_with_diagnostics(infcx);
     debug!(?value);
     let normalized_value = ocx.normalize(&cause, param_env, value);
     debug!(?normalized_value);