@@ -103,7 +103,6 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
103103/// rustdoc tree).
104104#[ derive( Clone ) ]
105105crate struct Context {
106- crate sess : Lrc < Session > ,
107106 /// Current hierarchy of components leading down to what's currently being
108107 /// rendered
109108 crate current : Vec < String > ,
@@ -124,6 +123,7 @@ crate struct Context {
124123}
125124
126125crate struct SharedContext {
126+ crate sess : Lrc < Session > ,
127127 /// The path to the crate root source minus the file name.
128128 /// Used for simplifying paths to the highlighted source code files.
129129 crate src_root : PathBuf ,
@@ -176,6 +176,10 @@ impl Context {
176176 let filename = format ! ( "{}{}.{}" , base, self . shared. resource_suffix, ext, ) ;
177177 self . dst . join ( & filename)
178178 }
179+
180+ fn sess ( & self ) -> & Session {
181+ & self . shared . sess
182+ }
179183}
180184
181185impl SharedContext {
@@ -459,6 +463,7 @@ impl FormatRenderer for Context {
459463 }
460464 let ( sender, receiver) = channel ( ) ;
461465 let mut scx = SharedContext {
466+ sess,
462467 collapsed : krate. collapsed ,
463468 src_root,
464469 include_sources,
@@ -498,7 +503,6 @@ impl FormatRenderer for Context {
498503
499504 let cache = Arc :: new ( cache) ;
500505 let mut cx = Context {
501- sess,
502506 current : Vec :: new ( ) ,
503507 dst,
504508 render_redirect_pages : false ,
@@ -1636,24 +1640,24 @@ impl Context {
16361640 /// of their crate documentation isn't known.
16371641 fn src_href ( & self , item : & clean:: Item , cache : & Cache ) -> Option < String > {
16381642 let mut root = self . root_path ( ) ;
1639-
16401643 let mut path = String :: new ( ) ;
1644+ let cnum = item. source . cnum ( self . sess ( ) ) ;
16411645
16421646 // We can safely ignore synthetic `SourceFile`s.
1643- let file = match item. source . filename {
1647+ let file = match item. source . filename ( self . sess ( ) ) {
16441648 FileName :: Real ( ref path) => path. local_path ( ) . to_path_buf ( ) ,
16451649 _ => return None ,
16461650 } ;
16471651 let file = & file;
16481652
1649- let ( krate, path) = if item . source . cnum == LOCAL_CRATE {
1653+ let ( krate, path) = if cnum == LOCAL_CRATE {
16501654 if let Some ( path) = self . shared . local_sources . get ( file) {
16511655 ( & self . shared . layout . krate , path)
16521656 } else {
16531657 return None ;
16541658 }
16551659 } else {
1656- let ( krate, src_root) = match * cache. extern_locations . get ( & item . source . cnum ) ? {
1660+ let ( krate, src_root) = match * cache. extern_locations . get ( & cnum) ? {
16571661 ( ref name, ref src, ExternalLocation :: Local ) => ( name, src) ,
16581662 ( ref name, ref src, ExternalLocation :: Remote ( ref s) ) => {
16591663 root = s. to_string ( ) ;
@@ -1672,11 +1676,10 @@ impl Context {
16721676 ( krate, & path)
16731677 } ;
16741678
1675- let lines = if item. source . loline == item. source . hiline {
1676- item. source . loline . to_string ( )
1677- } else {
1678- format ! ( "{}-{}" , item. source. loline, item. source. hiline)
1679- } ;
1679+ let loline = item. source . lo ( self . sess ( ) ) . line ;
1680+ let hiline = item. source . hi ( self . sess ( ) ) . line ;
1681+ let lines =
1682+ if loline == hiline { loline. to_string ( ) } else { format ! ( "{}-{}" , loline, hiline) } ;
16801683 Some ( format ! (
16811684 "{root}src/{krate}/{path}#{lines}" ,
16821685 root = Escape ( & root) ,
0 commit comments