Skip to content

Commit 9107ec1

Browse files
committed
rustc_mir: add sanity asserts for the types of ty::Consts.
1 parent b565ece commit 9107ec1

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/librustc_mir/build/expr/as_constant.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
3838
inferred_ty: ty,
3939
})
4040
});
41+
assert_eq!(literal.ty, ty);
4142
Constant {
4243
span,
4344
user_ty,

src/librustc_mir/build/matches/test.rs

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6363
}
6464

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

src/librustc_mir/hair/pattern/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,8 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
441441

442442
let mut kind = match (lo, hi) {
443443
(PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => {
444+
assert_eq!(lo.ty, ty);
445+
assert_eq!(hi.ty, ty);
444446
let cmp = compare_const_vals(
445447
self.tcx,
446448
lo,

0 commit comments

Comments
 (0)