about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/middle/const_val.rs24
-rw-r--r--src/librustc_const_eval/diagnostics.rs2
-rw-r--r--src/librustc_const_eval/eval.rs10
3 files changed, 5 insertions, 31 deletions
diff --git a/src/librustc/middle/const_val.rs b/src/librustc/middle/const_val.rs
index 05e4f0da001..469aed7e8ce 100644
--- a/src/librustc/middle/const_val.rs
+++ b/src/librustc/middle/const_val.rs
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use self::ConstVal::*;
-use self::ConstAggregate::*;
 pub use rustc_const_math::ConstInt;
 
 use hir;
@@ -73,23 +71,6 @@ impl<'tcx> Decodable for ConstAggregate<'tcx> {
 }
 
 impl<'tcx> ConstVal<'tcx> {
-    pub fn description(&self) -> &'static str {
-        match *self {
-            Float(f) => f.description(),
-            Integral(i) => i.description(),
-            Str(_) => "string literal",
-            ByteStr(_) => "byte string literal",
-            Bool(_) => "boolean",
-            Char(..) => "char",
-            Variant(_) => "enum variant",
-            Aggregate(Struct(_)) => "struct",
-            Aggregate(Tuple(_)) => "tuple",
-            Function(..) => "function definition",
-            Aggregate(Array(..)) => "array",
-            Aggregate(Repeat(..)) => "repeat",
-        }
-    }
-
     pub fn to_const_int(&self) -> Option<ConstInt> {
         match *self {
             ConstVal::Integral(i) => Some(i),
@@ -110,8 +91,6 @@ pub struct ConstEvalErr<'tcx> {
 pub enum ErrKind<'tcx> {
     CannotCast,
     MissingStructField,
-    NegateOn(ConstVal<'tcx>),
-    NotOn(ConstVal<'tcx>),
 
     NonConstPath,
     UnimplementedConstVal(&'static str),
@@ -170,9 +149,6 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
 
         match self.kind {
             CannotCast => simple!("can't cast this type"),
-            NegateOn(ref const_val) => simple!("negate on {}", const_val.description()),
-            NotOn(ref const_val) => simple!("not on {}", const_val.description()),
-
             MissingStructField  => simple!("nonexistent struct field"),
             NonConstPath        => simple!("non-constant path in constant expression"),
             UnimplementedConstVal(what) =>
diff --git a/src/librustc_const_eval/diagnostics.rs b/src/librustc_const_eval/diagnostics.rs
index 56d08184a0f..d01b3c45f7f 100644
--- a/src/librustc_const_eval/diagnostics.rs
+++ b/src/librustc_const_eval/diagnostics.rs
@@ -565,7 +565,7 @@ See also https://github.com/rust-lang/rust/issues/14587
 
 
 register_diagnostics! {
-    E0298, // cannot compare constants
+//  E0298, // cannot compare constants
 //  E0299, // mismatched types between arms
 //  E0471, // constant evaluation error (in pattern)
 }
diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs
index 1e3d1181281..1ad00a9e7b3 100644
--- a/src/librustc_const_eval/eval.rs
+++ b/src/librustc_const_eval/eval.rs
@@ -186,14 +186,14 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
         mk_const(match cx.eval(inner)?.val {
           Float(f) => Float(-f),
           Integral(i) => Integral(math!(e, -i)),
-          const_val => signal!(e, NegateOn(const_val)),
+          _ => signal!(e, TypeckError)
         })
       }
       hir::ExprUnary(hir::UnNot, ref inner) => {
         mk_const(match cx.eval(inner)?.val {
           Integral(i) => Integral(math!(e, !i)),
           Bool(b) => Bool(!b),
-          const_val => signal!(e, NotOn(const_val)),
+          _ => signal!(e, TypeckError)
         })
       }
       hir::ExprUnary(hir::UnDeref, _) => signal!(e, UnimplementedConstVal("deref operation")),
@@ -734,10 +734,8 @@ pub fn compare_const_vals(tcx: TyCtxt, span: Span, a: &ConstVal, b: &ConstVal)
         Some(result) => Ok(result),
         None => {
             // FIXME: can this ever be reached?
-            span_err!(tcx.sess, span, E0298,
-                      "type mismatch comparing {} and {}",
-                      a.description(),
-                      b.description());
+            tcx.sess.delay_span_bug(span,
+                &format!("type mismatch comparing {:?} and {:?}", a, b));
             Err(ErrorReported)
         }
     }