File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -116,20 +116,27 @@ pub struct ParamBindingIdCollector {
116
116
}
117
117
impl < ' tcx > ParamBindingIdCollector {
118
118
fn collect_binding_hir_ids ( body : & ' tcx hir:: Body < ' tcx > ) -> Vec < hir:: HirId > {
119
- let mut finder = ParamBindingIdCollector {
120
- binding_hir_ids : Vec :: new ( ) ,
121
- } ;
122
- finder. visit_body ( body) ;
123
- finder. binding_hir_ids
119
+ let mut hir_ids: Vec < hir:: HirId > = Vec :: new ( ) ;
120
+ for param in body. params . iter ( ) {
121
+ let mut finder = ParamBindingIdCollector {
122
+ binding_hir_ids : Vec :: new ( ) ,
123
+ } ;
124
+ finder. visit_param ( param) ;
125
+ for hir_id in & finder. binding_hir_ids {
126
+ hir_ids. push ( * hir_id) ;
127
+ }
128
+ }
129
+ hir_ids
124
130
}
125
131
}
126
132
impl < ' tcx > intravisit:: Visitor < ' tcx > for ParamBindingIdCollector {
127
133
type Map = Map < ' tcx > ;
128
134
129
- fn visit_param ( & mut self , param : & ' tcx hir:: Param < ' tcx > ) {
130
- if let hir:: PatKind :: Binding ( _, hir_id, ..) = param . pat . kind {
135
+ fn visit_pat ( & mut self , pat : & ' tcx hir:: Pat < ' tcx > ) {
136
+ if let hir:: PatKind :: Binding ( _, hir_id, ..) = pat. kind {
131
137
self . binding_hir_ids . push ( hir_id) ;
132
138
}
139
+ intravisit:: walk_pat ( self , pat) ;
133
140
}
134
141
135
142
fn nested_visit_map ( & mut self ) -> intravisit:: NestedVisitorMap < Self :: Map > {
Original file line number Diff line number Diff line change @@ -15,4 +15,8 @@ fn main() {
15
15
}
16
16
let _ = Ok ( 1 ) . unwrap_or_else ( |e:: E | 2 ) ;
17
17
let _ = Ok ( 1 ) . unwrap_or_else ( |SomeStruct { .. } | 2 ) ;
18
+
19
+ // Fix #6343
20
+ let arr = [ ( Some ( 1 ) , ) ] ;
21
+ Some ( & 0 ) . and_then ( |& i| arr[ i] . 0 ) ;
18
22
}
You can’t perform that action at this time.
0 commit comments