diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 1c4f0ca5069df..11b051b530198 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -657,6 +657,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate) } + ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..)) + if self.next_trait_solver() => + { + // We normalize `TypeOutlives` in the next solver, which is fallible + return self.dcx().span_delayed_bug( + span, + "type outlives claues errored outside borrowck without any other error", + ); + } ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..)) | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..)) => { span_bug!( diff --git a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs new file mode 100644 index 0000000000000..61a9a1df8e8ee --- /dev/null +++ b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs @@ -0,0 +1,13 @@ +//@ compile-flags: -Znext-solver + +// Regression test for + +trait Z<'a, T: ?Sized> +where + T: Z<'a, ()>, //~ ERROR: the trait bound `(): Z<'a, ()>` is not satisfied + for<'b> >::W: 'a, +{ + type W; +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr new file mode 100644 index 0000000000000..80f1a9328d5e0 --- /dev/null +++ b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `(): Z<'a, ()>` is not satisfied + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:7:8 + | +LL | T: Z<'a, ()>, + | ^^^^^^^^^ the trait `Z<'a, ()>` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:5:1 + | +LL | trait Z<'a, T: ?Sized> + | ^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `Z` + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:7:8 + | +LL | trait Z<'a, T: ?Sized> + | - required by a bound in this trait +LL | where +LL | T: Z<'a, ()>, + | ^^^^^^^^^ required by this bound in `Z` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`.