@@ -4,7 +4,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
4
4
use rustc_hir:: def:: { DefKind , Res } ;
5
5
use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
6
6
use 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 } ;
8
8
use rustc_middle:: hir:: nested_filter;
9
9
use rustc_middle:: ty:: TyCtxt ;
10
10
use rustc_span:: hygiene:: MacroKind ;
@@ -189,6 +189,27 @@ impl SpanMapVisitor<'_> {
189
189
self . matches . insert ( span, link) ;
190
190
}
191
191
}
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
+ }
192
213
}
193
214
194
215
impl < ' tcx > Visitor < ' tcx > for SpanMapVisitor < ' tcx > {
@@ -206,6 +227,10 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
206
227
intravisit:: walk_path ( self , path) ;
207
228
}
208
229
230
+ fn visit_pat ( & mut self , p : & Pat < ' tcx > ) {
231
+ self . handle_pat ( p) ;
232
+ }
233
+
209
234
fn visit_mod ( & mut self , m : & ' tcx Mod < ' tcx > , span : Span , id : HirId ) {
210
235
// To make the difference between "mod foo {}" and "mod foo;". In case we "import" another
211
236
// file, we want to link to it. Otherwise no need to create a link.
0 commit comments