about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2024-01-15 15:31:30 +0100
committerlcnr <rust@lcnr.de>2024-02-22 17:43:59 +0100
commit49dc0f22f43e54f6ddac568f3773d8cae63aeaac (patch)
tree60d5ff249035a6104ca90800f8aecfb1d696546d /compiler/rustc_trait_selection
parentf7cdff825c9a8087406ce56792e07d19f2d04e17 (diff)
downloadrust-49dc0f22f43e54f6ddac568f3773d8cae63aeaac.tar.gz
rust-49dc0f22f43e54f6ddac568f3773d8cae63aeaac.zip
do not use <: in subtyping overflow msg
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/type_err_ctxt_ext.rs27
1 files changed, 20 insertions, 7 deletions
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 a5411a04d59..eaae900549e 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
@@ -239,13 +239,26 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
             }
             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}`",
-                )
+                match predicate.kind().skip_binder() {
+                    ty::PredicateKind::Subtype(ty::SubtypePredicate { a, b, a_is_expected: _ })
+                    | ty::PredicateKind::Coerce(ty::CoercePredicate { a, b }) => {
+                        struct_span_code_err!(
+                            self.dcx(),
+                            span,
+                            E0275,
+                            "overflow setting `{a}` to a subtype of `{b}`",
+                        )
+                    }
+                    _ => {
+                        let pred_str = with_short_path(self.tcx, predicate);
+                        struct_span_code_err!(
+                            self.dcx(),
+                            span,
+                            E0275,
+                            "overflow evaluating the requirement `{pred_str}`",
+                        )
+                    }
+                }
             }
         };