Skip to content

Commit

Permalink
Use ScrubbedTraitError in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jun 3, 2024
1 parent f011d53 commit d46fd62
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
)
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_trait_selection/src/regions.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -28,8 +28,7 @@ impl<'tcx> InferCtxt<'tcx> {
),
ty,
)
// TODO:
.map_err(|_: Vec<FulfillmentError<'tcx>>| NoSolution)
.map_err(|_: Vec<ScrubbedTraitError>| NoSolution)
} else {
Ok(ty)
}
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_trait_selection/src/solve/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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> {
Expand All @@ -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))
}
}
9 changes: 8 additions & 1 deletion compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_trait_selection/src/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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![] }),
Expand Down
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d46fd62

Please sign in to comment.