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