@@ -8,9 +8,10 @@ use rustc_hir::{ExprKind, HirId, Item, ItemKind, Mod, Node, QPath};
8
8
use rustc_middle:: hir:: nested_filter;
9
9
use rustc_middle:: ty:: TyCtxt ;
10
10
use rustc_span:: hygiene:: MacroKind ;
11
- use rustc_span:: { BytePos , ExpnKind , Span } ;
11
+ use rustc_span:: { BytePos , ExpnKind } ;
12
12
13
13
use crate :: clean:: { self , PrimitiveType , rustc_span} ;
14
+ use crate :: html:: highlight:: Span ;
14
15
use crate :: html:: sources;
15
16
16
17
/// This enum allows us to store two different kinds of information:
@@ -96,7 +97,7 @@ impl SpanMapVisitor<'_> {
96
97
} )
97
98
. unwrap_or ( path. span )
98
99
} ;
99
- self . matches . insert ( span, link) ;
100
+ self . matches . insert ( span. into ( ) , link) ;
100
101
}
101
102
Res :: Local ( _) if let Some ( span) = self . tcx . hir_res_span ( path. res ) => {
102
103
let path_span = if only_use_last_segment
@@ -106,11 +107,12 @@ impl SpanMapVisitor<'_> {
106
107
} else {
107
108
path. span
108
109
} ;
109
- self . matches . insert ( path_span, LinkFromSrc :: Local ( clean:: Span :: new ( span) ) ) ;
110
+ self . matches . insert ( path_span. into ( ) , LinkFromSrc :: Local ( clean:: Span :: new ( span) ) ) ;
110
111
}
111
112
Res :: PrimTy ( p) => {
112
113
// FIXME: Doesn't handle "path-like" primitives like arrays or tuples.
113
- self . matches . insert ( path. span , LinkFromSrc :: Primitive ( PrimitiveType :: from ( p) ) ) ;
114
+ self . matches
115
+ . insert ( path. span . into ( ) , LinkFromSrc :: Primitive ( PrimitiveType :: from ( p) ) ) ;
114
116
}
115
117
Res :: Err => { }
116
118
_ => { }
@@ -127,7 +129,7 @@ impl SpanMapVisitor<'_> {
127
129
if cspan. inner ( ) . is_dummy ( ) || cspan. cnum ( self . tcx . sess ) != LOCAL_CRATE {
128
130
return ;
129
131
}
130
- self . matches . insert ( span, LinkFromSrc :: Doc ( item. owner_id . to_def_id ( ) ) ) ;
132
+ self . matches . insert ( span. into ( ) , LinkFromSrc :: Doc ( item. owner_id . to_def_id ( ) ) ) ;
131
133
}
132
134
}
133
135
@@ -138,7 +140,7 @@ impl SpanMapVisitor<'_> {
138
140
/// so, we loop until we find the macro definition by using `outer_expn_data` in a loop.
139
141
/// Finally, we get the information about the macro itself (`span` if "local", `DefId`
140
142
/// otherwise) and store it inside the span map.
141
- fn handle_macro ( & mut self , span : Span ) -> bool {
143
+ fn handle_macro ( & mut self , span : rustc_span :: Span ) -> bool {
142
144
if !span. from_expansion ( ) {
143
145
return false ;
144
146
}
@@ -176,7 +178,7 @@ impl SpanMapVisitor<'_> {
176
178
// The "call_site" includes the whole macro with its "arguments". We only want
177
179
// the macro name.
178
180
let new_span = new_span. with_hi ( new_span. lo ( ) + BytePos ( macro_name. len ( ) as u32 ) ) ;
179
- self . matches . insert ( new_span, link_from_src) ;
181
+ self . matches . insert ( new_span. into ( ) , link_from_src) ;
180
182
true
181
183
}
182
184
@@ -233,7 +235,7 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
233
235
intravisit:: walk_path ( self , path) ;
234
236
}
235
237
236
- fn visit_qpath ( & mut self , qpath : & QPath < ' tcx > , id : HirId , _span : Span ) {
238
+ fn visit_qpath ( & mut self , qpath : & QPath < ' tcx > , id : HirId , _span : rustc_span :: Span ) {
237
239
match * qpath {
238
240
QPath :: TypeRelative ( qself, path) => {
239
241
if matches ! ( path. res, Res :: Err ) {
@@ -249,7 +251,7 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
249
251
self . handle_path ( & path, false ) ;
250
252
}
251
253
} else {
252
- self . infer_id ( path. hir_id , Some ( id) , path. ident . span ) ;
254
+ self . infer_id ( path. hir_id , Some ( id) , path. ident . span . into ( ) ) ;
253
255
}
254
256
255
257
rustc_ast:: visit:: try_visit!( self . visit_ty_unambig( qself) ) ;
@@ -267,16 +269,18 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
267
269
}
268
270
}
269
271
270
- fn visit_mod ( & mut self , m : & ' tcx Mod < ' tcx > , span : Span , id : HirId ) {
272
+ fn visit_mod ( & mut self , m : & ' tcx Mod < ' tcx > , span : rustc_span :: Span , id : HirId ) {
271
273
// To make the difference between "mod foo {}" and "mod foo;". In case we "import" another
272
274
// file, we want to link to it. Otherwise no need to create a link.
273
275
if !span. overlaps ( m. spans . inner_span ) {
274
276
// Now that we confirmed it's a file import, we want to get the span for the module
275
277
// name only and not all the "mod foo;".
276
278
if let Node :: Item ( item) = self . tcx . hir_node ( id) {
277
279
let ( ident, _) = item. expect_mod ( ) ;
278
- self . matches
279
- . insert ( ident. span , LinkFromSrc :: Local ( clean:: Span :: new ( m. spans . inner_span ) ) ) ;
280
+ self . matches . insert (
281
+ ident. span . into ( ) ,
282
+ LinkFromSrc :: Local ( clean:: Span :: new ( m. spans . inner_span ) ) ,
283
+ ) ;
280
284
}
281
285
} else {
282
286
// If it's a "mod foo {}", we want to look to its documentation page.
@@ -288,9 +292,9 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
288
292
fn visit_expr ( & mut self , expr : & ' tcx rustc_hir:: Expr < ' tcx > ) {
289
293
match expr. kind {
290
294
ExprKind :: MethodCall ( segment, ..) => {
291
- self . infer_id ( segment. hir_id , Some ( expr. hir_id ) , segment. ident . span )
295
+ self . infer_id ( segment. hir_id , Some ( expr. hir_id ) , segment. ident . span . into ( ) )
292
296
}
293
- ExprKind :: Call ( call, ..) => self . infer_id ( call. hir_id , None , call. span ) ,
297
+ ExprKind :: Call ( call, ..) => self . infer_id ( call. hir_id , None , call. span . into ( ) ) ,
294
298
_ => {
295
299
if self . handle_macro ( expr. span ) {
296
300
// We don't want to go deeper into the macro.
0 commit comments