@@ -10,7 +10,6 @@ use std::cmp::Ordering;
10
10
use rustc_data_structures:: fx:: FxIndexMap ;
11
11
use rustc_hir:: { LangItem , RangeEnd } ;
12
12
use rustc_middle:: mir:: * ;
13
- use rustc_middle:: ty:: adjustment:: PointerCoercion ;
14
13
use rustc_middle:: ty:: util:: IntTypeExt ;
15
14
use rustc_middle:: ty:: { self , GenericArg , Ty , TyCtxt } ;
16
15
use rustc_middle:: { bug, span_bug} ;
@@ -375,14 +374,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
375
374
mut val : Place < ' tcx > ,
376
375
mut ty : Ty < ' tcx > ,
377
376
) {
378
- //let mut expect_op = self.literal_operand(source_info.span, value);
379
- //let expect = self.temp(value, source_info.span);
380
- //self.cfg.push_assign(
381
- // block,
382
- // source_info,
383
- // expect,
384
- // Rvalue::Use(expect_op),
385
- //);
377
+ let expect_ty = value. ty ( ) ;
378
+ let expect_op = self . literal_operand ( source_info. span , value) ;
379
+ let mut expect = self . temp ( value. ty ( ) , source_info. span ) ;
380
+ self . cfg . push_assign (
381
+ block,
382
+ source_info,
383
+ expect,
384
+ Rvalue :: Use ( expect_op) ,
385
+ ) ;
386
386
387
387
match ty. kind ( ) {
388
388
ty:: Ref ( _, inner_ty, _) if inner_ty. is_slice ( ) => {
@@ -435,6 +435,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
435
435
temp,
436
436
Rvalue :: Use ( Operand :: Copy ( val) ) ,
437
437
) ;
438
+ tracing:: warn!( "from {:?} to {:?}" , val, temp) ;
438
439
val = temp;
439
440
}
440
441
_=> break ,
@@ -445,65 +446,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
445
446
} ;
446
447
447
448
( ty, val) = normalize_depth ( ty, val) ;
448
-
449
- // If we're using `b"..."` as a pattern, we need to insert an
450
- // unsizing coercion, as the byte string has the type `&[u8; N]`.
451
- //
452
- // We want to do this even when the scrutinee is a reference to an
453
- // array, so we can call `<[u8]>::eq` rather than having to find an
454
- // `<[u8; N]>::eq`.
455
- let unsize = |ty : Ty < ' tcx > | match ty. kind ( ) {
456
- ty:: Ref ( region, rty, _) => match rty. kind ( ) {
457
- ty:: Array ( inner_ty, n) => Some ( ( region, inner_ty, n) ) ,
458
- _ => None ,
459
- } ,
460
- _ => None ,
461
- } ;
462
- let opt_ref_ty = unsize ( ty) ;
463
- let opt_ref_test_ty = unsize ( value. ty ( ) ) ;
464
- match ( opt_ref_ty, opt_ref_test_ty) {
465
- // nothing to do, neither is an array
466
- ( None , None ) => { }
467
- ( Some ( ( region, elem_ty, _) ) , _) | ( None , Some ( ( region, elem_ty, _) ) ) => {
468
- let tcx = self . tcx ;
469
- // make both a slice
470
- ty = Ty :: new_imm_ref ( tcx, * region, Ty :: new_slice ( tcx, * elem_ty) ) ;
471
- if opt_ref_ty. is_some ( ) {
472
- let temp = self . temp ( ty, source_info. span ) ;
473
- self . cfg . push_assign (
474
- block,
475
- source_info,
476
- temp,
477
- Rvalue :: Cast (
478
- CastKind :: PointerCoercion (
479
- PointerCoercion :: Unsize ,
480
- CoercionSource :: Implicit ,
481
- ) ,
482
- Operand :: Copy ( val) ,
483
- ty,
484
- ) ,
485
- ) ;
486
- val = temp;
487
- }
488
- if opt_ref_test_ty. is_some ( ) {
489
- let slice = self . temp ( ty, source_info. span ) ;
490
- self . cfg . push_assign (
491
- block,
492
- source_info,
493
- slice,
494
- Rvalue :: Cast (
495
- CastKind :: PointerCoercion (
496
- PointerCoercion :: Unsize ,
497
- CoercionSource :: Implicit ,
498
- ) ,
499
- expect,
500
- ty,
501
- ) ,
502
- ) ;
503
- expect = Operand :: Move ( slice) ;
504
- }
505
- }
506
- }
449
+ ( _, expect) = normalize_depth ( expect_ty, expect) ;
507
450
508
451
// Figure out the type on which we are calling `PartialEq`. This involves an extra wrapping
509
452
// reference: we can only compare two `&T`, and then compare_ty will be `T`.
@@ -540,7 +483,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
540
483
const_ : method,
541
484
} ) ) ,
542
485
args : [ Spanned { node : Operand :: Copy ( val) , span : DUMMY_SP } , Spanned {
543
- node : expect,
486
+ node : Operand :: Copy ( expect) ,
544
487
span : DUMMY_SP ,
545
488
} ]
546
489
. into ( ) ,
0 commit comments