]> git.lizzy.rs Git - rust.git/commitdiff
Remove unused error variants and const eval types
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Fri, 26 Jan 2018 15:22:26 +0000 (16:22 +0100)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 8 Mar 2018 07:34:12 +0000 (08:34 +0100)
src/librustc/ich/impls_ty.rs
src/librustc/middle/const_val.rs
src/librustc/ty/codec.rs
src/librustc/ty/structural_impls.rs

index 2dfb2d0bffc6cf28bf68edaee1efe2be7768d78e..72bc5af3b7e2d6b9364ea43993e0694db5b2d145 100644 (file)
@@ -353,10 +353,6 @@ fn hash_stable<W: StableHasherResult>(&self,
     }
 }
 
-impl_stable_hash_for!(struct ::middle::const_val::ByteArray<'tcx> {
-    data
-});
-
 impl_stable_hash_for!(enum mir::interpret::Value {
     ByVal(v),
     ByValPair(a, b),
@@ -454,16 +450,7 @@ fn hash_stable<W: StableHasherResult>(&self,
         mem::discriminant(self).hash_stable(hcx, hasher);
 
         match *self {
-            CannotCast |
-            MissingStructField |
             NonConstPath |
-            ExpectedConstTuple |
-            ExpectedConstStruct |
-            IndexedNonVec |
-            IndexNotUsize |
-            MiscBinaryOp |
-            MiscCatchAll |
-            IndexOpFeatureGated |
             TypeckError |
             CheckMatchError => {
                 // nothing to do
@@ -481,9 +468,6 @@ fn hash_stable<W: StableHasherResult>(&self,
             LayoutError(ref layout_error) => {
                 layout_error.hash_stable(hcx, hasher);
             }
-            ErroneousReferencedConstant(ref const_val) => {
-                const_val.hash_stable(hcx, hasher);
-            }
             Miri(ref err) => err.hash_stable(hcx, hasher),
         }
     }
index 5b18b7d5fd918ddc338c3750ece1a9554fe59cc1..c987ed0ea5d3fb8b80f9d485a4b9fa6fd568a589 100644 (file)
@@ -16,7 +16,6 @@
 use errors::DiagnosticBuilder;
 
 use graphviz::IntoCow;
-use serialize;
 use syntax_pos::Span;
 
 use std::borrow::Cow;
@@ -29,13 +28,6 @@ pub enum ConstVal<'tcx> {
     Value(Value),
 }
 
-#[derive(Copy, Clone, Debug, Hash, RustcEncodable, Eq, PartialEq)]
-pub struct ByteArray<'tcx> {
-    pub data: &'tcx [u8],
-}
-
-impl<'tcx> serialize::UseSpecializedDecodable for ByteArray<'tcx> {}
-
 impl<'tcx> ConstVal<'tcx> {
     pub fn to_raw_bits(&self) -> Option<u128> {
         match *self {
@@ -64,26 +56,14 @@ pub struct ConstEvalErr<'tcx> {
 
 #[derive(Clone, Debug)]
 pub enum ErrKind<'tcx> {
-    CannotCast,
-    MissingStructField,
 
     NonConstPath,
     UnimplementedConstVal(&'static str),
-    ExpectedConstTuple,
-    ExpectedConstStruct,
-    IndexedNonVec,
-    IndexNotUsize,
     IndexOutOfBounds { len: u64, index: u64 },
 
-    MiscBinaryOp,
-    MiscCatchAll,
-
-    IndexOpFeatureGated,
     Math(ConstMathErr),
     LayoutError(layout::LayoutError<'tcx>),
 
-    ErroneousReferencedConstant(Box<ConstEvalErr<'tcx>>),
-
     TypeckError,
     CheckMatchError,
     Miri(::mir::interpret::EvalError<'tcx>),
@@ -131,28 +111,17 @@ macro_rules! simple {
         }
 
         match self.kind {
-            CannotCast => simple!("can't cast this type"),
-            MissingStructField  => simple!("nonexistent struct field"),
             NonConstPath        => simple!("non-constant path in constant expression"),
             UnimplementedConstVal(what) =>
                 simple!("unimplemented constant expression: {}", what),
-            ExpectedConstTuple => simple!("expected constant tuple"),
-            ExpectedConstStruct => simple!("expected constant struct"),
-            IndexedNonVec => simple!("indexing is only supported for arrays"),
-            IndexNotUsize => simple!("indices must be of type `usize`"),
             IndexOutOfBounds { len, index } => {
                 simple!("index out of bounds: the len is {} but the index is {}",
                         len, index)
             }
 
-            MiscBinaryOp => simple!("bad operands for binary"),
-            MiscCatchAll => simple!("unsupported constant expr"),
-            IndexOpFeatureGated => simple!("the index operation on const values is unstable"),
             Math(ref err) => Simple(err.description().into_cow()),
             LayoutError(ref err) => Simple(err.to_string().into_cow()),
 
-            ErroneousReferencedConstant(_) => simple!("could not evaluate referenced constant"),
-
             TypeckError => simple!("type-checking failed"),
             CheckMatchError => simple!("match-checking failed"),
             // FIXME: report a full backtrace
@@ -166,15 +135,8 @@ pub fn struct_error(&self,
         primary_kind: &str)
         -> DiagnosticBuilder<'gcx>
     {
-        let mut err = self;
-        while let &ConstEvalErr {
-            kind: ErrKind::ErroneousReferencedConstant(box ref i_err), ..
-        } = err {
-            err = i_err;
-        }
-
-        let mut diag = struct_error(tcx, err.span, "constant evaluation error");
-        err.note(tcx, primary_span, primary_kind, &mut diag);
+        let mut diag = struct_error(tcx, self.span, "constant evaluation error");
+        self.note(tcx, primary_span, primary_kind, &mut diag);
         diag
     }
 
index fbb14f39ade34d939edfe82c7af64ca7b4b7365e..f98bc953560988f2290b1443c2ef4318b1f39fed 100644 (file)
@@ -17,7 +17,6 @@
 // persisting to incr. comp. caches.
 
 use hir::def_id::{DefId, CrateNum};
-use middle::const_val::ByteArray;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque};
 use std::hash::Hash;
@@ -240,17 +239,6 @@ pub fn decode_existential_predicate_slice<'a, 'tcx, D>(decoder: &mut D)
               .mk_existential_predicates((0..len).map(|_| Decodable::decode(decoder)))?)
 }
 
-#[inline]
-pub fn decode_byte_array<'a, 'tcx, D>(decoder: &mut D)
-                                      -> Result<ByteArray<'tcx>, D::Error>
-    where D: TyDecoder<'a, 'tcx>,
-          'tcx: 'a,
-{
-    Ok(ByteArray {
-        data: decoder.tcx().alloc_byte_array(&Vec::decode(decoder)?)
-    })
-}
-
 #[inline]
 pub fn decode_const<'a, 'tcx, D>(decoder: &mut D)
                                  -> Result<&'tcx ty::Const<'tcx>, D::Error>
@@ -278,7 +266,6 @@ mod __ty_decoder_impl {
             use $crate::ty::codec::*;
             use $crate::ty::subst::Substs;
             use $crate::hir::def_id::{CrateNum};
-            use $crate::middle::const_val::ByteArray;
             use rustc_serialize::{Decoder, SpecializedDecoder};
             use std::borrow::Cow;
 
@@ -377,13 +364,6 @@ fn specialized_decode(&mut self)
                 }
             }
 
-            impl<$($typaram),*> SpecializedDecoder<ByteArray<'tcx>>
-            for $DecoderName<$($typaram),*> {
-                fn specialized_decode(&mut self) -> Result<ByteArray<'tcx>, Self::Error> {
-                    decode_byte_array(self)
-                }
-            }
-
             impl<$($typaram),*> SpecializedDecoder<&'tcx $crate::ty::Const<'tcx>>
             for $DecoderName<$($typaram),*> {
                 fn specialized_decode(&mut self) -> Result<&'tcx ty::Const<'tcx>, Self::Error> {
index 9394a853920e516d2efaf82df09e0be39c18f995..4e1f3664d7f85355a6593c9c76be251ba76b1633 100644 (file)
@@ -703,26 +703,14 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
         use middle::const_val::ErrKind::*;
 
         Some(match *self {
-            CannotCast => CannotCast,
-            MissingStructField => MissingStructField,
             NonConstPath => NonConstPath,
             UnimplementedConstVal(s) => UnimplementedConstVal(s),
-            ExpectedConstTuple => ExpectedConstTuple,
-            ExpectedConstStruct => ExpectedConstStruct,
-            IndexedNonVec => IndexedNonVec,
-            IndexNotUsize => IndexNotUsize,
             IndexOutOfBounds { len, index } => IndexOutOfBounds { len, index },
-            MiscBinaryOp => MiscBinaryOp,
-            MiscCatchAll => MiscCatchAll,
-            IndexOpFeatureGated => IndexOpFeatureGated,
             Math(ref e) => Math(e.clone()),
 
             LayoutError(ref e) => {
                 return tcx.lift(e).map(LayoutError)
             }
-            ErroneousReferencedConstant(ref e) => {
-                return tcx.lift(e).map(ErroneousReferencedConstant)
-            }
 
             TypeckError => TypeckError,
             CheckMatchError => CheckMatchError,