rustc_mir: add sanity asserts for the types of ty::Consts.

This commit is contained in:
Eduard-Mihai Burtescu 2019-08-12 18:15:45 +03:00
parent b565ece5d8
commit 9107ec1acd
3 changed files with 6 additions and 0 deletions

View file

@ -38,6 +38,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
inferred_ty: ty,
})
});
assert_eq!(literal.ty, ty);
Constant {
span,
user_ty,

View file

@ -63,6 +63,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
PatternKind::Range(range) => {
assert_eq!(range.lo.ty, match_pair.pattern.ty);
assert_eq!(range.hi.ty, match_pair.pattern.ty);
Test {
span: match_pair.pattern.span,
kind: TestKind::Range(range),
@ -269,6 +271,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
);
} else {
if let [success, fail] = *make_target_blocks(self) {
assert_eq!(value.ty, ty);
let expect = self.literal_operand(test.span, value);
let val = Operand::Copy(place.clone());
self.compare(block, success, fail, source_info, BinOp::Eq, expect, val);

View file

@ -441,6 +441,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
let mut kind = match (lo, hi) {
(PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => {
assert_eq!(lo.ty, ty);
assert_eq!(hi.ty, ty);
let cmp = compare_const_vals(
self.tcx,
lo,