@@ -11,7 +11,7 @@ use rustc_infer::infer;
1111use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
1212use rustc_infer:: traits:: Pattern ;
1313use rustc_span:: hygiene:: DesugaringKind ;
14- use rustc_span:: Span ;
14+ use rustc_span:: source_map :: { Span , Spanned } ;
1515use syntax:: ast;
1616use syntax:: util:: lev_distance:: find_best_match_for_name;
1717
@@ -361,16 +361,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
361361 // Byte string patterns behave the same way as array patterns
362362 // They can denote both statically and dynamically-sized byte arrays.
363363 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 ) ) ;
374369 }
375370 }
376371
0 commit comments