@@ -17,6 +17,7 @@ use super::{
1717 ObligationCauseCode ,
1818 OutputTypeParameterMismatch ,
1919 TraitNotObjectSafe ,
20+ ConstEvalFailure ,
2021 PredicateObligation ,
2122 Reveal ,
2223 SelectionContext ,
@@ -30,6 +31,7 @@ use hir;
3031use hir:: def_id:: DefId ;
3132use infer:: { self , InferCtxt } ;
3233use infer:: type_variable:: TypeVariableOrigin ;
34+ use middle:: const_val;
3335use rustc:: lint:: builtin:: EXTRA_REQUIREMENT_IN_IMPL ;
3436use std:: fmt;
3537use syntax:: ast;
@@ -712,6 +714,14 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
712714 // (which may fail).
713715 span_bug ! ( span, "WF predicate not satisfied for {:?}" , ty) ;
714716 }
717+
718+ ty:: Predicate :: ConstEvaluatable ( ..) => {
719+ // Errors for `ConstEvaluatable` predicates show up as
720+ // `SelectionError::ConstEvalFailure`,
721+ // not `Unimplemented`.
722+ span_bug ! ( span,
723+ "const-evaluatable requirement gave wrong error: `{:?}`" , obligation)
724+ }
715725 }
716726 }
717727
@@ -776,6 +786,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
776786 self . tcx . report_object_safety_error ( span, did,
777787 violations)
778788 }
789+
790+ ConstEvalFailure ( ref err) => {
791+ if let const_val:: ErrKind :: TypeckError = err. kind {
792+ return ;
793+ }
794+ err. struct_error ( self . tcx , span, "constant expression" )
795+ }
779796 } ;
780797 self . note_obligation_cause ( & mut err, obligation) ;
781798 err. emit ( ) ;
0 commit comments