about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_trait_selection/src/solve/normalize.rs10
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs89
-rw-r--r--compiler/rustc_trait_selection/src/traits/fulfill.rs7
-rw-r--r--compiler/rustc_trait_selection/src/traits/normalize.rs14
-rw-r--r--compiler/rustc_trait_selection/src/traits/query/normalize.rs7
-rw-r--r--compiler/rustc_type_ir/src/ty_kind.rs11
-rw-r--r--tests/ui/impl-trait/issues/issue-62742.rs1
-rw-r--r--tests/ui/impl-trait/issues/issue-62742.stderr26
-rw-r--r--tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr6
-rw-r--r--tests/ui/infinite/infinite-type-alias-mutual-recursion.rs6
-rw-r--r--tests/ui/infinite/infinite-vec-type-recursion.feature.stderr2
-rw-r--r--tests/ui/infinite/infinite-vec-type-recursion.rs2
-rw-r--r--tests/ui/lazy-type-alias/inherent-impls-overflow.classic.stderr16
-rw-r--r--tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr6
-rw-r--r--tests/ui/lazy-type-alias/inherent-impls-overflow.rs14
15 files changed, 126 insertions, 91 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs
index 91312c9fdd6..b1c03e82cab 100644
--- a/compiler/rustc_trait_selection/src/solve/normalize.rs
+++ b/compiler/rustc_trait_selection/src/solve/normalize.rs
@@ -1,4 +1,4 @@
-use crate::traits::error_reporting::TypeErrCtxtExt;
+use crate::traits::error_reporting::{OverflowCause, TypeErrCtxtExt};
 use crate::traits::query::evaluate_obligation::InferCtxtExt;
 use crate::traits::{BoundVarReplacer, PlaceholderReplacer};
 use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -60,8 +60,12 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
         let tcx = infcx.tcx;
         let recursion_limit = tcx.recursion_limit();
         if !recursion_limit.value_within_limit(self.depth) {
+            let ty::Alias(_, data) = *alias_ty.kind() else {
+                unreachable!();
+            };
+
             self.at.infcx.err_ctxt().report_overflow_error(
-                &alias_ty,
+                OverflowCause::DeeplyNormalize(data),
                 self.at.cause.span,
                 true,
                 |_| {},
@@ -109,7 +113,7 @@ impl<'tcx> NormalizationFolder<'_, 'tcx> {
         let recursion_limit = tcx.recursion_limit();
         if !recursion_limit.value_within_limit(self.depth) {
             self.at.infcx.err_ctxt().report_overflow_error(
-                &ty::Const::new_unevaluated(tcx, uv, ty),
+                OverflowCause::DeeplyNormalize(ty::AliasTy::new(tcx, uv.def, uv.args)),
                 self.at.cause.span,
                 true,
                 |_| {},
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
index be4c6b4d9d1..a5411a04d59 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs
@@ -57,6 +57,11 @@ use super::{
 
 pub use rustc_infer::traits::error_reporting::*;
 
+pub enum OverflowCause<'tcx> {
+    DeeplyNormalize(ty::AliasTy<'tcx>),
+    TraitSolver(ty::Predicate<'tcx>),
+}
+
 #[extension(pub trait TypeErrCtxtExt<'tcx>)]
 impl<'tcx> TypeErrCtxt<'_, 'tcx> {
     fn report_fulfillment_errors(
@@ -184,49 +189,65 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
     /// whose result could not be truly determined and thus we can't say
     /// if the program type checks or not -- and they are unusual
     /// occurrences in any case.
-    fn report_overflow_error<T>(
+    fn report_overflow_error(
         &self,
-        predicate: &T,
+        cause: OverflowCause<'tcx>,
         span: Span,
         suggest_increasing_limit: bool,
         mutate: impl FnOnce(&mut DiagnosticBuilder<'_>),
-    ) -> !
-    where
-        T: fmt::Display + TypeFoldable<TyCtxt<'tcx>> + Print<'tcx, FmtPrinter<'tcx, 'tcx>>,
-    {
-        let mut err = self.build_overflow_error(predicate, span, suggest_increasing_limit);
+    ) -> ! {
+        let mut err = self.build_overflow_error(cause, span, suggest_increasing_limit);
         mutate(&mut err);
         err.emit();
         FatalError.raise();
     }
 
-    fn build_overflow_error<T>(
+    fn build_overflow_error(
         &self,
-        predicate: &T,
+        cause: OverflowCause<'tcx>,
         span: Span,
         suggest_increasing_limit: bool,
-    ) -> DiagnosticBuilder<'tcx>
-    where
-        T: fmt::Display + TypeFoldable<TyCtxt<'tcx>> + Print<'tcx, FmtPrinter<'tcx, 'tcx>>,
-    {
-        let predicate = self.resolve_vars_if_possible(predicate.clone());
-        let mut pred_str = predicate.to_string();
-
-        if pred_str.len() > 50 {
-            // We don't need to save the type to a file, we will be talking about this type already
-            // in a separate note when we explain the obligation, so it will be available that way.
-            let mut cx: FmtPrinter<'_, '_> =
-                FmtPrinter::new_with_limit(self.tcx, Namespace::TypeNS, rustc_session::Limit(6));
-            predicate.print(&mut cx).unwrap();
-            pred_str = cx.into_buffer();
+    ) -> DiagnosticBuilder<'tcx> {
+        fn with_short_path<'tcx, T>(tcx: TyCtxt<'tcx>, value: T) -> String
+        where
+            T: fmt::Display + Print<'tcx, FmtPrinter<'tcx, 'tcx>>,
+        {
+            let s = value.to_string();
+            if s.len() > 50 {
+                // We don't need to save the type to a file, we will be talking about this type already
+                // in a separate note when we explain the obligation, so it will be available that way.
+                let mut cx: FmtPrinter<'_, '_> =
+                    FmtPrinter::new_with_limit(tcx, Namespace::TypeNS, rustc_session::Limit(6));
+                value.print(&mut cx).unwrap();
+                cx.into_buffer()
+            } else {
+                s
+            }
         }
-        let mut err = struct_span_code_err!(
-            self.dcx(),
-            span,
-            E0275,
-            "overflow evaluating the requirement `{}`",
-            pred_str,
-        );
+
+        let mut err = match cause {
+            OverflowCause::DeeplyNormalize(alias_ty) => {
+                let alias_ty = self.resolve_vars_if_possible(alias_ty);
+                let kind = alias_ty.opt_kind(self.tcx).map_or("alias", |k| k.descr());
+                let alias_str = with_short_path(self.tcx, alias_ty);
+                struct_span_code_err!(
+                    self.dcx(),
+                    span,
+                    E0275,
+                    "overflow normalizing the {kind} `{alias_str}`",
+                )
+            }
+            OverflowCause::TraitSolver(predicate) => {
+                let predicate = self.resolve_vars_if_possible(predicate);
+                let pred_str = with_short_path(self.tcx, predicate);
+                struct_span_code_err!(
+                    self.dcx(),
+                    span,
+                    E0275,
+                    "overflow evaluating the requirement `{pred_str}`",
+                )
+            }
+        };
 
         if suggest_increasing_limit {
             self.suggest_new_overflow_limit(&mut err);
@@ -252,7 +273,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
         let predicate = obligation.predicate.clone().to_predicate(self.tcx);
         let predicate = self.resolve_vars_if_possible(predicate);
         self.report_overflow_error(
-            &predicate,
+            OverflowCause::TraitSolver(predicate),
             obligation.cause.span,
             suggest_increasing_limit,
             |err| {
@@ -303,7 +324,11 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
 
     fn report_overflow_no_abort(&self, obligation: PredicateObligation<'tcx>) -> ErrorGuaranteed {
         let obligation = self.resolve_vars_if_possible(obligation);
-        let mut err = self.build_overflow_error(&obligation.predicate, obligation.cause.span, true);
+        let mut err = self.build_overflow_error(
+            OverflowCause::TraitSolver(obligation.predicate),
+            obligation.cause.span,
+            true,
+        );
         self.note_obligation_cause(&mut err, &obligation);
         self.point_at_returns_when_relevant(&mut err, &obligation);
         err.emit()
diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs
index fd981130af8..b91698af942 100644
--- a/compiler/rustc_trait_selection/src/traits/fulfill.rs
+++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs
@@ -450,12 +450,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
                     .recursion_limit()
                     .value_within_limit(obligation.recursion_depth) =>
                 {
-                    self.selcx.infcx.err_ctxt().report_overflow_error(
-                        &obligation.predicate,
-                        obligation.cause.span,
-                        false,
-                        |_| {},
-                    );
+                    self.selcx.infcx.err_ctxt().report_overflow_obligation(&obligation, false);
                 }
 
                 ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(arg)) => {
diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs
index 429e5a5d7a4..15bfffef3ce 100644
--- a/compiler/rustc_trait_selection/src/traits/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/normalize.rs
@@ -1,4 +1,8 @@
 //! Deeply normalize types using the old trait solver.
+use super::error_reporting::OverflowCause;
+use super::error_reporting::TypeErrCtxtExt;
+use super::SelectionContext;
+use super::{project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer};
 use rustc_data_structures::stack::ensure_sufficient_stack;
 use rustc_infer::infer::at::At;
 use rustc_infer::infer::InferOk;
@@ -8,10 +12,6 @@ use rustc_middle::traits::{ObligationCause, ObligationCauseCode, Reveal};
 use rustc_middle::ty::{self, Ty, TyCtxt, TypeFolder};
 use rustc_middle::ty::{TypeFoldable, TypeSuperFoldable, TypeVisitable, TypeVisitableExt};
 
-use super::error_reporting::TypeErrCtxtExt;
-use super::SelectionContext;
-use super::{project, with_replaced_escaping_bound_vars, BoundVarReplacer, PlaceholderReplacer};
-
 #[extension(pub trait NormalizeExt<'tcx>)]
 impl<'tcx> At<'_, 'tcx> {
     /// Normalize a value using the `AssocTypeNormalizer`.
@@ -173,7 +173,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
         }
 
         let (kind, data) = match *ty.kind() {
-            ty::Alias(kind, alias_ty) => (kind, alias_ty),
+            ty::Alias(kind, data) => (kind, data),
             _ => return ty.super_fold_with(self),
         };
 
@@ -210,7 +210,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
                         let recursion_limit = self.interner().recursion_limit();
                         if !recursion_limit.value_within_limit(self.depth) {
                             self.selcx.infcx.err_ctxt().report_overflow_error(
-                                &ty,
+                                OverflowCause::DeeplyNormalize(data),
                                 self.cause.span,
                                 true,
                                 |_| {},
@@ -306,7 +306,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
                 let recursion_limit = self.interner().recursion_limit();
                 if !recursion_limit.value_within_limit(self.depth) {
                     self.selcx.infcx.err_ctxt().report_overflow_error(
-                        &ty,
+                        OverflowCause::DeeplyNormalize(data),
                         self.cause.span,
                         false,
                         |diag| {
diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
index 70fd0b7e50b..e5f8e336860 100644
--- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs
+++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
@@ -5,6 +5,7 @@
 use crate::infer::at::At;
 use crate::infer::canonical::OriginalQueryValues;
 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};
@@ -228,7 +229,11 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
                             let guar = self
                                 .infcx
                                 .err_ctxt()
-                                .build_overflow_error(&ty, self.cause.span, true)
+                                .build_overflow_error(
+                                    OverflowCause::DeeplyNormalize(data),
+                                    self.cause.span,
+                                    true,
+                                )
                                 .delay_as_bug();
                             return Ok(Ty::new_error(self.interner(), guar));
                         }
diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs
index d389933fd2d..9f715a01d44 100644
--- a/compiler/rustc_type_ir/src/ty_kind.rs
+++ b/compiler/rustc_type_ir/src/ty_kind.rs
@@ -105,6 +105,17 @@ pub enum AliasKind {
     Weak,
 }
 
+impl AliasKind {
+    pub fn descr(self) -> &'static str {
+        match self {
+            AliasKind::Projection => "associated type",
+            AliasKind::Inherent => "inherent associated type",
+            AliasKind::Opaque => "opaque type",
+            AliasKind::Weak => "type alias",
+        }
+    }
+}
+
 /// Defines the kinds of types used by the type system.
 ///
 /// Types written by the user start out as `hir::TyKind` and get
diff --git a/tests/ui/impl-trait/issues/issue-62742.rs b/tests/ui/impl-trait/issues/issue-62742.rs
index a980856f476..11a75737e55 100644
--- a/tests/ui/impl-trait/issues/issue-62742.rs
+++ b/tests/ui/impl-trait/issues/issue-62742.rs
@@ -4,7 +4,6 @@ fn _alias_check() {
     WrongImpl::foo(0i32);
     //~^ ERROR the trait bound `RawImpl<_>: Raw<_>` is not satisfied
     //~| ERROR the trait bound `RawImpl<_>: Raw<_>` is not satisfied
-    //~| ERROR the trait bound `RawImpl<_>: Raw<_>` is not satisfied
     WrongImpl::<()>::foo(0i32);
     //~^ ERROR the trait bound `RawImpl<()>: Raw<()>` is not satisfied
     //~| ERROR trait bounds were not satisfied
diff --git a/tests/ui/impl-trait/issues/issue-62742.stderr b/tests/ui/impl-trait/issues/issue-62742.stderr
index 825a48ae919..9ec581c231b 100644
--- a/tests/ui/impl-trait/issues/issue-62742.stderr
+++ b/tests/ui/impl-trait/issues/issue-62742.stderr
@@ -2,11 +2,11 @@ error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
   --> $DIR/issue-62742.rs:4:5
    |
 LL |     WrongImpl::foo(0i32);
-   |     ^^^^^^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
+   |     ^^^^^^^^^^^^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
    |
    = help: the trait `Raw<[_]>` is implemented for `RawImpl<_>`
 note: required by a bound in `SafeImpl::<T, A>::foo`
-  --> $DIR/issue-62742.rs:30:20
+  --> $DIR/issue-62742.rs:29:20
    |
 LL | impl<T: ?Sized, A: Raw<T>> SafeImpl<T, A> {
    |                    ^^^^^^ required by this bound in `SafeImpl::<T, A>::foo`
@@ -21,21 +21,13 @@ LL |     WrongImpl::foo(0i32);
    |
    = help: the trait `Raw<[_]>` is implemented for `RawImpl<_>`
 note: required by a bound in `SafeImpl`
-  --> $DIR/issue-62742.rs:28:35
+  --> $DIR/issue-62742.rs:27:35
    |
 LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
    |                                   ^^^^^^ required by this bound in `SafeImpl`
 
-error[E0277]: the trait bound `RawImpl<_>: Raw<_>` is not satisfied
-  --> $DIR/issue-62742.rs:4:5
-   |
-LL |     WrongImpl::foo(0i32);
-   |     ^^^^^^^^^^^^^^^^^^^^ the trait `Raw<_>` is not implemented for `RawImpl<_>`
-   |
-   = help: the trait `Raw<[_]>` is implemented for `RawImpl<_>`
-
 error[E0599]: the function or associated item `foo` exists for struct `SafeImpl<(), RawImpl<()>>`, but its trait bounds were not satisfied
-  --> $DIR/issue-62742.rs:8:22
+  --> $DIR/issue-62742.rs:7:22
    |
 LL |     WrongImpl::<()>::foo(0i32);
    |                      ^^^ function or associated item cannot be called on `SafeImpl<(), RawImpl<()>>` due to unsatisfied trait bounds
@@ -47,20 +39,20 @@ LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
    | ----------------------------------------- function or associated item `foo` not found for this struct
    |
 note: trait bound `RawImpl<()>: Raw<()>` was not satisfied
-  --> $DIR/issue-62742.rs:30:20
+  --> $DIR/issue-62742.rs:29:20
    |
 LL | impl<T: ?Sized, A: Raw<T>> SafeImpl<T, A> {
    |                    ^^^^^^  --------------
    |                    |
    |                    unsatisfied trait bound introduced here
 note: the trait `Raw` must be implemented
-  --> $DIR/issue-62742.rs:14:1
+  --> $DIR/issue-62742.rs:13:1
    |
 LL | pub trait Raw<T: ?Sized> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0277]: the trait bound `RawImpl<()>: Raw<()>` is not satisfied
-  --> $DIR/issue-62742.rs:8:5
+  --> $DIR/issue-62742.rs:7:5
    |
 LL |     WrongImpl::<()>::foo(0i32);
    |     ^^^^^^^^^^^^^^^ the trait `Raw<()>` is not implemented for `RawImpl<()>`
@@ -68,12 +60,12 @@ LL |     WrongImpl::<()>::foo(0i32);
    = help: the trait `Raw<[()]>` is implemented for `RawImpl<()>`
    = help: for that trait implementation, expected `[()]`, found `()`
 note: required by a bound in `SafeImpl`
-  --> $DIR/issue-62742.rs:28:35
+  --> $DIR/issue-62742.rs:27:35
    |
 LL | pub struct SafeImpl<T: ?Sized, A: Raw<T>>(PhantomData<(A, T)>);
    |                                   ^^^^^^ required by this bound in `SafeImpl`
 
-error: aborting due to 5 previous errors
+error: aborting due to 4 previous errors
 
 Some errors have detailed explanations: E0277, E0599.
 For more information about an error, try `rustc --explain E0277`.
diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr
index 8b8fc46dfc5..3dec2c3084f 100644
--- a/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr
+++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr
@@ -1,4 +1,4 @@
-error[E0275]: overflow evaluating the requirement `X2`
+error[E0275]: overflow normalizing the type alias `X2`
   --> $DIR/infinite-type-alias-mutual-recursion.rs:6:11
    |
 LL | type X1 = X2;
@@ -6,7 +6,7 @@ LL | type X1 = X2;
    |
    = note: in case this is a recursive type alias, consider using a struct, enum, or union instead
 
-error[E0275]: overflow evaluating the requirement `X3`
+error[E0275]: overflow normalizing the type alias `X3`
   --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11
    |
 LL | type X2 = X3;
@@ -14,7 +14,7 @@ LL | type X2 = X3;
    |
    = note: in case this is a recursive type alias, consider using a struct, enum, or union instead
 
-error[E0275]: overflow evaluating the requirement `X1`
+error[E0275]: overflow normalizing the type alias `X1`
   --> $DIR/infinite-type-alias-mutual-recursion.rs:11:11
    |
 LL | type X3 = X1;
diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs b/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs
index 91cfe89e28a..cf9ea0db4cb 100644
--- a/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs
+++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.rs
@@ -5,10 +5,10 @@
 
 type X1 = X2;
 //[gated]~^ ERROR cycle detected when expanding type alias `X1`
-//[feature]~^^ ERROR: overflow evaluating the requirement `X2`
+//[feature]~^^ ERROR: overflow normalizing the type alias `X2`
 type X2 = X3;
-//[feature]~^ ERROR: overflow evaluating the requirement `X3`
+//[feature]~^ ERROR: overflow normalizing the type alias `X3`
 type X3 = X1;
-//[feature]~^ ERROR: overflow evaluating the requirement `X1`
+//[feature]~^ ERROR: overflow normalizing the type alias `X1`
 
 fn main() {}
diff --git a/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr b/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr
index 3aac0d7d1db..5c8d50341c1 100644
--- a/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr
+++ b/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr
@@ -1,4 +1,4 @@
-error[E0275]: overflow evaluating the requirement `X`
+error[E0275]: overflow normalizing the type alias `X`
   --> $DIR/infinite-vec-type-recursion.rs:6:10
    |
 LL | type X = Vec<X>;
diff --git a/tests/ui/infinite/infinite-vec-type-recursion.rs b/tests/ui/infinite/infinite-vec-type-recursion.rs
index ff270f3bf8c..c051d11d376 100644
--- a/tests/ui/infinite/infinite-vec-type-recursion.rs
+++ b/tests/ui/infinite/infinite-vec-type-recursion.rs
@@ -5,7 +5,7 @@
 
 type X = Vec<X>;
 //[gated]~^ ERROR cycle detected
-//[feature]~^^ ERROR: overflow evaluating the requirement `X`
+//[feature]~^^ ERROR: overflow normalizing the type alias `X`
 
 #[rustfmt::skip]
 fn main() { let b: X = Vec::new(); }
diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.classic.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.classic.stderr
index 1cace470627..2f00a877142 100644
--- a/tests/ui/lazy-type-alias/inherent-impls-overflow.classic.stderr
+++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.classic.stderr
@@ -1,4 +1,4 @@
-error[E0275]: overflow evaluating the requirement `Loop`
+error[E0275]: overflow normalizing the type alias `Loop`
   --> $DIR/inherent-impls-overflow.rs:7:13
    |
 LL | type Loop = Loop;
@@ -6,7 +6,7 @@ LL | type Loop = Loop;
    |
    = note: in case this is a recursive type alias, consider using a struct, enum, or union instead
 
-error[E0275]: overflow evaluating the requirement `Loop`
+error[E0275]: overflow normalizing the type alias `Loop`
   --> $DIR/inherent-impls-overflow.rs:9:1
    |
 LL | impl Loop {}
@@ -14,24 +14,24 @@ LL | impl Loop {}
    |
    = note: in case this is a recursive type alias, consider using a struct, enum, or union instead
 
-error[E0275]: overflow evaluating the requirement `Poly0<((((((...,),),),),),)>`
-  --> $DIR/inherent-impls-overflow.rs:11:17
+error[E0275]: overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>`
+  --> $DIR/inherent-impls-overflow.rs:13:17
    |
 LL | type Poly0<T> = Poly1<(T,)>;
    |                 ^^^^^^^^^^^
    |
    = note: in case this is a recursive type alias, consider using a struct, enum, or union instead
 
-error[E0275]: overflow evaluating the requirement `Poly1<((((((...,),),),),),)>`
-  --> $DIR/inherent-impls-overflow.rs:14:17
+error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>`
+  --> $DIR/inherent-impls-overflow.rs:16:17
    |
 LL | type Poly1<T> = Poly0<(T,)>;
    |                 ^^^^^^^^^^^
    |
    = note: in case this is a recursive type alias, consider using a struct, enum, or union instead
 
-error[E0275]: overflow evaluating the requirement `Poly1<((((((...,),),),),),)>`
-  --> $DIR/inherent-impls-overflow.rs:18:1
+error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>`
+  --> $DIR/inherent-impls-overflow.rs:20:1
    |
 LL | impl Poly0<()> {}
    | ^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr
index 1a6259b5cf9..85e8061f173 100644
--- a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr
+++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr
@@ -7,7 +7,7 @@ LL | impl Loop {}
    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`)
 
 error[E0392]: type parameter `T` is never used
-  --> $DIR/inherent-impls-overflow.rs:11:12
+  --> $DIR/inherent-impls-overflow.rs:13:12
    |
 LL | type Poly0<T> = Poly1<(T,)>;
    |            ^ unused type parameter
@@ -16,7 +16,7 @@ LL | type Poly0<T> = Poly1<(T,)>;
    = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
 
 error[E0392]: type parameter `T` is never used
-  --> $DIR/inherent-impls-overflow.rs:14:12
+  --> $DIR/inherent-impls-overflow.rs:16:12
    |
 LL | type Poly1<T> = Poly0<(T,)>;
    |            ^ unused type parameter
@@ -25,7 +25,7 @@ LL | type Poly1<T> = Poly0<(T,)>;
    = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
 
 error[E0275]: overflow evaluating the requirement `Poly0<()> == _`
-  --> $DIR/inherent-impls-overflow.rs:18:6
+  --> $DIR/inherent-impls-overflow.rs:20:6
    |
 LL | impl Poly0<()> {}
    |      ^^^^^^^^^
diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.rs b/tests/ui/lazy-type-alias/inherent-impls-overflow.rs
index b260dedeb07..dbf5c3743e8 100644
--- a/tests/ui/lazy-type-alias/inherent-impls-overflow.rs
+++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.rs
@@ -4,17 +4,21 @@
 #![feature(lazy_type_alias)]
 #![allow(incomplete_features)]
 
-type Loop = Loop; //[classic]~ ERROR overflow evaluating the requirement
+type Loop = Loop; //[classic]~ ERROR overflow normalizing the type alias `Loop`
 
-impl Loop {} //~ ERROR overflow evaluating the requirement
+impl Loop {}
+//[classic]~^ ERROR overflow normalizing the type alias `Loop`
+//[next]~^^ ERROR overflow evaluating the requirement `Loop == _`
 
 type Poly0<T> = Poly1<(T,)>;
-//[classic]~^ ERROR overflow evaluating the requirement
+//[classic]~^ ERROR overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>`
 //[next]~^^ ERROR type parameter `T` is never used
 type Poly1<T> = Poly0<(T,)>;
-//[classic]~^ ERROR overflow evaluating the requirement
+//[classic]~^ ERROR  overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>`
 //[next]~^^ ERROR type parameter `T` is never used
 
-impl Poly0<()> {} //~ ERROR overflow evaluating the requirement
+impl Poly0<()> {}
+//[classic]~^ ERROR overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>`
+//[next]~^^ ERROR overflow evaluating the requirement `Poly0<()> == _`
 
 fn main() {}