]>
git.proxmox.com Git - rustc.git/blob - src/librustc_const_math/err.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 #[derive(Debug, PartialEq, Eq, Clone)]
14 pub enum ConstMathErr
{
16 CmpBetweenUnequalTypes
,
23 ULitOutOfRange(ast
::UintTy
),
24 LitOutOfRange(ast
::IntTy
),
26 pub use self::ConstMathErr
::*;
28 #[derive(Debug, PartialEq, Eq, Clone)]
44 pub fn description(&self) -> &'
static str {
47 NotInRange
=> "inferred value out of range",
48 CmpBetweenUnequalTypes
=> "compared two integrals of different types",
49 UnequalTypes(Add
) => "tried to add two integrals of different types",
50 UnequalTypes(Sub
) => "tried to subtract two integrals of different types",
51 UnequalTypes(Mul
) => "tried to multiply two integrals of different types",
52 UnequalTypes(Div
) => "tried to divide two integrals of different types",
53 UnequalTypes(Rem
) => {
54 "tried to calculate the remainder of two integrals of different types"
56 UnequalTypes(BitAnd
) => "tried to bitand two integrals of different types",
57 UnequalTypes(BitOr
) => "tried to bitor two integrals of different types",
58 UnequalTypes(BitXor
) => "tried to xor two integrals of different types",
59 UnequalTypes(_
) => unreachable
!(),
60 Overflow(Add
) => "attempted to add with overflow",
61 Overflow(Sub
) => "attempted to subtract with overflow",
62 Overflow(Mul
) => "attempted to multiply with overflow",
63 Overflow(Div
) => "attempted to divide with overflow",
64 Overflow(Rem
) => "attempted to calculate the remainder with overflow",
65 Overflow(Neg
) => "attempted to negate with overflow",
66 Overflow(Shr
) => "attempted to shift right with overflow",
67 Overflow(Shl
) => "attempted to shift left with overflow",
68 Overflow(_
) => unreachable
!(),
69 ShiftNegative
=> "attempted to shift by a negative amount",
70 DivisionByZero
=> "attempted to divide by zero",
71 RemainderByZero
=> "attempted to calculate the remainder with a divisor of zero",
72 UnsignedNegation
=> "unary negation of unsigned integer",
73 ULitOutOfRange(ast
::UintTy
::U8
) => "literal out of range for u8",
74 ULitOutOfRange(ast
::UintTy
::U16
) => "literal out of range for u16",
75 ULitOutOfRange(ast
::UintTy
::U32
) => "literal out of range for u32",
76 ULitOutOfRange(ast
::UintTy
::U64
) => "literal out of range for u64",
77 ULitOutOfRange(ast
::UintTy
::Us
) => "literal out of range for usize",
78 LitOutOfRange(ast
::IntTy
::I8
) => "literal out of range for i8",
79 LitOutOfRange(ast
::IntTy
::I16
) => "literal out of range for i16",
80 LitOutOfRange(ast
::IntTy
::I32
) => "literal out of range for i32",
81 LitOutOfRange(ast
::IntTy
::I64
) => "literal out of range for i64",
82 LitOutOfRange(ast
::IntTy
::Is
) => "literal out of range for isize",