@@ -32,7 +32,7 @@ use std::fmt;
32
32
use std:: iter:: { FromIterator , IntoIterator , repeat} ;
33
33
34
34
use rustc_front:: hir;
35
- use rustc_front:: hir:: Pat ;
35
+ use rustc_front:: hir:: { Pat , PatKind } ;
36
36
use rustc_front:: intravisit:: { self , Visitor , FnKind } ;
37
37
use rustc_front:: util as front_util;
38
38
use rustc_back:: slice;
@@ -47,7 +47,7 @@ use util::nodemap::FnvHashMap;
47
47
48
48
pub const DUMMY_WILD_PAT : & ' static Pat = & Pat {
49
49
id : DUMMY_NODE_ID ,
50
- node : hir :: PatWild ,
50
+ node : PatKind :: Wild ,
51
51
span : DUMMY_SP
52
52
} ;
53
53
@@ -242,7 +242,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) {
242
242
fn check_for_bindings_named_the_same_as_variants ( cx : & MatchCheckCtxt , pat : & Pat ) {
243
243
front_util:: walk_pat ( pat, |p| {
244
244
match p. node {
245
- hir :: PatIdent ( hir:: BindByValue ( hir:: MutImmutable ) , ident, None ) => {
245
+ PatKind :: Ident ( hir:: BindByValue ( hir:: MutImmutable ) , ident, None ) => {
246
246
let pat_ty = cx. tcx . pat_ty ( p) ;
247
247
if let ty:: TyEnum ( edef, _) = pat_ty. sty {
248
248
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)
274
274
// Check that we do not match against a static NaN (#6804)
275
275
fn check_for_static_nan ( cx : & MatchCheckCtxt , pat : & Pat ) {
276
276
front_util:: walk_pat ( pat, |p| {
277
- if let hir :: PatLit ( ref expr) = p. node {
277
+ if let PatKind :: Lit ( ref expr) = p. node {
278
278
match eval_const_expr_partial ( cx. tcx , & expr, ExprTypeChecked , None ) {
279
279
Ok ( ConstVal :: Float ( f) ) if f. is_nan ( ) => {
280
280
span_warn ! ( cx. tcx. sess, p. span, E0003 ,
@@ -360,7 +360,7 @@ fn check_arms(cx: &MatchCheckCtxt,
360
360
361
361
fn raw_pat < ' a > ( p : & ' a Pat ) -> & ' a Pat {
362
362
match p. node {
363
- hir :: PatIdent ( _, _, Some ( ref s) ) => raw_pat ( & s) ,
363
+ PatKind :: Ident ( _, _, Some ( ref s) ) => raw_pat ( & s) ,
364
364
_ => p
365
365
}
366
366
}
@@ -377,7 +377,7 @@ fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix, source: hir:
377
377
hir:: MatchSource :: ForLoopDesugar => {
378
378
// `witnesses[0]` has the form `Some(<head>)`, peel off the `Some`
379
379
let witness = match witnesses[ 0 ] . node {
380
- hir :: PatEnum ( _, Some ( ref pats) ) => match & pats[ ..] {
380
+ PatKind :: Enum ( _, Some ( ref pats) ) => match & pats[ ..] {
381
381
[ ref pat] => & * * pat,
382
382
_ => unreachable ! ( ) ,
383
383
} ,
@@ -466,7 +466,7 @@ impl<'map> ast_util::IdVisitingOperation for RenamingRecorder<'map> {
466
466
impl < ' a , ' tcx > Folder for StaticInliner < ' a , ' tcx > {
467
467
fn fold_pat ( & mut self , pat : P < Pat > ) -> P < Pat > {
468
468
return match pat. node {
469
- hir :: PatIdent ( ..) | hir :: PatEnum ( ..) | hir :: PatQPath ( ..) => {
469
+ PatKind :: Ident ( ..) | PatKind :: Enum ( ..) | PatKind :: QPath ( ..) => {
470
470
let def = self . tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) ;
471
471
match def {
472
472
Some ( Def :: AssociatedConst ( did) ) |
@@ -530,14 +530,14 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
530
530
let pats_len = pats. len ( ) ;
531
531
let mut pats = pats. into_iter ( ) . map ( |p| P ( ( * p) . clone ( ) ) ) ;
532
532
let pat = match left_ty. sty {
533
- ty:: TyTuple ( _) => hir :: PatTup ( pats. collect ( ) ) ,
533
+ ty:: TyTuple ( _) => PatKind :: Tup ( pats. collect ( ) ) ,
534
534
535
535
ty:: TyEnum ( adt, _) | ty:: TyStruct ( adt, _) => {
536
536
let v = adt. variant_of_ctor ( ctor) ;
537
537
if let VariantKind :: Struct = v. kind ( ) {
538
538
let field_pats: hir:: HirVec < _ > = v. fields . iter ( )
539
539
. zip ( pats)
540
- . filter ( |& ( _, ref pat) | pat. node != hir :: PatWild )
540
+ . filter ( |& ( _, ref pat) | pat. node != PatKind :: Wild )
541
541
. map ( |( field, pat) | Spanned {
542
542
span : DUMMY_SP ,
543
543
node : hir:: FieldPat {
@@ -547,9 +547,9 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
547
547
}
548
548
} ) . collect ( ) ;
549
549
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)
551
551
} 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 ( ) ) )
553
553
}
554
554
}
555
555
@@ -558,35 +558,35 @@ fn construct_witness<'a,'tcx>(cx: &MatchCheckCtxt<'a,'tcx>, ctor: &Constructor,
558
558
ty:: TyArray ( _, n) => match ctor {
559
559
& Single => {
560
560
assert_eq ! ( pats_len, n) ;
561
- hir :: PatVec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
561
+ PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
562
562
} ,
563
563
_ => unreachable ! ( )
564
564
} ,
565
565
ty:: TySlice ( _) => match ctor {
566
566
& Slice ( n) => {
567
567
assert_eq ! ( pats_len, n) ;
568
- hir :: PatVec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
568
+ PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
569
569
} ,
570
570
_ => unreachable ! ( )
571
571
} ,
572
- ty:: TyStr => hir :: PatWild ,
572
+ ty:: TyStr => PatKind :: Wild ,
573
573
574
574
_ => {
575
575
assert_eq ! ( pats_len, 1 ) ;
576
- hir :: PatRegion ( pats. nth ( 0 ) . unwrap ( ) , mutbl)
576
+ PatKind :: Ref ( pats. nth ( 0 ) . unwrap ( ) , mutbl)
577
577
}
578
578
}
579
579
}
580
580
581
581
ty:: TyArray ( _, len) => {
582
582
assert_eq ! ( pats_len, len) ;
583
- hir :: PatVec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
583
+ PatKind :: Vec ( pats. collect ( ) , None , hir:: HirVec :: new ( ) )
584
584
}
585
585
586
586
_ => {
587
587
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 ,
590
590
}
591
591
}
592
592
} ;
@@ -682,15 +682,15 @@ fn is_useful(cx: &MatchCheckCtxt,
682
682
let left_ty = cx. tcx . pat_ty ( & real_pat) ;
683
683
684
684
match real_pat. node {
685
- hir :: PatIdent ( hir:: BindByRef ( ..) , _, _) => {
685
+ PatKind :: Ident ( hir:: BindByRef ( ..) , _, _) => {
686
686
left_ty. builtin_deref ( false , NoPreference ) . unwrap ( ) . ty
687
687
}
688
688
_ => left_ty,
689
689
}
690
690
} ;
691
691
692
692
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 ( ) ) ,
694
694
_ => None
695
695
} ) . max ( ) . map_or ( 0 , |v| v + 1 ) ;
696
696
@@ -769,7 +769,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
769
769
left_ty : Ty , max_slice_length : usize ) -> Vec < Constructor > {
770
770
let pat = raw_pat ( p) ;
771
771
match pat. node {
772
- hir :: PatIdent ( ..) =>
772
+ PatKind :: Ident ( ..) =>
773
773
match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
774
774
Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
775
775
cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
@@ -778,30 +778,30 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
778
778
Some ( Def :: Variant ( _, id) ) => vec ! ( Variant ( id) ) ,
779
779
_ => vec ! ( )
780
780
} ,
781
- hir :: PatEnum ( ..) =>
781
+ PatKind :: Enum ( ..) =>
782
782
match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
783
783
Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
784
784
cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
785
785
been rewritten") ,
786
786
Some ( Def :: Variant ( _, id) ) => vec ! ( Variant ( id) ) ,
787
787
_ => vec ! ( Single )
788
788
} ,
789
- hir :: PatQPath ( ..) =>
789
+ PatKind :: QPath ( ..) =>
790
790
cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
791
791
been rewritten") ,
792
- hir :: PatStruct ( ..) =>
792
+ PatKind :: Struct ( ..) =>
793
793
match cx. tcx . def_map . borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
794
794
Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
795
795
cx. tcx . sess . span_bug ( pat. span , "const pattern should've \
796
796
been rewritten") ,
797
797
Some ( Def :: Variant ( _, id) ) => vec ! ( Variant ( id) ) ,
798
798
_ => vec ! ( Single )
799
799
} ,
800
- hir :: PatLit ( ref expr) =>
800
+ PatKind :: Lit ( ref expr) =>
801
801
vec ! ( ConstantValue ( eval_const_expr( cx. tcx, & expr) ) ) ,
802
- hir :: PatRange ( ref lo, ref hi) =>
802
+ PatKind :: Range ( ref lo, ref hi) =>
803
803
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) =>
805
805
match left_ty. sty {
806
806
ty:: TyArray ( _, _) => vec ! ( Single ) ,
807
807
_ => if slice. is_some ( ) {
@@ -812,9 +812,9 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
812
812
vec ! ( Slice ( before. len( ) + after. len( ) ) )
813
813
}
814
814
} ,
815
- hir :: PatBox ( _) | hir :: PatTup ( _) | hir :: PatRegion ( ..) =>
815
+ PatKind :: Box ( _) | PatKind :: Tup ( _) | PatKind :: Ref ( ..) =>
816
816
vec ! ( Single ) ,
817
- hir :: PatWild =>
817
+ PatKind :: Wild =>
818
818
vec ! ( ) ,
819
819
}
820
820
}
@@ -877,10 +877,10 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
877
877
id : pat_id, ref node, span : pat_span
878
878
} = raw_pat ( r[ col] ) ;
879
879
let head: Option < Vec < & Pat > > = match * node {
880
- hir :: PatWild =>
880
+ PatKind :: Wild =>
881
881
Some ( vec ! [ DUMMY_WILD_PAT ; arity] ) ,
882
882
883
- hir :: PatIdent ( _, _, _) => {
883
+ PatKind :: Ident ( _, _, _) => {
884
884
let opt_def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . map ( |d| d. full_def ( ) ) ;
885
885
match opt_def {
886
886
Some ( Def :: Const ( ..) ) | Some ( Def :: AssociatedConst ( ..) ) =>
@@ -895,7 +895,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
895
895
}
896
896
}
897
897
898
- hir :: PatEnum ( _, ref args) => {
898
+ PatKind :: Enum ( _, ref args) => {
899
899
let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
900
900
match def {
901
901
Def :: Const ( ..) | Def :: AssociatedConst ( ..) =>
@@ -912,12 +912,12 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
912
912
}
913
913
}
914
914
915
- hir :: PatQPath ( _, _) => {
915
+ PatKind :: QPath ( _, _) => {
916
916
cx. tcx . sess . span_bug ( pat_span, "const pattern should've \
917
917
been rewritten")
918
918
}
919
919
920
- hir :: PatStruct ( _, ref pattern_fields, _) => {
920
+ PatKind :: Struct ( _, ref pattern_fields, _) => {
921
921
let def = cx. tcx . def_map . borrow ( ) . get ( & pat_id) . unwrap ( ) . full_def ( ) ;
922
922
let adt = cx. tcx . node_id_to_type ( pat_id) . ty_adt_def ( ) . unwrap ( ) ;
923
923
let variant = adt. variant_of_ctor ( constructor) ;
@@ -934,13 +934,13 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
934
934
}
935
935
}
936
936
937
- hir :: PatTup ( ref args) =>
937
+ PatKind :: Tup ( ref args) =>
938
938
Some ( args. iter ( ) . map ( |p| & * * p) . collect ( ) ) ,
939
939
940
- hir :: PatBox ( ref inner) | hir :: PatRegion ( ref inner, _) =>
940
+ PatKind :: Box ( ref inner) | PatKind :: Ref ( ref inner, _) =>
941
941
Some ( vec ! [ & * * inner] ) ,
942
942
943
- hir :: PatLit ( ref expr) => {
943
+ PatKind :: Lit ( ref expr) => {
944
944
let expr_value = eval_const_expr ( cx. tcx , & expr) ;
945
945
match range_covered_by_constructor ( constructor, & expr_value, & expr_value) {
946
946
Some ( true ) => Some ( vec ! [ ] ) ,
@@ -952,7 +952,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
952
952
}
953
953
}
954
954
955
- hir :: PatRange ( ref from, ref to) => {
955
+ PatKind :: Range ( ref from, ref to) => {
956
956
let from_value = eval_const_expr ( cx. tcx , & from) ;
957
957
let to_value = eval_const_expr ( cx. tcx , & to) ;
958
958
match range_covered_by_constructor ( constructor, & from_value, & to_value) {
@@ -965,7 +965,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
965
965
}
966
966
}
967
967
968
- hir :: PatVec ( ref before, ref slice, ref after) => {
968
+ PatKind :: Vec ( ref before, ref slice, ref after) => {
969
969
match * constructor {
970
970
// Fixed-length vectors.
971
971
Single => {
@@ -1104,7 +1104,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
1104
1104
front_util:: walk_pat ( & pat, |p| {
1105
1105
if pat_is_binding ( & def_map. borrow ( ) , & p) {
1106
1106
match p. node {
1107
- hir :: PatIdent ( hir:: BindByValue ( _) , _, ref sub) => {
1107
+ PatKind :: Ident ( hir:: BindByValue ( _) , _, ref sub) => {
1108
1108
let pat_ty = tcx. node_id_to_type ( p. id ) ;
1109
1109
//FIXME: (@jroesch) this code should be floated up as well
1110
1110
let infcx = infer:: new_infer_ctxt ( cx. tcx ,
@@ -1114,7 +1114,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
1114
1114
check_move ( p, sub. as_ref ( ) . map ( |p| & * * p) ) ;
1115
1115
}
1116
1116
}
1117
- hir :: PatIdent ( hir:: BindByRef ( _) , _, _) => {
1117
+ PatKind :: Ident ( hir:: BindByRef ( _) , _, _) => {
1118
1118
}
1119
1119
_ => {
1120
1120
cx. tcx . sess . span_bug (
@@ -1202,7 +1202,7 @@ impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
1202
1202
}
1203
1203
1204
1204
match pat. node {
1205
- hir :: PatIdent ( _, _, Some ( _) ) => {
1205
+ PatKind :: Ident ( _, _, Some ( _) ) => {
1206
1206
let bindings_were_allowed = self . bindings_allowed ;
1207
1207
self . bindings_allowed = false ;
1208
1208
intravisit:: walk_pat ( self , pat) ;
0 commit comments