@@ -4,7 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
44use rustc_hir:: def:: { DefKind , Res } ;
55use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
66use rustc_hir:: intravisit:: { self , Visitor } ;
7- use rustc_hir:: { ExprKind , HirId , Item , ItemKind , Mod , Node } ;
7+ use rustc_hir:: { ExprKind , HirId , Item , ItemKind , Mod , Node , Pat , PatKind , QPath } ;
88use rustc_middle:: hir:: nested_filter;
99use rustc_middle:: ty:: TyCtxt ;
1010use rustc_span:: hygiene:: MacroKind ;
@@ -189,6 +189,27 @@ impl SpanMapVisitor<'_> {
189189 self . matches . insert ( span, link) ;
190190 }
191191 }
192+
193+ fn handle_pat ( & mut self , p : & Pat < ' _ > ) {
194+ match p. kind {
195+ PatKind :: Binding ( _, _, _, Some ( p) ) => self . handle_pat ( p) ,
196+ PatKind :: Struct ( qpath, _, _)
197+ | PatKind :: TupleStruct ( qpath, _, _)
198+ | PatKind :: Path ( qpath) => match qpath {
199+ QPath :: TypeRelative ( _, path) if matches ! ( path. res, Res :: Err ) => {
200+ self . handle_call ( path. hir_id , Some ( p. hir_id ) , qpath. span ( ) ) ;
201+ }
202+ QPath :: Resolved ( _, path) => self . handle_path ( path) ,
203+ _ => { }
204+ } ,
205+ PatKind :: Or ( pats) => {
206+ for pat in pats {
207+ self . handle_pat ( pat) ;
208+ }
209+ }
210+ _ => { }
211+ }
212+ }
192213}
193214
194215impl < ' tcx > Visitor < ' tcx > for SpanMapVisitor < ' tcx > {
@@ -206,6 +227,10 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
206227 intravisit:: walk_path ( self , path) ;
207228 }
208229
230+ fn visit_pat ( & mut self , p : & Pat < ' tcx > ) {
231+ self . handle_pat ( p) ;
232+ }
233+
209234 fn visit_mod ( & mut self , m : & ' tcx Mod < ' tcx > , span : Span , id : HirId ) {
210235 // To make the difference between "mod foo {}" and "mod foo;". In case we "import" another
211236 // file, we want to link to it. Otherwise no need to create a link.
0 commit comments