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 {
116116}
117117impl < ' tcx > ParamBindingIdCollector {
118118 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
124130 }
125131}
126132impl < ' tcx > intravisit:: Visitor < ' tcx > for ParamBindingIdCollector {
127133 type Map = Map < ' tcx > ;
128134
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 {
131137 self . binding_hir_ids . push ( hir_id) ;
132138 }
139+ intravisit:: walk_pat ( self , pat) ;
133140 }
134141
135142 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() {
1515 }
1616 let _ = Ok ( 1 ) . unwrap_or_else ( |e:: E | 2 ) ;
1717 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 ) ;
1822}
You can’t perform that action at this time.
0 commit comments