]> git.lizzy.rs Git - rust.git/commitdiff
rustc: remove obsolete const_val::ErrKind::{Negate,Not}On.
authorEduard-Mihai Burtescu <edy.burt@gmail.com>
Tue, 15 Aug 2017 15:35:31 +0000 (18:35 +0300)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Mon, 11 Sep 2017 05:41:15 +0000 (08:41 +0300)
src/librustc/middle/const_val.rs
src/librustc_const_eval/diagnostics.rs
src/librustc_const_eval/eval.rs

index 05e4f0da001cf7406a2cae8b5569e3914feee89a..469aed7e8ce68c13a9f294ad4f99e34fe87707fc 100644 (file)
@@ -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 @@ fn decode<D: Decoder>(_: &mut D) -> Result<Self, D::Error> {
 }
 
 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 @@ macro_rules! simple {
 
         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) =>
index 56d08184a0f17b10f1c317d93198a98f28ed32a8..d01b3c45f7fd1642603e3402008addf6085d6c5f 100644 (file)
@@ -565,7 +565,7 @@ pub enum Method { GET, POST }
 
 
 register_diagnostics! {
-    E0298, // cannot compare constants
+//  E0298, // cannot compare constants
 //  E0299, // mismatched types between arms
 //  E0471, // constant evaluation error (in pattern)
 }
index 1e3d11812816345e7215916db758cc104eca83ed..1ad00a9e7b34ea3e77aa7792b3f208c0469789e3 100644 (file)
@@ -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)
         }
     }