@@ -32,7 +32,7 @@ use std::fmt;
3232use std:: iter:: { FromIterator , IntoIterator , repeat} ;
3333
3434use rustc_front:: hir;
35- use rustc_front:: hir:: Pat ;
35+ use rustc_front:: hir:: { Pat , PatKind } ;
3636use rustc_front:: intravisit:: { self , Visitor , FnKind } ;
3737use rustc_front:: util as front_util;
3838use rustc_back:: slice;
@@ -47,7 +47,7 @@ use util::nodemap::FnvHashMap;
4747
4848pub const DUMMY_WILD_PAT : & ' static Pat = & Pat {
4949 id : DUMMY_NODE_ID ,
50- node : hir :: PatWild ,
50+ node : PatKind :: Wild ,
5151 span : DUMMY_SP
5252} ;
5353
@@ -242,7 +242,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
242242fn check_for_bindings_named_the_same_as_variants ( cx : & MatchCheckCtxt , pat : & Pat ) {
243243 front_util:: walk_pat ( pat, |p| {
244244 match p. node {
245- hir :: PatIdent ( hir:: BindByValue ( hir:: MutImmutable ) , ident, None ) => {
245+ PatKind :: Ident ( hir:: BindByValue ( hir:: MutImmutable ) , ident, None ) => {
246246 let pat_ty = cx. tcx . pat_ty ( p) ;
247247 if let ty:: TyEnum ( edef, _) = pat_ty. sty {
248248 let def = cx. tcx . def_map . borrow ( ) . get ( & p. id ) . map ( |d| d. full_def ( ) ) ;
@@ -274,7 +274,7 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
274274// Check that we do not match against a static NaN (#6804)
275275fn check_for_static_nan ( cx : & MatchCheckCtxt , pat : & Pat ) {
276276 front_util:: walk_pat ( pat, |p| {
277- if let hir :: PatLit ( ref expr) = p. node {
277+ if let PatKind :: Lit ( ref expr) = p. node {
278278 match eval_const_expr_partial ( cx. tcx , & expr, ExprTypeChecked , None ) {
279279 Ok ( ConstVal :: Float ( f) ) if f. is_nan ( ) => {
280280 span_warn ! ( cx. tcx. sess, p. span, E0003 ,
@@ -360,7 +360,7 @@ fn check_arms(cx: &MatchCheckCtxt,
360360
361361fn raw_pat < ' a > ( p : & ' a Pat ) -> & ' a Pat {
362362 match p. node {
363- hir :: PatIdent ( _, _, Some ( ref s) ) => raw_pat ( & s) ,
363+ PatKind :: Ident ( _, _, Some ( ref s) ) => raw_pat ( & s) ,
364364 _ => p
365365 }
366366}
@@ -377,7 +377,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
377377 hir:: MatchSource :: ForLoopDesugar => {
378378 // `witnesses[0]` has the form `Some(<head>)`, peel off the `Some`
379379 let witness = match witnesses[ 0 ] . node {
380- hir :: PatEnum ( _, Some ( ref pats) ) => match & pats[ ..] {
380+ PatKind :: Enum ( _, Some ( ref pats) ) => match & pats[ ..] {
381381 [ ref pat] => & * * pat,
382382 _ => unreachable ! ( ) ,
383383 } ,
@@ -466,7 +466,7 @@ impl<'map> ast_util::IdVisitingOperation for RenamingRecorder<'map> {
466466impl < ' a , ' tcx > Folder for StaticInliner < ' a , ' tcx > {
467467 fn fold_pat ( & mut self , pat : P < Pat > ) -> P < Pat > {
468468 return match pat. node {
469- hir :: PatIdent ( ..) | hir :: PatEnum ( ..) | hir :: PatQPath ( ..) => {
469+ PatKind :: Ident ( ..) | PatKind :: Enum ( ..) | PatKind :: QPath ( ..) => {
470470 let def = self . tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) ;
471471 match def {
472472 Some ( Def :: AssociatedConst ( did) ) |
@@ -530,14 +530,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
530530 let pats_len = pats. len ( ) ;
531531 let mut pats = pats. into_iter ( ) . map ( |p| P ( ( * p) . clone ( ) ) ) ;
532532 let pat = match left_ty. sty {
533- ty:: TyTuple ( _) => hir :: PatTup ( pats. collect ( ) ) ,
533+ ty:: TyTuple ( _) => PatKind :: Tup ( pats. collect ( ) ) ,
534534
535535 ty:: TyEnum ( adt, _) | ty:: TyStruct ( adt, _) => {
536536 let v = adt. variant_of_ctor ( ctor) ;
537537 if let VariantKind :: Struct = v. kind ( ) {
538538 let field_pats: hir:: HirVec < _ > = v. fields . iter ( )
539539 . zip ( pats)
540- . filter ( |& ( _, ref pat) | pat. node != hir :: PatWild )
540+ . filter ( |& ( _, ref pat) | pat. node != PatKind :: Wild )
541541 . map ( |( field, pat) | Spanned {
542542 span : DUMMY_SP ,
543543 node : hir:: FieldPat {
@@ -547,9 +547,9 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
547547 }
548548 } ) . collect ( ) ;
549549 let has_more_fields = field_pats. len ( ) < pats_len;
550- hir :: PatStruct ( def_to_path ( cx. tcx , v. did ) , field_pats, has_more_fields)
550+ PatKind :: Struct ( def_to_path ( cx. tcx , v. did ) , field_pats, has_more_fields)
551551 } else {
552- hir :: PatEnum ( def_to_path ( cx. tcx , v. did ) , Some ( pats. collect ( ) ) )
552+ PatKind :: Enum ( def_to_path ( cx. tcx , v. did ) , Some ( pats. collect ( ) ) )
553553 }
554554 }
555555
@@ -558,35 +558,35 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
558558 ty:: TyArray ( _, n) => match ctor {
559559 & Single => {
560560 assert_eq ! ( pats_len, n) ;
561- hir :: PatVec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
561+ PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
562562 } ,
563563 _ => unreachable ! ( )
564564 } ,
565565 ty:: TySlice ( _) => match ctor {
566566 & Slice ( n) => {
567567 assert_eq ! ( pats_len, n) ;
568- hir :: PatVec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
568+ PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
569569 } ,
570570 _ => unreachable ! ( )
571571 } ,
572- ty:: TyStr => hir :: PatWild ,
572+ ty:: TyStr => PatKind :: Wild ,
573573
574574 _ => {
575575 assert_eq ! ( pats_len, 1 ) ;
576- hir :: PatRegion ( pats. nth ( 0 ) . unwrap ( ) , mutbl)
576+ PatKind :: Ref ( pats. nth ( 0 ) . unwrap ( ) , mutbl)
577577 }
578578 }
579579 }
580580
581581 ty:: TyArray ( _, len) => {
582582 assert_eq ! ( pats_len, len) ;
583- hir :: PatVec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
583+ PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
584584 }
585585
586586 _ => {
587587 match * ctor {
588- ConstantValue ( ref v) => hir :: PatLit ( const_val_to_expr ( v) ) ,
589- _ => hir :: PatWild ,
588+ ConstantValue ( ref v) => PatKind :: Lit ( const_val_to_expr ( v) ) ,
589+ _ => PatKind :: Wild ,
590590 }
591591 }
592592 } ;
@@ -682,15 +682,15 @@ fn is_useful(cx: &MatchCheckCtxt,
682682 let left_ty = cx. tcx . pat_ty ( & real_pat) ;
683683
684684 match real_pat. node {
685- hir :: PatIdent ( hir:: BindByRef ( ..) , _, _) => {
685+ PatKind :: Ident ( hir:: BindByRef ( ..) , _, _) => {
686686 left_ty. builtin_deref ( false , NoPreference ) . unwrap ( ) . ty
687687 }
688688 _ => left_ty,
689689 }
690690 } ;
691691
692692 let max_slice_length = rows. iter ( ) . filter_map ( |row| match row[ 0 ] . node {
693- hir :: PatVec ( ref before, _, ref after) => Some ( before. len ( ) + after. len ( ) ) ,
693+ PatKind :: Vec ( ref before, _, ref after) => Some ( before. len ( ) + after. len ( ) ) ,
694694 _ => None
695695 } ) . max ( ) . map_or ( 0 , |v| v + 1 ) ;
696696
@@ -769,7 +769,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
769769 left_ty : Ty , max_slice_length : usize ) -> Vec < Constructor > {
770770 let pat = raw_pat ( p) ;
771771 match pat. node {
772- hir :: PatIdent ( ..) =>
772+ PatKind :: Ident ( ..) =>
773773 match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
774774 Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
775775 cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
@@ -778,30 +778,30 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
778778 Some ( Def :: Variant ( _, id) ) => vec ! ( Variant ( id) ) ,
779779 _ => vec ! ( )
780780 } ,
781- hir :: PatEnum ( ..) =>
781+ PatKind :: Enum ( ..) =>
782782 match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
783783 Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
784784 cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
785785 been rewritten") ,
786786 Some ( Def :: Variant ( _, id) ) => vec ! ( Variant ( id) ) ,
787787 _ => vec ! ( Single )
788788 } ,
789- hir :: PatQPath ( ..) =>
789+ PatKind :: QPath ( ..) =>
790790 cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
791791 been rewritten") ,
792- hir :: PatStruct ( ..) =>
792+ PatKind :: Struct ( ..) =>
793793 match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
794794 Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
795795 cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
796796 been rewritten") ,
797797 Some ( Def :: Variant ( _, id) ) => vec ! ( Variant ( id) ) ,
798798 _ => vec ! ( Single )
799799 } ,
800- hir :: PatLit ( ref expr) =>
800+ PatKind :: Lit ( ref expr) =>
801801 vec ! ( ConstantValue ( eval_const_expr( cx. tcx, & expr) ) ) ,
802- hir :: PatRange ( ref lo, ref hi) =>
802+ PatKind :: Range ( ref lo, ref hi) =>
803803 vec ! ( ConstantRange ( eval_const_expr( cx. tcx, & lo) , eval_const_expr( cx. tcx, & hi) ) ) ,
804- hir :: PatVec ( ref before, ref slice, ref after) =>
804+ PatKind :: Vec ( ref before, ref slice, ref after) =>
805805 match left_ty. sty {
806806 ty:: TyArray ( _, _) => vec ! ( Single ) ,
807807 _ => if slice. is_some ( ) {
@@ -812,9 +812,9 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
812812 vec ! ( Slice ( before. len( ) + after. len( ) ) )
813813 }
814814 } ,
815- hir :: PatBox ( _) | hir :: PatTup ( _) | hir :: PatRegion ( ..) =>
815+ PatKind :: Box ( _) | PatKind :: Tup ( _) | PatKind :: Ref ( ..) =>
816816 vec ! ( Single ) ,
817- hir :: PatWild =>
817+ PatKind :: Wild =>
818818 vec ! ( ) ,
819819 }
820820}
@@ -877,10 +877,10 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
877877 id : pat_id, ref node, span : pat_span
878878 } = raw_pat ( r[ col] ) ;
879879 let head: Option < Vec < & Pat > > = match * node {
880- hir :: PatWild =>
880+ PatKind :: Wild =>
881881 Some ( vec ! [ DUMMY_WILD_PAT ; arity] ) ,
882882
883- hir :: PatIdent ( _, _, _) => {
883+ PatKind :: Ident ( _, _, _) => {
884884 let opt_def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . map ( |d| d. full_def ( ) ) ;
885885 match opt_def {
886886 Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
@@ -895,7 +895,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
895895 }
896896 }
897897
898- hir :: PatEnum ( _, ref args) => {
898+ PatKind :: Enum ( _, ref args) => {
899899 let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
900900 match def {
901901 Def :: Const ( ..) | Def :: AssociatedConst ( ..) =>
@@ -912,12 +912,12 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
912912 }
913913 }
914914
915- hir :: PatQPath ( _, _) => {
915+ PatKind :: QPath ( _, _) => {
916916 cx. tcx . sess . span_bug ( pat_span, "const pattern should've \
917917 been rewritten")
918918 }
919919
920- hir :: PatStruct ( _, ref pattern_fields, _) => {
920+ PatKind :: Struct ( _, ref pattern_fields, _) => {
921921 let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
922922 let adt = cx. tcx . node_id_to_type ( pat_id) . ty_adt_def ( ) . unwrap ( ) ;
923923 let variant = adt. variant_of_ctor ( constructor) ;
@@ -934,13 +934,13 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
934934 }
935935 }
936936
937- hir :: PatTup ( ref args) =>
937+ PatKind :: Tup ( ref args) =>
938938 Some ( args. iter ( ) . map ( |p| & * * p) . collect ( ) ) ,
939939
940- hir :: PatBox ( ref inner) | hir :: PatRegion ( ref inner, _) =>
940+ PatKind :: Box ( ref inner) | PatKind :: Ref ( ref inner, _) =>
941941 Some ( vec ! [ & * * inner] ) ,
942942
943- hir :: PatLit ( ref expr) => {
943+ PatKind :: Lit ( ref expr) => {
944944 let expr_value = eval_const_expr ( cx. tcx , & expr) ;
945945 match range_covered_by_constructor ( constructor, & expr_value, & expr_value) {
946946 Some ( true ) => Some ( vec ! [ ] ) ,
@@ -952,7 +952,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
952952 }
953953 }
954954
955- hir :: PatRange ( ref from, ref to) => {
955+ PatKind :: Range ( ref from, ref to) => {
956956 let from_value = eval_const_expr ( cx. tcx , & from) ;
957957 let to_value = eval_const_expr ( cx. tcx , & to) ;
958958 match range_covered_by_constructor ( constructor, & from_value, & to_value) {
@@ -965,7 +965,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
965965 }
966966 }
967967
968- hir :: PatVec ( ref before, ref slice, ref after) => {
968+ PatKind :: Vec ( ref before, ref slice, ref after) => {
969969 match * constructor {
970970 // Fixed-length vectors.
971971 Single => {
@@ -1104,7 +1104,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
11041104 front_util:: walk_pat ( & pat, |p| {
11051105 if pat_is_binding ( & def_map. borrow ( ) , & p) {
11061106 match p. node {
1107- hir :: PatIdent ( hir:: BindByValue ( _) , _, ref sub) => {
1107+ PatKind :: Ident ( hir:: BindByValue ( _) , _, ref sub) => {
11081108 let pat_ty = tcx. node_id_to_type ( p. id ) ;
11091109 //FIXME: (@jroesch) this code should be floated up as well
11101110 let infcx = infer:: new_infer_ctxt ( cx. tcx ,
@@ -1114,7 +1114,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
11141114 check_move ( p, sub. as_ref ( ) . map ( |p| & * * p) ) ;
11151115 }
11161116 }
1117- hir :: PatIdent ( hir:: BindByRef ( _) , _, _) => {
1117+ PatKind :: Ident ( hir:: BindByRef ( _) , _, _) => {
11181118 }
11191119 _ => {
11201120 cx. tcx . sess . span_bug (
@@ -1202,7 +1202,7 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
12021202 }
12031203
12041204 match pat. node {
1205- hir :: PatIdent ( _, _, Some ( _) ) => {
1205+ PatKind :: Ident ( _, _, Some ( _) ) => {
12061206 let bindings_were_allowed = self . bindings_allowed ;
12071207 self . bindings_allowed = false ;
12081208 intravisit:: walk_pat ( self , pat) ;
0 commit comments