Skip to content

Commit 671b2a5

Browse files
committed
Remove the rustc_const_math crate
1 parent cf103e5 commit 671b2a5

File tree

17 files changed

+60
-132
lines changed

17 files changed

+60
-132
lines changed

src/librustc/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ log = { version = "0.4", features = ["release_max_level_info", "std"] }
1919
proc_macro = { path = "../libproc_macro" }
2020
rustc_apfloat = { path = "../librustc_apfloat" }
2121
rustc_target = { path = "../librustc_target" }
22-
rustc_const_math = { path = "../librustc_const_math" }
2322
rustc_data_structures = { path = "../librustc_data_structures" }
2423
rustc_errors = { path = "../librustc_errors" }
2524
serialize = { path = "../libserialize" }

src/librustc/ich/impls_const_math.rs

-29
This file was deleted.

src/librustc/ich/impls_ty.rs

+17
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,23 @@ for ::mir::interpret::EvalError<'gcx> {
669669
}
670670
}
671671

672+
impl_stable_hash_for!(enum mir::interpret::ConstMathErr {
673+
Overflow(op),
674+
DivisionByZero,
675+
RemainderByZero,
676+
});
677+
678+
impl_stable_hash_for!(enum mir::interpret::Op {
679+
Add,
680+
Sub,
681+
Mul,
682+
Div,
683+
Rem,
684+
Shr,
685+
Shl,
686+
Neg,
687+
});
688+
672689
impl_stable_hash_for!(enum mir::interpret::Lock {
673690
NoLock,
674691
WriteLock(dl),

src/librustc/ich/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ mod fingerprint;
1818
mod caching_codemap_view;
1919
mod hcx;
2020

21-
mod impls_const_math;
2221
mod impls_cstore;
2322
mod impls_hir;
2423
mod impls_mir;

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ extern crate libc;
8585
extern crate rustc_target;
8686
#[macro_use] extern crate rustc_data_structures;
8787
extern crate serialize;
88-
extern crate rustc_const_math;
8988
extern crate rustc_errors as errors;
9089
#[macro_use] extern crate log;
9190
#[macro_use] extern crate syntax;

src/librustc/mir/interpret/error.rs

+38-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use super::{
88
MemoryPointer, Lock, AccessKind
99
};
1010

11-
use rustc_const_math::ConstMathErr;
1211
use syntax::codemap::Span;
1312
use backtrace::Backtrace;
1413

@@ -304,3 +303,41 @@ impl<'tcx> fmt::Display for EvalError<'tcx> {
304303
}
305304
}
306305
}
306+
307+
#[derive(Debug, PartialEq, Eq, Clone, RustcEncodable, RustcDecodable)]
308+
pub enum ConstMathErr {
309+
Overflow(Op),
310+
DivisionByZero,
311+
RemainderByZero,
312+
}
313+
pub use self::ConstMathErr::*;
314+
315+
#[derive(Debug, PartialEq, Eq, Clone, RustcEncodable, RustcDecodable)]
316+
pub enum Op {
317+
Add,
318+
Sub,
319+
Mul,
320+
Div,
321+
Rem,
322+
Shr,
323+
Shl,
324+
Neg,
325+
}
326+
327+
impl ConstMathErr {
328+
pub fn description(&self) -> &'static str {
329+
use self::Op::*;
330+
match *self {
331+
Overflow(Add) => "attempt to add with overflow",
332+
Overflow(Sub) => "attempt to subtract with overflow",
333+
Overflow(Mul) => "attempt to multiply with overflow",
334+
Overflow(Div) => "attempt to divide with overflow",
335+
Overflow(Rem) => "attempt to calculate the remainder with overflow",
336+
Overflow(Neg) => "attempt to negate with overflow",
337+
Overflow(Shr) => "attempt to shift right with overflow",
338+
Overflow(Shl) => "attempt to shift left with overflow",
339+
DivisionByZero => "attempt to divide by zero",
340+
RemainderByZero => "attempt to calculate the remainder with a divisor of zero",
341+
}
342+
}
343+
}

src/librustc/mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ macro_rules! err {
88
mod error;
99
mod value;
1010

11-
pub use self::error::{EvalError, EvalResult, EvalErrorKind};
11+
pub use self::error::{EvalError, EvalResult, EvalErrorKind, Op, ConstMathErr};
1212

1313
pub use self::value::{PrimVal, PrimValKind, Value, Pointer};
1414

src/librustc/mir/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use graphviz::IntoCow;
1616
use middle::const_val::ConstVal;
1717
use middle::region;
18-
use rustc_const_math::ConstMathErr;
1918
use rustc_data_structures::sync::{Lrc};
2019
use rustc_data_structures::indexed_vec::{IndexVec, Idx};
2120
use rustc_data_structures::control_flow_graph::dominators::{Dominators, dominators};
@@ -26,7 +25,7 @@ use rustc_serialize as serialize;
2625
use hir::def::CtorKind;
2726
use hir::def_id::DefId;
2827
use mir::visit::MirVisitable;
29-
use mir::interpret::{Value, PrimVal};
28+
use mir::interpret::{Value, PrimVal, ConstMathErr};
3029
use ty::subst::{Subst, Substs};
3130
use ty::{self, AdtDef, CanonicalTy, ClosureSubsts, Region, Ty, TyCtxt, GeneratorInterior};
3231
use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};

src/librustc_const_math/Cargo.toml

-14
This file was deleted.

src/librustc_const_math/err.rs

-47
This file was deleted.

src/librustc_const_math/lib.rs

-26
This file was deleted.

src/librustc_mir/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ log = "0.4"
1616
log_settings = "0.1.1"
1717
rustc = { path = "../librustc" }
1818
rustc_target = { path = "../librustc_target" }
19-
rustc_const_math = { path = "../librustc_const_math" }
2019
rustc_data_structures = { path = "../librustc_data_structures" }
2120
rustc_errors = { path = "../librustc_errors" }
2221
serialize = { path = "../libserialize" }

src/librustc_mir/build/expr/as_rvalue.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
//! See docs in build/expr/mod.rs
1212
13-
use rustc_const_math::{ConstMathErr, Op};
1413
use rustc_data_structures::fx::FxHashMap;
1514
use rustc_data_structures::indexed_vec::Idx;
1615

@@ -21,7 +20,7 @@ use rustc::middle::const_val::ConstVal;
2120
use rustc::middle::region;
2221
use rustc::ty::{self, Ty};
2322
use rustc::mir::*;
24-
use rustc::mir::interpret::{Value, PrimVal};
23+
use rustc::mir::interpret::{Value, PrimVal, ConstMathErr, Op};
2524
use syntax_pos::Span;
2625

2726
impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {

src/librustc_mir/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ extern crate rustc_errors;
5050
extern crate syntax;
5151
extern crate syntax_pos;
5252
extern crate rustc_target;
53-
extern crate rustc_const_math;
54-
extern crate core; // for NonZero
5553
extern crate log_settings;
5654
extern crate rustc_apfloat;
5755
extern crate byteorder;

src/librustc_trans/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ rustc-demangle = "0.1.4"
2121
rustc_allocator = { path = "../librustc_allocator" }
2222
rustc_apfloat = { path = "../librustc_apfloat" }
2323
rustc_target = { path = "../librustc_target" }
24-
rustc_const_math = { path = "../librustc_const_math" }
2524
rustc_data_structures = { path = "../librustc_data_structures" }
2625
rustc_errors = { path = "../librustc_errors" }
2726
rustc_incremental = { path = "../librustc_incremental" }

src/librustc_trans/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ extern crate rustc_mir;
4343
extern crate rustc_allocator;
4444
extern crate rustc_apfloat;
4545
extern crate rustc_target;
46-
extern crate rustc_const_math;
4746
#[macro_use] extern crate rustc_data_structures;
4847
extern crate rustc_demangle;
4948
extern crate rustc_incremental;

src/librustc_trans/mir/block.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> {
311311
// checked operation, just a comparison with the minimum
312312
// value, so we have to check for the assert message.
313313
if !bx.cx.check_overflow {
314-
use rustc_const_math::ConstMathErr::Overflow;
315-
use rustc_const_math::Op::Neg;
314+
use rustc::mir::interpret::ConstMathErr::Overflow;
315+
use rustc::mir::interpret::Op::Neg;
316316

317317
if let mir::AssertMessage::Math(Overflow(Neg)) = *msg {
318318
const_cond = Some(expected);

0 commit comments

Comments
 (0)