Use ScrubbedTraitError in more places

This commit is contained in:
Michael Goulet 2024-06-01 15:00:02 -04:00
parent eb0a70a557
commit 94a524ed11
7 changed files with 25 additions and 22 deletions

View File

@ -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",
)

View File

@ -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)

View File

@ -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)
}

View File

@ -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))
}
}

View File

@ -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,
}

View File

@ -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![] }),

View File

@ -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);