@@ -103,7 +103,6 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ {
103
103
/// rustdoc tree).
104
104
#[ derive( Clone ) ]
105
105
crate struct Context {
106
- crate sess : Lrc < Session > ,
107
106
/// Current hierarchy of components leading down to what's currently being
108
107
/// rendered
109
108
crate current : Vec < String > ,
@@ -124,6 +123,7 @@ crate struct Context {
124
123
}
125
124
126
125
crate struct SharedContext {
126
+ crate sess : Lrc < Session > ,
127
127
/// The path to the crate root source minus the file name.
128
128
/// Used for simplifying paths to the highlighted source code files.
129
129
crate src_root : PathBuf ,
@@ -176,6 +176,10 @@ impl Context {
176
176
let filename = format ! ( "{}{}.{}" , base, self . shared. resource_suffix, ext, ) ;
177
177
self . dst . join ( & filename)
178
178
}
179
+
180
+ fn sess ( & self ) -> & Session {
181
+ & self . shared . sess
182
+ }
179
183
}
180
184
181
185
impl SharedContext {
@@ -459,6 +463,7 @@ impl FormatRenderer for Context {
459
463
}
460
464
let ( sender, receiver) = channel ( ) ;
461
465
let mut scx = SharedContext {
466
+ sess,
462
467
collapsed : krate. collapsed ,
463
468
src_root,
464
469
include_sources,
@@ -498,7 +503,6 @@ impl FormatRenderer for Context {
498
503
499
504
let cache = Arc :: new ( cache) ;
500
505
let mut cx = Context {
501
- sess,
502
506
current : Vec :: new ( ) ,
503
507
dst,
504
508
render_redirect_pages : false ,
@@ -1636,24 +1640,24 @@ impl Context {
1636
1640
/// of their crate documentation isn't known.
1637
1641
fn src_href ( & self , item : & clean:: Item , cache : & Cache ) -> Option < String > {
1638
1642
let mut root = self . root_path ( ) ;
1639
-
1640
1643
let mut path = String :: new ( ) ;
1644
+ let cnum = item. source . cnum ( self . sess ( ) ) ;
1641
1645
1642
1646
// We can safely ignore synthetic `SourceFile`s.
1643
- let file = match item. source . filename {
1647
+ let file = match item. source . filename ( self . sess ( ) ) {
1644
1648
FileName :: Real ( ref path) => path. local_path ( ) . to_path_buf ( ) ,
1645
1649
_ => return None ,
1646
1650
} ;
1647
1651
let file = & file;
1648
1652
1649
- let ( krate, path) = if item . source . cnum == LOCAL_CRATE {
1653
+ let ( krate, path) = if cnum == LOCAL_CRATE {
1650
1654
if let Some ( path) = self . shared . local_sources . get ( file) {
1651
1655
( & self . shared . layout . krate , path)
1652
1656
} else {
1653
1657
return None ;
1654
1658
}
1655
1659
} 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) ? {
1657
1661
( ref name, ref src, ExternalLocation :: Local ) => ( name, src) ,
1658
1662
( ref name, ref src, ExternalLocation :: Remote ( ref s) ) => {
1659
1663
root = s. to_string ( ) ;
@@ -1672,11 +1676,10 @@ impl Context {
1672
1676
( krate, & path)
1673
1677
} ;
1674
1678
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) } ;
1680
1683
Some ( format ! (
1681
1684
"{root}src/{krate}/{path}#{lines}" ,
1682
1685
root = Escape ( & root) ,
0 commit comments