rustc: remove obsolete const_val::ErrKind::{Negate,Not}On.
This commit is contained in:
parent
8a9b78f5cc
commit
88217618ec
@ -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) =>
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user