use rustc::ty::cast::{CastKind};
use rustc_const_eval::{ConstEvalErr, lookup_const_fn_by_id, compare_lit_exprs};
use rustc_const_eval::{eval_const_expr_partial, lookup_const_by_id};
-use rustc_const_eval::ErrKind::{IndexOpFeatureGated, UnimplementedConstVal, MiscCatchAll};
use rustc_const_eval::ErrKind::{ErroneousReferencedConstant, MiscBinaryOp};
+use rustc_const_eval::ErrKind::{IndexOpFeatureGated, UnimplementedConstVal, MiscCatchAll, Math};
use rustc_const_eval::EvalHint::ExprTypeChecked;
+use rustc_const_math::{ConstMathErr, Op};
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::middle::expr_use_visitor as euv;
Err(ConstEvalErr { kind: MiscCatchAll, ..}) |
Err(ConstEvalErr { kind: MiscBinaryOp, ..}) |
Err(ConstEvalErr { kind: ErroneousReferencedConstant(_), ..}) |
+ Err(ConstEvalErr { kind: Math(ConstMathErr::Overflow(Op::Shr)), ..}) |
+ Err(ConstEvalErr { kind: Math(ConstMathErr::Overflow(Op::Shl)), ..}) |
Err(ConstEvalErr { kind: IndexOpFeatureGated, ..}) => {},
Err(msg) => {
self.qualif = self.qualif | ConstQualif::NOT_CONST;
fn main() {
let n = 1u8 << 7;
let n = 1u8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1u16 << 15;
let n = 1u16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1u32 << 31;
let n = 1u32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1u64 << 63;
let n = 1u64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1i8 << 7;
let n = 1i8 << 8; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1i16 << 15;
let n = 1i16 << 16; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1i32 << 31;
let n = 1i32 << 32; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1i64 << 63;
let n = 1i64 << 64; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1u8 >> 7;
let n = 1u8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1u16 >> 15;
let n = 1u16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1u32 >> 31;
let n = 1u32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1u64 >> 63;
let n = 1u64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1i8 >> 7;
let n = 1i8 >> 8; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1i16 >> 15;
let n = 1i16 >> 16; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1i32 >> 31;
let n = 1i32 >> 32; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1i64 >> 63;
let n = 1i64 >> 64; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
let n = 1u8;
let n = n << 7;
let n = 1u8 << (4+3);
let n = 1u8 << (4+4); //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
#[cfg(target_pointer_width = "32")]
const BITS: usize = 32;
const BITS: usize = 64;
let n = 1_isize << BITS; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1_usize << BITS; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift left with overflow
let n = 1i8<<(1isize+-1);
let n = 1i64 >> [63][0];
let n = 1i64 >> [64][0]; //~ ERROR: bitshift exceeds the type's number of bits
- //~^ WARN: attempted to shift right with overflow
}