@@ -11,7 +11,7 @@ use rustc_middle::ty::TyCtxt;
1111use rustc_session:: Session ;
1212use rustc_span:: edition:: Edition ;
1313use rustc_span:: source_map:: FileName ;
14- use rustc_span:: { symbol:: sym, Symbol } ;
14+ use rustc_span:: symbol:: sym;
1515
1616use super :: cache:: { build_index, ExternalLocation } ;
1717use super :: print_item:: { full_path, item_path, print_item} ;
@@ -111,8 +111,6 @@ crate struct SharedContext<'tcx> {
111111 crate static_root_path : Option < String > ,
112112 /// The fs handle we are working with.
113113 crate fs : DocFS ,
114- /// The default edition used to parse doctests.
115- crate edition : Edition ,
116114 pub ( super ) codes : ErrorCodes ,
117115 pub ( super ) playground : Option < markdown:: Playground > ,
118116 all : RefCell < AllTypes > ,
@@ -141,6 +139,10 @@ impl SharedContext<'_> {
141139 crate fn maybe_collapsed_doc_value < ' a > ( & self , item : & ' a clean:: Item ) -> Option < String > {
142140 if self . collapsed { item. collapsed_doc_value ( ) } else { item. doc_value ( ) }
143141 }
142+
143+ crate fn edition ( & self ) -> Edition {
144+ self . tcx . sess . edition ( )
145+ }
144146}
145147
146148impl < ' tcx > Context < ' tcx > {
@@ -346,7 +348,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
346348 fn init (
347349 mut krate : clean:: Crate ,
348350 options : RenderOptions ,
349- edition : Edition ,
350351 mut cache : Cache ,
351352 tcx : TyCtxt < ' tcx > ,
352353 ) -> Result < ( Self , clean:: Crate ) , Error > {
@@ -435,7 +436,6 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
435436 resource_suffix,
436437 static_root_path,
437438 fs : DocFS :: new ( sender) ,
438- edition,
439439 codes : ErrorCodes :: from ( unstable_features. is_nightly_build ( ) ) ,
440440 playground,
441441 all : RefCell :: new ( AllTypes :: new ( ) ) ,
@@ -494,11 +494,8 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
494494 }
495495 }
496496
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 ) ;
502499 let final_file = self . dst . join ( & * crate_name. as_str ( ) ) . join ( "all.html" ) ;
503500 let settings_file = self . dst . join ( "settings.html" ) ;
504501
@@ -572,15 +569,16 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
572569
573570 // Flush pending errors.
574571 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 ( ) ;
576574 if nb_errors > 0 {
577575 Err ( Error :: new ( io:: Error :: new ( io:: ErrorKind :: Other , "I/O error" ) , "" ) )
578576 } else {
579577 Ok ( ( ) )
580578 }
581579 }
582580
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 > {
584582 // Stripped modules survive the rustdoc passes (i.e., `strip-private`)
585583 // if they contain impls for public types. These modules can also
586584 // contain items such as publicly re-exported structures.
@@ -592,8 +590,9 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
592590 self . render_redirect_pages = item. is_stripped ( ) ;
593591 }
594592 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) ;
597596
598597 info ! ( "Recursing into {}" , self . dst. display( ) ) ;
599598
@@ -619,7 +618,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
619618 Ok ( ( ) )
620619 }
621620
622- fn mod_item_out ( & mut self , _item_name : & str ) -> Result < ( ) , Error > {
621+ fn mod_item_out ( & mut self ) -> Result < ( ) , Error > {
623622 info ! ( "Recursed; leaving {}" , self . dst. display( ) ) ;
624623
625624 // Go back to where we were at
0 commit comments