File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 55//!
66//! Use the `render_with_highlighting` to highlight some rust code.
77
8+ use crate :: clean:: PrimitiveType ;
89use crate :: html:: escape:: Escape ;
910use crate :: html:: render:: Context ;
1011
@@ -584,6 +585,13 @@ fn string<T: Display>(
584585 . ok ( )
585586 . map ( |( url, _, _) | url)
586587 }
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) ,
587595 }
588596 } )
589597 {
Original file line number Diff line number Diff line change 1- use crate :: clean;
1+ use crate :: clean:: { self , PrimitiveType } ;
22use crate :: html:: sources;
33
44use rustc_data_structures:: fx:: FxHashMap ;
@@ -22,6 +22,7 @@ use std::path::{Path, PathBuf};
2222crate enum LinkFromSrc {
2323 Local ( clean:: Span ) ,
2424 External ( DefId ) ,
25+ Primitive ( PrimitiveType ) ,
2526}
2627
2728/// This function will do at most two things:
@@ -73,17 +74,20 @@ impl<'tcx> SpanMapVisitor<'tcx> {
7374 Some ( def_id)
7475 }
7576 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+ }
7683 Res :: Err => return ,
7784 _ => return ,
7885 } ;
7986 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 {
8587 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) ) ;
8791 }
8892 }
8993}
You can’t perform that action at this time.
0 commit comments