use rustc_data_structures::obligation_forest::{Error, ForestObligation, Outcome};
use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor};
use rustc_errors::ErrorReported;
-use rustc_infer::traits::{TraitEngine, TraitEngineExt as _, TraitObligation};
+use rustc_infer::traits::{SelectionError, TraitEngine, TraitEngineExt as _, TraitObligation};
+use rustc_middle::mir::abstract_const::NotConstEvaluatable;
use rustc_middle::mir::interpret::ErrorHandled;
use rustc_middle::ty::error::ExpectedFound;
use rustc_middle::ty::subst::SubstsRef;
use super::CodeAmbiguity;
use super::CodeProjectionError;
use super::CodeSelectionError;
-use super::{ConstEvalFailure, Unimplemented};
+use super::Unimplemented;
use super::{FulfillmentError, FulfillmentErrorCode};
use super::{ObligationCause, PredicateObligation};
obligation.cause.span,
) {
Ok(()) => ProcessResult::Changed(vec![]),
- Err(ErrorHandled::TooGeneric) => {
+ Err(NotConstEvaluatable::MentionsInfer) => {
pending_obligation.stalled_on.clear();
pending_obligation.stalled_on.extend(
substs.iter().filter_map(TyOrConstInferVar::maybe_from_generic_arg),
);
ProcessResult::Unchanged
}
- Err(e) => ProcessResult::Error(CodeSelectionError(ConstEvalFailure(e))),
+ Err(
+ e @ NotConstEvaluatable::MentionsParam
+ | e @ NotConstEvaluatable::Error(_),
+ ) => ProcessResult::Error(CodeSelectionError(
+ SelectionError::NotConstEvaluatable(e),
+ )),
}
}
// if the constants depend on generic parameters.
//
// Let's just see where this breaks :shrug:
- if let (
- ty::ConstKind::Unevaluated(a_def, a_substs, None),
- ty::ConstKind::Unevaluated(b_def, b_substs, None),
- ) = (c1.val, c2.val)
+ if let (ty::ConstKind::Unevaluated(a), ty::ConstKind::Unevaluated(b)) =
+ (c1.val, c2.val)
{
if self
.selcx
.tcx()
- .try_unify_abstract_consts(((a_def, a_substs), (b_def, b_substs)))
+ .try_unify_abstract_consts(((a.def, a.substs), (b.def, b.substs)))
{
return ProcessResult::Changed(vec![]);
}
let stalled_on = &mut pending_obligation.stalled_on;
let mut evaluate = |c: &'tcx Const<'tcx>| {
- if let ty::ConstKind::Unevaluated(def, substs, promoted) = c.val {
+ if let ty::ConstKind::Unevaluated(unevaluated) = c.val {
match self.selcx.infcx().const_eval_resolve(
obligation.param_env,
- def,
- substs,
- promoted,
+ unevaluated,
Some(obligation.cause.span),
) {
Ok(val) => Ok(Const::from_value(self.selcx.tcx(), val, c.ty)),
Err(ErrorHandled::TooGeneric) => {
stalled_on.extend(
- substs
+ unevaluated
+ .substs
.iter()
.filter_map(TyOrConstInferVar::maybe_from_generic_arg),
);
}
}
(Err(ErrorHandled::Reported(ErrorReported)), _)
- | (_, Err(ErrorHandled::Reported(ErrorReported))) => {
- ProcessResult::Error(CodeSelectionError(ConstEvalFailure(
- ErrorHandled::Reported(ErrorReported),
- )))
- }
+ | (_, Err(ErrorHandled::Reported(ErrorReported))) => ProcessResult::Error(
+ CodeSelectionError(SelectionError::NotConstEvaluatable(
+ NotConstEvaluatable::Error(ErrorReported),
+ )),
+ ),
(Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => {
span_bug!(
obligation.cause.span(self.selcx.tcx()),
/// Returns the set of inference variables contained in `substs`.
fn substs_infer_vars<'a, 'tcx>(
selcx: &mut SelectionContext<'a, 'tcx>,
- substs: ty::Binder<SubstsRef<'tcx>>,
+ substs: ty::Binder<'tcx, SubstsRef<'tcx>>,
) -> impl Iterator<Item = TyOrConstInferVar<'tcx>> {
selcx
.infcx()