Skip to content

Commit 99f0df0

Browse files
committed
rustc: remove obsolete const_val::ErrKind::{Negate,Not}On.
1 parent a62d6fb commit 99f0df0

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

src/librustc/middle/const_val.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use self::ConstVal::*;
12-
use self::ConstAggregate::*;
1311
pub use rustc_const_math::ConstInt;
1412

1513
use hir;
@@ -73,23 +71,6 @@ impl<'tcx> Decodable for ConstAggregate<'tcx> {
7371
}
7472

7573
impl<'tcx> ConstVal<'tcx> {
76-
pub fn description(&self) -> &'static str {
77-
match *self {
78-
Float(f) => f.description(),
79-
Integral(i) => i.description(),
80-
Str(_) => "string literal",
81-
ByteStr(_) => "byte string literal",
82-
Bool(_) => "boolean",
83-
Char(..) => "char",
84-
Variant(_) => "enum variant",
85-
Aggregate(Struct(_)) => "struct",
86-
Aggregate(Tuple(_)) => "tuple",
87-
Function(..) => "function definition",
88-
Aggregate(Array(..)) => "array",
89-
Aggregate(Repeat(..)) => "repeat",
90-
}
91-
}
92-
9374
pub fn to_const_int(&self) -> Option<ConstInt> {
9475
match *self {
9576
ConstVal::Integral(i) => Some(i),
@@ -110,8 +91,6 @@ pub struct ConstEvalErr<'tcx> {
11091
pub enum ErrKind<'tcx> {
11192
CannotCast,
11293
MissingStructField,
113-
NegateOn(ConstVal<'tcx>),
114-
NotOn(ConstVal<'tcx>),
11594

11695
NonConstPath,
11796
UnimplementedConstVal(&'static str),
@@ -170,9 +149,6 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> {
170149

171150
match self.kind {
172151
CannotCast => simple!("can't cast this type"),
173-
NegateOn(ref const_val) => simple!("negate on {}", const_val.description()),
174-
NotOn(ref const_val) => simple!("not on {}", const_val.description()),
175-
176152
MissingStructField => simple!("nonexistent struct field"),
177153
NonConstPath => simple!("non-constant path in constant expression"),
178154
UnimplementedConstVal(what) =>

src/librustc_const_eval/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ See also https://github.com/rust-lang/rust/issues/14587
565565

566566

567567
register_diagnostics! {
568-
E0298, // cannot compare constants
568+
// E0298, // cannot compare constants
569569
// E0299, // mismatched types between arms
570570
// E0471, // constant evaluation error (in pattern)
571571
}

src/librustc_const_eval/eval.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>,
186186
mk_const(match cx.eval(inner)?.val {
187187
Float(f) => Float(-f),
188188
Integral(i) => Integral(math!(e, -i)),
189-
const_val => signal!(e, NegateOn(const_val)),
189+
_ => signal!(e, TypeckError)
190190
})
191191
}
192192
hir::ExprUnary(hir::UnNot, ref inner) => {
193193
mk_const(match cx.eval(inner)?.val {
194194
Integral(i) => Integral(math!(e, !i)),
195195
Bool(b) => Bool(!b),
196-
const_val => signal!(e, NotOn(const_val)),
196+
_ => signal!(e, TypeckError)
197197
})
198198
}
199199
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)
734734
Some(result) => Ok(result),
735735
None => {
736736
// FIXME: can this ever be reached?
737-
span_err!(tcx.sess, span, E0298,
738-
"type mismatch comparing {} and {}",
739-
a.description(),
740-
b.description());
737+
tcx.sess.delay_span_bug(span,
738+
&format!("type mismatch comparing {:?} and {:?}", a, b));
741739
Err(ErrorReported)
742740
}
743741
}

0 commit comments

Comments
 (0)