@@ -145,6 +145,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
145
145
let tcx = self . tcx ;
146
146
let success_block = target_block ( TestBranch :: Success ) ;
147
147
let fail_block = target_block ( TestBranch :: Failure ) ;
148
+
149
+ let expect_ty = value. ty ( ) ;
150
+ let expect = self . literal_operand ( test. span , value) ;
148
151
if let ty:: Adt ( def, _) = ty. kind ( )
149
152
&& tcx. is_lang_item ( def. did ( ) , LangItem :: String )
150
153
{
@@ -173,7 +176,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
173
176
success_block,
174
177
fail_block,
175
178
source_info,
176
- value,
179
+ expect,
180
+ expect_ty,
177
181
ref_str,
178
182
ref_str_ty,
179
183
) ;
@@ -185,13 +189,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
185
189
success_block,
186
190
fail_block,
187
191
source_info,
188
- value,
192
+ expect,
193
+ expect_ty,
189
194
place,
190
195
ty,
191
196
) ;
192
197
} else {
193
- assert_eq ! ( value. ty( ) , ty) ;
194
- let expect = self . literal_operand ( test. span , value) ;
198
+ assert_eq ! ( expect_ty, ty) ;
195
199
let val = Operand :: Copy ( place) ;
196
200
self . compare (
197
201
block,
@@ -371,12 +375,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
371
375
success_block : BasicBlock ,
372
376
fail_block : BasicBlock ,
373
377
source_info : SourceInfo ,
374
- value : Const < ' tcx > ,
378
+ mut expect : Operand < ' tcx > ,
379
+ expect_ty : Ty < ' tcx > ,
375
380
mut val : Place < ' tcx > ,
376
381
mut ty : Ty < ' tcx > ,
377
382
) {
378
- let mut expect = self . literal_operand ( source_info. span , value) ;
379
-
380
383
// If we're using `b"..."` as a pattern, we need to insert an
381
384
// unsizing coercion, as the byte string has the type `&[u8; N]`.
382
385
//
@@ -391,7 +394,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
391
394
_ => None ,
392
395
} ;
393
396
let opt_ref_ty = unsize ( ty) ;
394
- let opt_ref_test_ty = unsize ( value . ty ( ) ) ;
397
+ let opt_ref_test_ty = unsize ( expect_ty ) ;
395
398
match ( opt_ref_ty, opt_ref_test_ty) {
396
399
// nothing to do, neither is an array
397
400
( None , None ) => { }
0 commit comments