]> git.lizzy.rs Git - rust.git/commitdiff
preserve const eval error information through trait error system
authorRalf Jung <post@ralfj.de>
Thu, 20 Sep 2018 06:06:57 +0000 (08:06 +0200)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 25 Oct 2018 14:48:15 +0000 (16:48 +0200)
src/librustc/mir/interpret/error.rs
src/librustc/traits/error_reporting.rs
src/librustc/traits/fulfill.rs
src/librustc/traits/mod.rs
src/librustc/traits/structural_impls.rs

index 75ce9b55c503774b8d0cc03a0dbbb813bde85a75..2445ce334c0e796a47b98817e75a929e189ba185 100644 (file)
@@ -29,7 +29,7 @@
 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,
index a7513b325fe6dd8f0821c59876aed373f1420a3b..7d52e9438f86978a2edae2ef1c3086056fc3b3a7 100644 (file)
@@ -881,7 +881,7 @@ pub fn report_selection_error(&self,
             }
 
             // already reported in the query
-            ConstEvalFailure => {
+            ConstEvalFailure(_) => {
                 self.tcx.sess.delay_span_bug(span, "constant in type had an ignored error");
                 return;
             }
index 320902263af61a5ec32cc6c322f9d12aed49acc4..cfa77b210e857769f2a3e8f58640bc11367bffab 100644 (file)
@@ -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 @@ fn process_obligation(&mut self,
                                     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 => {
index c809c94f4449de949cb2992d57e5c8f867242685..6b2ec64668e9bbb006e1bbce46a7392ff0e9976a 100644 (file)
@@ -23,6 +23,7 @@
 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,
 }
 
index e7cb9ff06234f1fb0ee3e5a2059325ad760b0b11..24779a350d74bdfcf5382244a26db480dfd44560 100644 (file)
@@ -172,7 +172,7 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
                 )
             }
             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),
         }
     }