mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 17:13:48 +00:00
Handle all types in to_const_range
This commit is contained in:
parent
353945a01b
commit
6f0fd15da9
@ -2,7 +2,7 @@ use rustc::lint::*;
|
||||
use rustc::middle::const_val::ConstVal;
|
||||
use rustc::ty;
|
||||
use rustc_const_eval::ConstContext;
|
||||
use rustc_const_math::{ConstUsize,ConstInt};
|
||||
use rustc_const_math::{ConstUsize,ConstIsize,ConstInt};
|
||||
use rustc::hir;
|
||||
use syntax::ast::RangeLimits;
|
||||
use utils::{self, higher};
|
||||
@ -122,7 +122,24 @@ fn to_const_range(
|
||||
let end = match *end {
|
||||
Some(Some(ConstVal::Integral(x))) => {
|
||||
if limits == RangeLimits::Closed {
|
||||
(x + ConstInt::U8(1)).expect("such a big array is not realistic")
|
||||
match x {
|
||||
ConstInt::U8(_) => (x + ConstInt::U8(1)),
|
||||
ConstInt::U16(_) => (x + ConstInt::U16(1)),
|
||||
ConstInt::U32(_) => (x + ConstInt::U32(1)),
|
||||
ConstInt::U64(_) => (x + ConstInt::U64(1)),
|
||||
ConstInt::U128(_) => (x + ConstInt::U128(1)),
|
||||
ConstInt::Usize(ConstUsize::Us16(_)) => (x + ConstInt::Usize(ConstUsize::Us16(1))),
|
||||
ConstInt::Usize(ConstUsize::Us32(_)) => (x + ConstInt::Usize(ConstUsize::Us32(1))),
|
||||
ConstInt::Usize(ConstUsize::Us64(_)) => (x + ConstInt::Usize(ConstUsize::Us64(1))),
|
||||
ConstInt::I8(_) => (x + ConstInt::I8(1)),
|
||||
ConstInt::I16(_) => (x + ConstInt::I16(1)),
|
||||
ConstInt::I32(_) => (x + ConstInt::I32(1)),
|
||||
ConstInt::I64(_) => (x + ConstInt::I64(1)),
|
||||
ConstInt::I128(_) => (x + ConstInt::I128(1)),
|
||||
ConstInt::Isize(ConstIsize::Is16(_)) => (x + ConstInt::Isize(ConstIsize::Is16(1))),
|
||||
ConstInt::Isize(ConstIsize::Is32(_)) => (x + ConstInt::Isize(ConstIsize::Is32(1))),
|
||||
ConstInt::Isize(ConstIsize::Is64(_)) => (x + ConstInt::Isize(ConstIsize::Is64(1))),
|
||||
}.expect("such a big array is not realistic")
|
||||
} else {
|
||||
x
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user