@@ -32,13 +32,13 @@ pub fn pat_id_map(dm: &RefCell<DefMap>, pat: &hir::Pat) -> PatIdMap {
32
32
map
33
33
}
34
34
35
- pub fn pat_is_refutable ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
35
+ pub fn pat_is_refutable ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
36
36
match pat. node {
37
37
hir:: PatLit ( _) | hir:: PatRange ( _, _) | hir:: PatQPath ( ..) => true ,
38
38
hir:: PatEnum ( _, _) |
39
39
hir:: PatIdent ( _, _, None ) |
40
40
hir:: PatStruct ( ..) => {
41
- match dm. borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
41
+ match dm. get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
42
42
Some ( DefVariant ( ..) ) => true ,
43
43
_ => false
44
44
}
@@ -48,12 +48,12 @@ pub fn pat_is_refutable(dm: &RefCell<DefMap>, pat: &hir::Pat) -> bool {
48
48
}
49
49
}
50
50
51
- pub fn pat_is_variant_or_struct ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
51
+ pub fn pat_is_variant_or_struct ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
52
52
match pat. node {
53
53
hir:: PatEnum ( _, _) |
54
54
hir:: PatIdent ( _, _, None ) |
55
55
hir:: PatStruct ( ..) => {
56
- match dm. borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
56
+ match dm. get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
57
57
Some ( DefVariant ( ..) ) | Some ( DefStruct ( ..) ) => true ,
58
58
_ => false
59
59
}
@@ -62,10 +62,10 @@ pub fn pat_is_variant_or_struct(dm: &RefCell<DefMap>, pat: &hir::Pat) -> bool {
62
62
}
63
63
}
64
64
65
- pub fn pat_is_const ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
65
+ pub fn pat_is_const ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
66
66
match pat. node {
67
67
hir:: PatIdent ( _, _, None ) | hir:: PatEnum ( ..) | hir:: PatQPath ( ..) => {
68
- match dm. borrow ( ) . get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
68
+ match dm. get ( & pat. id ) . map ( |d| d. full_def ( ) ) {
69
69
Some ( DefConst ( ..) ) | Some ( DefAssociatedConst ( ..) ) => true ,
70
70
_ => false
71
71
}
@@ -76,10 +76,10 @@ pub fn pat_is_const(dm: &RefCell<DefMap>, pat: &hir::Pat) -> bool {
76
76
77
77
// Same as above, except that partially-resolved defs cause `false` to be
78
78
// returned instead of a panic.
79
- pub fn pat_is_resolved_const ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
79
+ pub fn pat_is_resolved_const ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
80
80
match pat. node {
81
81
hir:: PatIdent ( _, _, None ) | hir:: PatEnum ( ..) | hir:: PatQPath ( ..) => {
82
- match dm. borrow ( ) . get ( & pat. id )
82
+ match dm. get ( & pat. id )
83
83
. and_then ( |d| if d. depth == 0 { Some ( d. base_def ) }
84
84
else { None } ) {
85
85
Some ( DefConst ( ..) ) | Some ( DefAssociatedConst ( ..) ) => true ,
@@ -90,7 +90,7 @@ pub fn pat_is_resolved_const(dm: &RefCell<DefMap>, pat: &hir::Pat) -> bool {
90
90
}
91
91
}
92
92
93
- pub fn pat_is_binding ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
93
+ pub fn pat_is_binding ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
94
94
match pat. node {
95
95
hir:: PatIdent ( ..) => {
96
96
!pat_is_variant_or_struct ( dm, pat) &&
@@ -100,7 +100,7 @@ pub fn pat_is_binding(dm: &RefCell<DefMap>, pat: &hir::Pat) -> bool {
100
100
}
101
101
}
102
102
103
- pub fn pat_is_binding_or_wild ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
103
+ pub fn pat_is_binding_or_wild ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
104
104
match pat. node {
105
105
hir:: PatIdent ( ..) => pat_is_binding ( dm, pat) ,
106
106
hir:: PatWild => true ,
@@ -115,7 +115,7 @@ pub fn pat_bindings<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I) where
115
115
{
116
116
walk_pat ( pat, |p| {
117
117
match p. node {
118
- hir:: PatIdent ( binding_mode, ref pth, _) if pat_is_binding ( dm , p) => {
118
+ hir:: PatIdent ( binding_mode, ref pth, _) if pat_is_binding ( & dm . borrow ( ) , p) => {
119
119
it ( binding_mode, p. id , p. span , & respan ( pth. span , pth. node . name ) ) ;
120
120
}
121
121
_ => { }
@@ -129,7 +129,7 @@ pub fn pat_bindings_hygienic<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I)
129
129
{
130
130
walk_pat ( pat, |p| {
131
131
match p. node {
132
- hir:: PatIdent ( binding_mode, ref pth, _) if pat_is_binding ( dm , p) => {
132
+ hir:: PatIdent ( binding_mode, ref pth, _) if pat_is_binding ( & dm . borrow ( ) , p) => {
133
133
it ( binding_mode, p. id , p. span , & respan ( pth. span , pth. node ) ) ;
134
134
}
135
135
_ => { }
@@ -140,7 +140,7 @@ pub fn pat_bindings_hygienic<I>(dm: &RefCell<DefMap>, pat: &hir::Pat, mut it: I)
140
140
141
141
/// Checks if the pattern contains any patterns that bind something to
142
142
/// an ident, e.g. `foo`, or `Foo(foo)` or `foo @ Bar(..)`.
143
- pub fn pat_contains_bindings ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
143
+ pub fn pat_contains_bindings ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
144
144
let mut contains_bindings = false ;
145
145
walk_pat ( pat, |p| {
146
146
if pat_is_binding ( dm, p) {
@@ -185,7 +185,7 @@ pub fn arm_contains_ref_binding(dm: &RefCell<DefMap>, arm: &hir::Arm) -> Option<
185
185
186
186
/// Checks if the pattern contains any patterns that bind something to
187
187
/// an ident or wildcard, e.g. `foo`, or `Foo(_)`, `foo @ Bar(..)`,
188
- pub fn pat_contains_bindings_or_wild ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> bool {
188
+ pub fn pat_contains_bindings_or_wild ( dm : & DefMap , pat : & hir:: Pat ) -> bool {
189
189
let mut contains_bindings = false ;
190
190
walk_pat ( pat, |p| {
191
191
if pat_is_binding_or_wild ( dm, p) {
@@ -221,14 +221,14 @@ pub fn def_to_path(tcx: &ty::ctxt, id: DefId) -> hir::Path {
221
221
}
222
222
223
223
/// Return variants that are necessary to exist for the pattern to match.
224
- pub fn necessary_variants ( dm : & RefCell < DefMap > , pat : & hir:: Pat ) -> Vec < DefId > {
224
+ pub fn necessary_variants ( dm : & DefMap , pat : & hir:: Pat ) -> Vec < DefId > {
225
225
let mut variants = vec ! [ ] ;
226
226
walk_pat ( pat, |p| {
227
227
match p. node {
228
228
hir:: PatEnum ( _, _) |
229
229
hir:: PatIdent ( _, _, None ) |
230
230
hir:: PatStruct ( ..) => {
231
- match dm. borrow ( ) . get ( & p. id ) {
231
+ match dm. get ( & p. id ) {
232
232
Some ( & PathResolution { base_def : DefVariant ( _, id, _) , .. } ) => {
233
233
variants. push ( id) ;
234
234
}
0 commit comments