about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-06-01 15:00:02 -0400
committerMichael Goulet <michael@errs.io>2024-06-03 09:27:52 -0400
commit94a524ed1163f4876544366586dc1b87deb13e95 (patch)
tree20295042546ef296ddfbee4d500aebec8c2b78a5 /compiler
parenteb0a70a5578be0ae164cb802898ea98d41e95f13 (diff)
downloadrust-94a524ed1163f4876544366586dc1b87deb13e95.tar.gz
rust-94a524ed1163f4876544366586dc1b87deb13e95.zip
Use ScrubbedTraitError in more places
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/type_check/constraint_conversion.rs4
-rw-r--r--compiler/rustc_hir_analysis/src/coherence/orphan.rs9
-rw-r--r--compiler/rustc_trait_selection/src/regions.rs5
-rw-r--r--compiler/rustc_trait_selection/src/solve/normalize.rs8
-rw-r--r--compiler/rustc_trait_selection/src/traits/mod.rs9
-rw-r--r--compiler/rustc_trait_selection/src/traits/query/normalize.rs7
-rw-r--r--compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs5
7 files changed, 25 insertions, 22 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
index 4037f04d0bc..210532e56a5 100644
--- a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
+++ b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs
@@ -13,7 +13,7 @@ use rustc_span::Span;
 use rustc_trait_selection::solve::deeply_normalize;
 use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
 use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
-use rustc_trait_selection::traits::FulfillmentError;
+use rustc_trait_selection::traits::ScrubbedTraitError;
 
 use crate::{
     constraints::OutlivesConstraint,
@@ -287,7 +287,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
                     ocx.infcx.at(&ObligationCause::dummy_with_span(self.span), self.param_env),
                     ty,
                 )
-                .map_err(|_: Vec<FulfillmentError<'tcx>>| NoSolution)
+                .map_err(|_: Vec<ScrubbedTraitError>| NoSolution)
             },
             "normalize type outlives obligation",
         )
diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
index a4818b25f98..d2eb0cb5a7b 100644
--- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs
+++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs
@@ -12,9 +12,11 @@ use rustc_middle::ty::{TypeFoldable, TypeFolder, TypeSuperFoldable};
 use rustc_middle::ty::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
 use rustc_middle::{bug, span_bug};
 use rustc_span::def_id::{DefId, LocalDefId};
-use rustc_trait_selection::traits::{self, IsFirstInputType, UncoveredTyParams};
-use rustc_trait_selection::traits::{FulfillmentError, StructurallyNormalizeExt, TraitEngineExt};
+use rustc_trait_selection::traits::{
+    self, IsFirstInputType, ScrubbedTraitError, UncoveredTyParams,
+};
 use rustc_trait_selection::traits::{OrphanCheckErr, OrphanCheckMode};
+use rustc_trait_selection::traits::{StructurallyNormalizeExt, TraitEngineExt};
 
 #[instrument(level = "debug", skip(tcx))]
 pub(crate) fn orphan_check_impl(
@@ -317,8 +319,7 @@ fn orphan_check<'tcx>(
         }
 
         let ty = if infcx.next_trait_solver() {
-            let mut fulfill_cx =
-                <dyn traits::TraitEngine<'tcx, FulfillmentError<'tcx>>>::new(&infcx);
+            let mut fulfill_cx = <dyn traits::TraitEngine<'tcx, ScrubbedTraitError>>::new(&infcx);
             infcx
                 .at(&cause, ty::ParamEnv::empty())
                 .structurally_normalize(ty, &mut *fulfill_cx)
diff --git a/compiler/rustc_trait_selection/src/regions.rs b/compiler/rustc_trait_selection/src/regions.rs
index cca5bce03e1..3ef3f9ef358 100644
--- a/compiler/rustc_trait_selection/src/regions.rs
+++ b/compiler/rustc_trait_selection/src/regions.rs
@@ -1,4 +1,4 @@
-use crate::traits::FulfillmentError;
+use crate::traits::ScrubbedTraitError;
 use rustc_infer::infer::outlives::env::OutlivesEnvironment;
 use rustc_infer::infer::{InferCtxt, RegionResolutionError};
 use rustc_macros::extension;
@@ -28,8 +28,7 @@ impl<'tcx> InferCtxt<'tcx> {
                     ),
                     ty,
                 )
-                // TODO:
-                .map_err(|_: Vec<FulfillmentError<'tcx>>| NoSolution)
+                .map_err(|_: Vec<ScrubbedTraitError>| NoSolution)
             } else {
                 Ok(ty)
             }
diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs
index f85e5d8746f..5e41e8e8ba9 100644
--- a/compiler/rustc_trait_selection/src/solve/normalize.rs
+++ b/compiler/rustc_trait_selection/src/solve/normalize.rs
@@ -2,7 +2,7 @@ use std::marker::PhantomData;
 
 use crate::traits::error_reporting::{OverflowCause, TypeErrCtxtExt};
 use crate::traits::query::evaluate_obligation::InferCtxtExt;
-use crate::traits::{BoundVarReplacer, FulfillmentError, PlaceholderReplacer};
+use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError};
 use rustc_data_structures::stack::ensure_sufficient_stack;
 use rustc_infer::infer::at::At;
 use rustc_infer::infer::InferCtxt;
@@ -253,8 +253,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for DeeplyNormalizeForDiagnosticsFolder<'_,
             ty,
             vec![None; ty.outer_exclusive_binder().as_usize()],
         )
-        // TODO:
-        .unwrap_or_else(|_: Vec<FulfillmentError<'tcx>>| ty.super_fold_with(self))
+        .unwrap_or_else(|_: Vec<ScrubbedTraitError>| ty.super_fold_with(self))
     }
 
     fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
@@ -263,7 +262,6 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for DeeplyNormalizeForDiagnosticsFolder<'_,
             ct,
             vec![None; ct.outer_exclusive_binder().as_usize()],
         )
-        // TODO:
-        .unwrap_or_else(|_: Vec<FulfillmentError<'tcx>>| ct.super_fold_with(self))
+        .unwrap_or_else(|_: Vec<ScrubbedTraitError>| ct.super_fold_with(self))
     }
 }
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs
index aabd687f0a5..cab743987c6 100644
--- a/compiler/rustc_trait_selection/src/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/mod.rs
@@ -70,10 +70,17 @@ 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`].
+/// A trait error without 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(Copy, Clone, Debug)]
 pub enum ScrubbedTraitError {
+    /// A real error. This goal definitely does not hold.
     TrueError,
+    /// An ambiguity. This goal may hold if further inference is done.
     Ambiguity,
 }
 
diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
index 2c0103e40df..860f50888a5 100644
--- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
@@ -8,8 +8,8 @@ use crate::infer::{InferCtxt, InferOk};
 use crate::traits::error_reporting::OverflowCause;
 use crate::traits::error_reporting::TypeErrCtxtExt;
 use crate::traits::normalize::needs_normalization;
-use crate::traits::{BoundVarReplacer, PlaceholderReplacer};
-use crate::traits::{FulfillmentError, Normalized};
+use crate::traits::Normalized;
+use crate::traits::{BoundVarReplacer, PlaceholderReplacer, ScrubbedTraitError};
 use crate::traits::{ObligationCause, PredicateObligation, Reveal};
 use rustc_data_structures::sso::SsoHashMap;
 use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -76,8 +76,7 @@ impl<'cx, 'tcx> At<'cx, 'tcx> {
         };
 
         if self.infcx.next_trait_solver() {
-            // TODO:
-            match crate::solve::deeply_normalize_with_skipped_universes::<_, FulfillmentError<'tcx>>(
+            match crate::solve::deeply_normalize_with_skipped_universes::<_, ScrubbedTraitError>(
                 self, value, universes,
             ) {
                 Ok(value) => return Ok(Normalized { value, obligations: vec![] }),
diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs
index a1bbd21f829..e4d0a541219 100644
--- a/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/type_op/implied_outlives_bounds.rs
@@ -1,8 +1,8 @@
 use crate::solve;
 use crate::traits::query::NoSolution;
 use crate::traits::wf;
-use crate::traits::FulfillmentError;
 use crate::traits::ObligationCtxt;
+use crate::traits::ScrubbedTraitError;
 
 use rustc_infer::infer::canonical::Canonical;
 use rustc_infer::infer::outlives::components::{push_outlives_components, Component};
@@ -267,8 +267,7 @@ pub fn compute_implied_outlives_bounds_compat_inner<'tcx>(
                         ocx.infcx.at(&ObligationCause::dummy(), param_env),
                         ty_a,
                     )
-                    // TODO:
-                    .map_err(|_errs: Vec<FulfillmentError<'tcx>>| NoSolution)?;
+                    .map_err(|_errs: Vec<ScrubbedTraitError>| NoSolution)?;
                 }
                 let mut components = smallvec![];
                 push_outlives_components(tcx, ty_a, &mut components);