about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2018-09-20 08:06:57 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2018-10-25 16:48:15 +0200
commitd2e682afed62b3ba7b6cea55b6f8fcea296861a7 (patch)
tree541779e702e2e0ee4f0451e4d8054263c6b7f6a0
parent7ed7fc881e7f4dabcdc45646257ddb979822d7f4 (diff)
preserve const eval error information through trait error system
-rw-r--r--src/librustc/mir/interpret/error.rs2
-rw-r--r--src/librustc/traits/error_reporting.rs2
-rw-r--r--src/librustc/traits/fulfill.rs10
-rw-r--r--src/librustc/traits/mod.rs3
-rw-r--r--src/librustc/traits/structural_impls.rs2
5 files changed, 11 insertions, 8 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index 75ce9b55c50..2445ce334c0 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -29,7 +29,7 @@ use syntax_pos::Span;
 use syntax::ast;
 use syntax::symbol::Symbol;
 
-#[derive(Debug, Clone, PartialEq, Eq)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
 pub enum ErrorHandled {
     /// Already reported a lint or an error for this evaluation
     Reported,
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs
index a7513b325fe..7d52e9438f8 100644
--- a/src/librustc/traits/error_reporting.rs
+++ b/src/librustc/traits/error_reporting.rs
@@ -881,7 +881,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
             }
 
             // already reported in the query
-            ConstEvalFailure => {
+            ConstEvalFailure(_) => {
                 self.tcx.sess.delay_span_bug(span, "constant in type had an ignored error");
                 return;
             }
diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs
index 320902263af..cfa77b210e8 100644
--- a/src/librustc/traits/fulfill.rs
+++ b/src/librustc/traits/fulfill.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use infer::InferCtxt;
-use mir::interpret::GlobalId;
+use mir::interpret::{GlobalId, ErrorHandled};
 use ty::{self, Ty, TypeFoldable, ToPolyTraitRef, ToPredicate};
 use ty::error::ExpectedFound;
 use rustc_data_structures::obligation_forest::{Error, ForestObligation, ObligationForest};
@@ -489,11 +489,13 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
                                     match self.selcx.tcx().at(obligation.cause.span)
                                                           .const_eval(param_env.and(cid)) {
                                         Ok(_) => ProcessResult::Changed(vec![]),
-                                        Err(_) => ProcessResult::Error(
-                                            CodeSelectionError(ConstEvalFailure))
+                                        Err(err) => ProcessResult::Error(
+                                            CodeSelectionError(ConstEvalFailure(err)))
                                     }
                                 } else {
-                                    ProcessResult::Error(CodeSelectionError(ConstEvalFailure))
+                                    ProcessResult::Error(CodeSelectionError(
+                                        ConstEvalFailure(ErrorHandled::TooGeneric)
+                                    ))
                                 }
                             },
                             None => {
diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs
index c809c94f444..6b2ec64668e 100644
--- a/src/librustc/traits/mod.rs
+++ b/src/librustc/traits/mod.rs
@@ -23,6 +23,7 @@ use hir::def_id::DefId;
 use infer::SuppressRegionErrors;
 use infer::outlives::env::OutlivesEnvironment;
 use middle::region;
+use mir::interpret::ErrorHandled;
 use ty::subst::Substs;
 use ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate};
 use ty::error::{ExpectedFound, TypeError};
@@ -437,7 +438,7 @@ pub enum SelectionError<'tcx> {
                                 ty::PolyTraitRef<'tcx>,
                                 ty::error::TypeError<'tcx>),
     TraitNotObjectSafe(DefId),
-    ConstEvalFailure,
+    ConstEvalFailure(ErrorHandled),
     Overflow,
 }
 
diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs
index e7cb9ff0623..24779a350d7 100644
--- a/src/librustc/traits/structural_impls.rs
+++ b/src/librustc/traits/structural_impls.rs
@@ -172,7 +172,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::SelectionError<'a> {
                 )
             }
             super::TraitNotObjectSafe(def_id) => Some(super::TraitNotObjectSafe(def_id)),
-            super::ConstEvalFailure(ref err) => Some(super::ConstEvalFailure),
+            super::ConstEvalFailure(err) => Some(super::ConstEvalFailure(err)),
             super::Overflow => Some(super::Overflow),
         }
     }