File tree 2 files changed +19
-7
lines changed
2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 5
5
//!
6
6
//! Use the `render_with_highlighting` to highlight some rust code.
7
7
8
+ use crate :: clean:: PrimitiveType ;
8
9
use crate :: html:: escape:: Escape ;
9
10
use crate :: html:: render:: Context ;
10
11
@@ -584,6 +585,13 @@ fn string<T: Display>(
584
585
. ok ( )
585
586
. map ( |( url, _, _) | url)
586
587
}
588
+ LinkFromSrc :: Primitive ( prim) => format:: href_with_root_path (
589
+ PrimitiveType :: primitive_locations ( context. tcx ( ) ) [ & prim] ,
590
+ context,
591
+ Some ( context_info. root_path ) ,
592
+ )
593
+ . ok ( )
594
+ . map ( |( url, _, _) | url) ,
587
595
}
588
596
} )
589
597
{
Original file line number Diff line number Diff line change 1
- use crate :: clean;
1
+ use crate :: clean:: { self , PrimitiveType } ;
2
2
use crate :: html:: sources;
3
3
4
4
use rustc_data_structures:: fx:: FxHashMap ;
@@ -22,6 +22,7 @@ use std::path::{Path, PathBuf};
22
22
crate enum LinkFromSrc {
23
23
Local ( clean:: Span ) ,
24
24
External ( DefId ) ,
25
+ Primitive ( PrimitiveType ) ,
25
26
}
26
27
27
28
/// This function will do at most two things:
@@ -73,17 +74,20 @@ impl<'tcx> SpanMapVisitor<'tcx> {
73
74
Some ( def_id)
74
75
}
75
76
Res :: Local ( _) => None ,
77
+ Res :: PrimTy ( p) => {
78
+ // FIXME: Doesn't handle "path-like" primitives like arrays or tuples.
79
+ let span = path_span. unwrap_or ( path. span ) ;
80
+ self . matches . insert ( span, LinkFromSrc :: Primitive ( PrimitiveType :: from ( p) ) ) ;
81
+ return ;
82
+ }
76
83
Res :: Err => return ,
77
84
_ => return ,
78
85
} ;
79
86
if let Some ( span) = self . tcx . hir ( ) . res_span ( path. res ) {
80
- self . matches . insert (
81
- path_span. unwrap_or_else ( || path. span ) ,
82
- LinkFromSrc :: Local ( clean:: Span :: new ( span) ) ,
83
- ) ;
84
- } else if let Some ( def_id) = info {
85
87
self . matches
86
- . insert ( path_span. unwrap_or_else ( || path. span ) , LinkFromSrc :: External ( def_id) ) ;
88
+ . insert ( path_span. unwrap_or ( path. span ) , LinkFromSrc :: Local ( clean:: Span :: new ( span) ) ) ;
89
+ } else if let Some ( def_id) = info {
90
+ self . matches . insert ( path_span. unwrap_or ( path. span ) , LinkFromSrc :: External ( def_id) ) ;
87
91
}
88
92
}
89
93
}
You can’t perform that action at this time.
0 commit comments