summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-01-11 20:26:12 +0000
committerMichael Goulet <michael@errs.io>2023-01-13 23:19:36 +0000
commit75074e0e528cf8a50310bc0de19f73b60e8c8304 (patch)
treef35f28794f2cc2d063b6d739b6df58b1dc1fa160 /compiler/rustc_trait_selection/src
parent6ec8c13e15824d5b0dbdca5ab404d15af3e68f48 (diff)
downloadrust-75074e0e528cf8a50310bc0de19f73b60e8c8304.tar.gz
rust-75074e0e528cf8a50310bc0de19f73b60e8c8304.zip
Delay normalization bugs instead of reporting them
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/traits/misc.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/misc.rs b/compiler/rustc_trait_selection/src/traits/misc.rs
index 0de44dba0dd..a41a601f2db 100644
--- a/compiler/rustc_trait_selection/src/traits/misc.rs
+++ b/compiler/rustc_trait_selection/src/traits/misc.rs
@@ -8,8 +8,6 @@ use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
 use rustc_infer::{infer::outlives::env::OutlivesEnvironment, traits::FulfillmentError};
 use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable};
 
-use crate::traits::error_reporting::TypeErrCtxtExt;
-
 use super::outlives_bounds::InferCtxtExt;
 
 pub enum CopyImplementationError<'tcx> {
@@ -60,8 +58,8 @@ pub fn type_allowed_to_implement_copy<'tcx>(
             let infcx = tcx.infer_ctxt().build();
             let ocx = traits::ObligationCtxt::new(&infcx);
 
-            let ty = field.ty(tcx, substs);
-            if ty.references_error() {
+            let unnormalized_ty = field.ty(tcx, substs);
+            if unnormalized_ty.references_error() {
                 continue;
             }
 
@@ -84,12 +82,10 @@ pub fn type_allowed_to_implement_copy<'tcx>(
             } else {
                 ObligationCause::dummy_with_span(field_ty_span)
             };
-            let ty = ocx.normalize(&normalization_cause, param_env, ty);
+            let ty = ocx.normalize(&normalization_cause, param_env, unnormalized_ty);
             let normalization_errors = ocx.select_where_possible();
             if !normalization_errors.is_empty() {
-                // Don't report this as a field that doesn't implement Copy,
-                // but instead just implement this as a field that isn't WF.
-                infcx.err_ctxt().report_fulfillment_errors(&normalization_errors, None);
+                tcx.sess.delay_span_bug(field_span, format!("couldn't normalize struct field `{unnormalized_ty}` when checking Copy implementation"));
                 continue;
             }