Skip to content

Commit d2e682a

Browse files
RalfJungoli-obk
authored andcommitted
preserve const eval error information through trait error system
1 parent 7ed7fc8 commit d2e682a

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

src/librustc/mir/interpret/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use syntax_pos::Span;
2929
use syntax::ast;
3030
use syntax::symbol::Symbol;
3131

32-
#[derive(Debug, Clone, PartialEq, Eq)]
32+
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
3333
pub enum ErrorHandled {
3434
/// Already reported a lint or an error for this evaluation
3535
Reported,

src/librustc/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
881881
}
882882

883883
// already reported in the query
884-
ConstEvalFailure => {
884+
ConstEvalFailure(_) => {
885885
self.tcx.sess.delay_span_bug(span, "constant in type had an ignored error");
886886
return;
887887
}

src/librustc/traits/fulfill.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use infer::InferCtxt;
12-
use mir::interpret::GlobalId;
12+
use mir::interpret::{GlobalId, ErrorHandled};
1313
use ty::{self, Ty, TypeFoldable, ToPolyTraitRef, ToPredicate};
1414
use ty::error::ExpectedFound;
1515
use rustc_data_structures::obligation_forest::{Error, ForestObligation, ObligationForest};
@@ -489,11 +489,13 @@ impl<'a, 'b, 'gcx, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'gcx,
489489
match self.selcx.tcx().at(obligation.cause.span)
490490
.const_eval(param_env.and(cid)) {
491491
Ok(_) => ProcessResult::Changed(vec![]),
492-
Err(_) => ProcessResult::Error(
493-
CodeSelectionError(ConstEvalFailure))
492+
Err(err) => ProcessResult::Error(
493+
CodeSelectionError(ConstEvalFailure(err)))
494494
}
495495
} else {
496-
ProcessResult::Error(CodeSelectionError(ConstEvalFailure))
496+
ProcessResult::Error(CodeSelectionError(
497+
ConstEvalFailure(ErrorHandled::TooGeneric)
498+
))
497499
}
498500
},
499501
None => {

src/librustc/traits/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use hir::def_id::DefId;
2323
use infer::SuppressRegionErrors;
2424
use infer::outlives::env::OutlivesEnvironment;
2525
use middle::region;
26+
use mir::interpret::ErrorHandled;
2627
use ty::subst::Substs;
2728
use ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate};
2829
use ty::error::{ExpectedFound, TypeError};
@@ -437,7 +438,7 @@ pub enum SelectionError<'tcx> {
437438
ty::PolyTraitRef<'tcx>,
438439
ty::error::TypeError<'tcx>),
439440
TraitNotObjectSafe(DefId),
440-
ConstEvalFailure,
441+
ConstEvalFailure(ErrorHandled),
441442
Overflow,
442443
}
443444

src/librustc/traits/structural_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::SelectionError<'a> {
172172
)
173173
}
174174
super::TraitNotObjectSafe(def_id) => Some(super::TraitNotObjectSafe(def_id)),
175-
super::ConstEvalFailure(ref err) => Some(super::ConstEvalFailure),
175+
super::ConstEvalFailure(err) => Some(super::ConstEvalFailure(err)),
176176
super::Overflow => Some(super::Overflow),
177177
}
178178
}

0 commit comments

Comments
 (0)