@@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt;
11
11
use rustc_session:: Session ;
12
12
use rustc_span:: edition:: Edition ;
13
13
use rustc_span:: source_map:: FileName ;
14
- use rustc_span:: { symbol:: sym, Symbol } ;
14
+ use rustc_span:: symbol:: sym;
15
15
16
16
use super :: cache:: { build_index, ExternalLocation } ;
17
17
use super :: print_item:: { full_path, item_path, print_item} ;
@@ -111,8 +111,6 @@ crate struct SharedContext<'tcx> {
111
111
crate static_root_path : Option < String > ,
112
112
/// The fs handle we are working with.
113
113
crate fs : DocFS ,
114
- /// The default edition used to parse doctests.
115
- crate edition : Edition ,
116
114
pub ( super ) codes : ErrorCodes ,
117
115
pub ( super ) playground : Option < markdown:: Playground > ,
118
116
all : RefCell < AllTypes > ,
@@ -141,6 +139,10 @@ impl SharedContext<'_> {
141
139
crate fn maybe_collapsed_doc_value < ' a > ( & self , item : & ' a clean:: Item ) -> Option < String > {
142
140
if self . collapsed { item. collapsed_doc_value ( ) } else { item. doc_value ( ) }
143
141
}
142
+
143
+ crate fn edition ( & self ) -> Edition {
144
+ self . tcx . sess . edition ( )
145
+ }
144
146
}
145
147
146
148
impl < ' tcx > Context < ' tcx > {
@@ -346,7 +348,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
346
348
fn init (
347
349
mut krate : clean:: Crate ,
348
350
options : RenderOptions ,
349
- edition : Edition ,
350
351
mut cache : Cache ,
351
352
tcx : TyCtxt < ' tcx > ,
352
353
) -> Result < ( Self , clean:: Crate ) , Error > {
@@ -435,7 +436,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
435
436
resource_suffix,
436
437
static_root_path,
437
438
fs : DocFS :: new ( sender) ,
438
- edition,
439
439
codes : ErrorCodes :: from ( unstable_features. is_nightly_build ( ) ) ,
440
440
playground,
441
441
all : RefCell :: new ( AllTypes :: new ( ) ) ,
@@ -494,11 +494,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
494
494
}
495
495
}
496
496
497
- fn after_krate (
498
- & mut self ,
499
- crate_name : Symbol ,
500
- diag : & rustc_errors:: Handler ,
501
- ) -> Result < ( ) , Error > {
497
+ fn after_krate ( & mut self ) -> Result < ( ) , Error > {
498
+ let crate_name = self . tcx ( ) . crate_name ( LOCAL_CRATE ) ;
502
499
let final_file = self . dst . join ( & * crate_name. as_str ( ) ) . join ( "all.html" ) ;
503
500
let settings_file = self . dst . join ( "settings.html" ) ;
504
501
@@ -572,15 +569,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
572
569
573
570
// Flush pending errors.
574
571
Rc :: get_mut ( & mut self . shared ) . unwrap ( ) . fs . close ( ) ;
575
- let nb_errors = self . shared . errors . iter ( ) . map ( |err| diag. struct_err ( & err) . emit ( ) ) . count ( ) ;
572
+ let nb_errors =
573
+ self . shared . errors . iter ( ) . map ( |err| self . tcx ( ) . sess . struct_err ( & err) . emit ( ) ) . count ( ) ;
576
574
if nb_errors > 0 {
577
575
Err ( Error :: new ( io:: Error :: new ( io:: ErrorKind :: Other , "I/O error" ) , "" ) )
578
576
} else {
579
577
Ok ( ( ) )
580
578
}
581
579
}
582
580
583
- fn mod_item_in ( & mut self , item : & clean:: Item , item_name : & str ) -> Result < ( ) , Error > {
581
+ fn mod_item_in ( & mut self , item : & clean:: Item ) -> Result < ( ) , Error > {
584
582
// Stripped modules survive the rustdoc passes (i.e., `strip-private`)
585
583
// if they contain impls for public types. These modules can also
586
584
// contain items such as publicly re-exported structures.
@@ -592,8 +590,9 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
592
590
self . render_redirect_pages = item. is_stripped ( ) ;
593
591
}
594
592
let scx = & self . shared ;
595
- self . dst . push ( item_name) ;
596
- self . current . push ( item_name. to_owned ( ) ) ;
593
+ let item_name = item. name . as_ref ( ) . unwrap ( ) . to_string ( ) ;
594
+ self . dst . push ( & item_name) ;
595
+ self . current . push ( item_name) ;
597
596
598
597
info ! ( "Recursing into {}" , self . dst. display( ) ) ;
599
598
@@ -619,7 +618,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
619
618
Ok ( ( ) )
620
619
}
621
620
622
- fn mod_item_out ( & mut self , _item_name : & str ) -> Result < ( ) , Error > {
621
+ fn mod_item_out ( & mut self ) -> Result < ( ) , Error > {
623
622
info ! ( "Recursed; leaving {}" , self . dst. display( ) ) ;
624
623
625
624
// Go back to where we were at
0 commit comments