@@ -63,7 +63,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
63
63
}
64
64
65
65
PatternKind :: Range ( range) => {
66
- assert ! ( range. ty == match_pair. pattern. ty) ;
66
+ assert_eq ! ( range. lo. ty, match_pair. pattern. ty) ;
67
+ assert_eq ! ( range. hi. ty, match_pair. pattern. ty) ;
67
68
Test {
68
69
span : match_pair. pattern . span ,
69
70
kind : TestKind :: Range ( range) ,
@@ -270,22 +271,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
270
271
) ;
271
272
} else {
272
273
if let [ success, fail] = * make_target_blocks ( self ) {
274
+ assert_eq ! ( value. ty, ty) ;
275
+ let expect = self . literal_operand ( test. span , value) ;
273
276
let val = Operand :: Copy ( place. clone ( ) ) ;
274
- let expect = self . literal_operand ( test. span , ty, value) ;
275
277
self . compare ( block, success, fail, source_info, BinOp :: Eq , expect, val) ;
276
278
} else {
277
279
bug ! ( "`TestKind::Eq` should have two target blocks" ) ;
278
280
}
279
281
}
280
282
}
281
283
282
- TestKind :: Range ( PatternRange { ref lo, ref hi, ty , ref end } ) => {
284
+ TestKind :: Range ( PatternRange { ref lo, ref hi, ref end } ) => {
283
285
let lower_bound_success = self . cfg . start_new_block ( ) ;
284
286
let target_blocks = make_target_blocks ( self ) ;
285
287
286
288
// Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
287
- let lo = self . literal_operand ( test. span , ty , lo) ;
288
- let hi = self . literal_operand ( test. span , ty , hi) ;
289
+ let lo = self . literal_operand ( test. span , lo) ;
290
+ let hi = self . literal_operand ( test. span , hi) ;
289
291
let val = Operand :: Copy ( place. clone ( ) ) ;
290
292
291
293
if let [ success, fail] = * target_blocks {
@@ -387,7 +389,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
387
389
) {
388
390
use rustc:: middle:: lang_items:: EqTraitLangItem ;
389
391
390
- let mut expect = self . literal_operand ( source_info. span , value. ty , value ) ;
392
+ let mut expect = self . literal_operand ( source_info. span , value) ;
391
393
let mut val = Operand :: Copy ( place. clone ( ) ) ;
392
394
393
395
// If we're using `b"..."` as a pattern, we need to insert an
@@ -440,7 +442,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
440
442
} ;
441
443
442
444
let eq_def_id = self . hir . tcx ( ) . require_lang_item ( EqTraitLangItem ) ;
443
- let ( mty , method) = self . hir . trait_method ( eq_def_id, sym:: eq, deref_ty, & [ deref_ty. into ( ) ] ) ;
445
+ let method = self . hir . trait_method ( eq_def_id, sym:: eq, deref_ty, & [ deref_ty. into ( ) ] ) ;
444
446
445
447
let bool_ty = self . hir . bool_ty ( ) ;
446
448
let eq_result = self . temp ( bool_ty, source_info. span ) ;
@@ -449,7 +451,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
449
451
self . cfg . terminate ( block, source_info, TerminatorKind :: Call {
450
452
func : Operand :: Constant ( box Constant {
451
453
span : source_info. span ,
452
- ty : mty,
453
454
454
455
// FIXME(#54571): This constant comes from user input (a
455
456
// constant in a pattern). Are there forms where users can add
@@ -656,8 +657,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
656
657
657
658
let tcx = self . hir . tcx ( ) ;
658
659
659
- let lo = compare_const_vals ( tcx, test. lo , pat. hi , self . hir . param_env , test. ty ) ?;
660
- let hi = compare_const_vals ( tcx, test. hi , pat. lo , self . hir . param_env , test. ty ) ?;
660
+ let test_ty = test. lo . ty ;
661
+ let lo = compare_const_vals ( tcx, test. lo , pat. hi , self . hir . param_env , test_ty) ?;
662
+ let hi = compare_const_vals ( tcx, test. hi , pat. lo , self . hir . param_env , test_ty) ?;
661
663
662
664
match ( test. end , pat. end , lo, hi) {
663
665
// pat < test
@@ -774,8 +776,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
774
776
775
777
let tcx = self . hir . tcx ( ) ;
776
778
777
- let a = compare_const_vals ( tcx, range. lo , value, self . hir . param_env , range. ty ) ?;
778
- let b = compare_const_vals ( tcx, value, range. hi , self . hir . param_env , range. ty ) ?;
779
+ let a = compare_const_vals ( tcx, range. lo , value, self . hir . param_env , range. lo . ty ) ?;
780
+ let b = compare_const_vals ( tcx, value, range. hi , self . hir . param_env , range. lo . ty ) ?;
779
781
780
782
match ( b, range. end ) {
781
783
( Less , _) |
0 commit comments