diff --git a/src/librustc_trait_selection/traits/fulfill.rs b/src/librustc_trait_selection/traits/fulfill.rs index cf107a6c5b5..98f6ac0e547 100644 --- a/src/librustc_trait_selection/traits/fulfill.rs +++ b/src/librustc_trait_selection/traits/fulfill.rs @@ -2,6 +2,7 @@ use crate::infer::{InferCtxt, TyOrConstInferVar}; use rustc_data_structures::obligation_forest::ProcessResult; use rustc_data_structures::obligation_forest::{DoCompleted, Error, ForestObligation}; use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor}; +use rustc_errors::ErrorReported; use rustc_infer::traits::{TraitEngine, TraitEngineExt as _}; use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::error::ExpectedFound; @@ -544,11 +545,9 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { .filter_map(|ty| TyOrConstInferVar::maybe_from_ty(ty)) .collect(), ); - Err(ProcessResult::Unchanged) - } - Err(err) => { - Err(ProcessResult::Error(CodeSelectionError(ConstEvalFailure(err)))) + Err(ErrorHandled::TooGeneric) } + Err(err) => Err(err), } } else { Ok(c) @@ -572,15 +571,17 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> { } } } - // FIXME(skinny121) How to report both errors if both produces errors? - (Err(result @ ProcessResult::Error(_)), _) - | (_, Err(result @ ProcessResult::Error(_))) => result, - (Err(ProcessResult::Unchanged), _) | (_, Err(ProcessResult::Unchanged)) => { + (Err(ErrorHandled::Reported(ErrorReported)), _) + | (_, Err(ErrorHandled::Reported(ErrorReported))) => ProcessResult::Error( + CodeSelectionError(ConstEvalFailure(ErrorHandled::Reported(ErrorReported))), + ), + (Err(ErrorHandled::Linted), _) | (_, Err(ErrorHandled::Linted)) => span_bug!( + obligation.cause.span(self.selcx.tcx()), + "ConstEquate: const_eval_resolve returned an unexpected error" + ), + (Err(ErrorHandled::TooGeneric), _) | (_, Err(ErrorHandled::TooGeneric)) => { ProcessResult::Unchanged } - _ => { - unreachable!("evaluate shouldn't itself return ProcessResult::Changed(..)") - } } } } diff --git a/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr index 8a97ec0c5fc..9a7844f5e8f 100644 --- a/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr +++ b/src/test/ui/const-generics/lazy-normalization/lazy-normalization-feature-gate.stderr @@ -1,40 +1,40 @@ warning: the feature `const_generics` is incomplete and may cause the compiler to crash - --> $DIR/lazy-normalization-feature-gate-hack.rs:2:12 + --> $DIR/lazy-normalization-feature-gate.rs:2:12 | LL | #![feature(const_generics)] | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default -error[E0391]: cycle detected when const-evaluating + checking `::{{constant}}#0` - --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 +error[E0391]: cycle detected when const-evaluating + checking `::{{constant}}#0` + --> $DIR/lazy-normalization-feature-gate.rs:6:58 | LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} | ^^^^^^^^^^ | -note: ...which requires const-evaluating + checking `::{{constant}}#0`... - --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 +note: ...which requires const-evaluating + checking `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate.rs:6:58 | LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} | ^^^^^^^^^^ -note: ...which requires const-evaluating `::{{constant}}#0`... - --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 +note: ...which requires const-evaluating `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate.rs:6:58 | LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} | ^^^^^^^^^^ -note: ...which requires type-checking `::{{constant}}#0`... - --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 +note: ...which requires type-checking `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate.rs:6:58 | LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} | ^^^^^^^^^^ -note: ...which requires processing `::{{constant}}#0`... - --> $DIR/lazy-normalization-feature-gate-hack.rs:6:58 +note: ...which requires processing `::{{constant}}#0`... + --> $DIR/lazy-normalization-feature-gate.rs:6:58 | LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} | ^^^^^^^^^^ - = note: ...which again requires const-evaluating + checking `::{{constant}}#0`, completing the cycle -note: cycle used when processing `` - --> $DIR/lazy-normalization-feature-gate-hack.rs:6:1 + = note: ...which again requires const-evaluating + checking `::{{constant}}#0`, completing the cycle +note: cycle used when processing `` + --> $DIR/lazy-normalization-feature-gate.rs:6:1 | LL | impl Foo for [(); N] where Self: FooImpl<{ N == 0 }> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^