@@ -11,7 +11,7 @@ use rustc_infer::infer;
11
11
use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
12
12
use rustc_infer:: traits:: Pattern ;
13
13
use rustc_span:: hygiene:: DesugaringKind ;
14
- use rustc_span:: Span ;
14
+ use rustc_span:: source_map :: { Span , Spanned } ;
15
15
use syntax:: ast;
16
16
use syntax:: util:: lev_distance:: find_best_match_for_name;
17
17
@@ -361,16 +361,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
361
361
// Byte string patterns behave the same way as array patterns
362
362
// They can denote both statically and dynamically-sized byte arrays.
363
363
let mut pat_ty = ty;
364
- if let hir:: ExprKind :: Lit ( ref lt) = lt. kind {
365
- if let ast:: LitKind :: ByteStr ( _) = lt. node {
366
- let expected_ty = self . structurally_resolved_type ( span, expected) ;
367
- if let ty:: Ref ( _, r_ty, _) = expected_ty. kind {
368
- if let ty:: Slice ( _) = r_ty. kind {
369
- let tcx = self . tcx ;
370
- pat_ty =
371
- tcx. mk_imm_ref ( tcx. lifetimes . re_static , tcx. mk_slice ( tcx. types . u8 ) ) ;
372
- }
373
- }
364
+ if let hir:: ExprKind :: Lit ( Spanned { node : ast:: LitKind :: ByteStr ( _) , .. } ) = lt. kind {
365
+ let expected = self . structurally_resolved_type ( span, expected) ;
366
+ if let ty:: Ref ( _, ty:: TyS { kind : ty:: Slice ( _) , .. } , _) = expected. kind {
367
+ let tcx = self . tcx ;
368
+ pat_ty = tcx. mk_imm_ref ( tcx. lifetimes . re_static , tcx. mk_slice ( tcx. types . u8 ) ) ;
374
369
}
375
370
}
376
371
0 commit comments