about summary refs log tree commit diff
path: root/src/librustc_trait_selection
diff options
context:
space:
mode:
authorBastian Kauschke <bastian_kauschke@hotmail.de>2020-05-07 10:26:12 +0200
committerBastian Kauschke <bastian_kauschke@hotmail.de>2020-05-17 11:05:05 +0200
commite873eef1e37eb45bdafda02ad4a3a4d599cee401 (patch)
treedd7bfec75244a1844196b89e07080beb469c24dd /src/librustc_trait_selection
parentafd7ea88fb887627dd551309b951a5b69ea90d98 (diff)
explicitly handle errors in fulfill
Diffstat (limited to 'src/librustc_trait_selection')
-rw-r--r--src/librustc_trait_selection/traits/fulfill.rs23
1 files changed, 12 insertions, 11 deletions
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(..)")
-                    }
                 }
             }
         }