@@ -22,12 +22,10 @@ use syntax::json::JsonEmitter;
2222use syntax:: symbol:: sym;
2323use errors;
2424use errors:: emitter:: { Emitter , EmitterWriter } ;
25- use parking_lot:: ReentrantMutex ;
2625
2726use std:: cell:: RefCell ;
2827use std:: mem;
2928use rustc_data_structures:: sync:: { self , Lrc } ;
30- use std:: sync:: Arc ;
3129use std:: rc:: Rc ;
3230
3331use crate :: config:: { Options as RustdocOptions , RenderOptions } ;
@@ -46,16 +44,14 @@ pub struct DocContext<'tcx> {
4644
4745 pub tcx : TyCtxt < ' tcx > ,
4846 pub resolver : Rc < RefCell < interface:: BoxedResolver > > ,
49- /// The stack of module NodeIds up till this point
50- pub crate_name : Option < String > ,
5147 pub cstore : Lrc < CStore > ,
5248 /// Later on moved into `html::render::CACHE_KEY`
5349 pub renderinfo : RefCell < RenderInfo > ,
5450 /// Later on moved through `clean::Crate` into `html::render::CACHE_KEY`
55- pub external_traits : Arc < ReentrantMutex < RefCell < FxHashMap < DefId , clean:: Trait > > > > ,
51+ pub external_traits : Rc < RefCell < FxHashMap < DefId , clean:: Trait > > > ,
5652 /// Used while populating `external_traits` to ensure we don't process the same trait twice at
5753 /// the same time.
58- pub active_extern_traits : RefCell < Vec < DefId > > ,
54+ pub active_extern_traits : RefCell < FxHashSet < DefId > > ,
5955 // The current set of type and lifetime substitutions,
6056 // for expanding type aliases at the HIR level:
6157
@@ -72,7 +68,6 @@ pub struct DocContext<'tcx> {
7268 /// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
7369 // FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set.
7470 pub generated_synthetics : RefCell < FxHashSet < ( Ty < ' tcx > , DefId ) > > ,
75- pub all_traits : Vec < DefId > ,
7671 pub auto_traits : Vec < DefId > ,
7772}
7873
@@ -227,7 +222,7 @@ pub fn new_handler(error_format: ErrorOutputType,
227222 )
228223}
229224
230- pub fn run_core ( options : RustdocOptions ) -> ( clean:: Crate , RenderInfo , RenderOptions , Vec < String > ) {
225+ pub fn run_core ( options : RustdocOptions ) -> ( clean:: Crate , RenderInfo , RenderOptions ) {
231226 // Parse, resolve, and typecheck the given crate.
232227
233228 let RustdocOptions {
@@ -332,7 +327,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
332327 file_loader : None ,
333328 diagnostic_output : DiagnosticOutput :: Default ,
334329 stderr : None ,
335- crate_name : crate_name . clone ( ) ,
330+ crate_name,
336331 lint_caps,
337332 } ;
338333
@@ -368,11 +363,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
368363 let mut renderinfo = RenderInfo :: default ( ) ;
369364 renderinfo. access_levels = access_levels;
370365
371- let all_traits = tcx. all_traits ( LOCAL_CRATE ) . to_vec ( ) ;
372366 let ctxt = DocContext {
373367 tcx,
374368 resolver,
375- crate_name,
376369 cstore : compiler. cstore ( ) . clone ( ) ,
377370 external_traits : Default :: default ( ) ,
378371 active_extern_traits : Default :: default ( ) ,
@@ -384,10 +377,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
384377 fake_def_ids : Default :: default ( ) ,
385378 all_fake_def_ids : Default :: default ( ) ,
386379 generated_synthetics : Default :: default ( ) ,
387- auto_traits : all_traits. iter ( ) . cloned ( ) . filter ( |trait_def_id| {
380+ auto_traits : tcx . all_traits ( LOCAL_CRATE ) . iter ( ) . cloned ( ) . filter ( |trait_def_id| {
388381 tcx. trait_is_auto ( * trait_def_id)
389382 } ) . collect ( ) ,
390- all_traits,
391383 } ;
392384 debug ! ( "crate: {:?}" , tcx. hir( ) . krate( ) ) ;
393385
@@ -432,8 +424,8 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
432424 } ,
433425 _ => continue ,
434426 } ;
435- for p in value. as_str ( ) . split_whitespace ( ) {
436- sink. push ( p . to_string ( ) ) ;
427+ for name in value. as_str ( ) . split_whitespace ( ) {
428+ sink. push ( name . to_string ( ) ) ;
437429 }
438430 }
439431
@@ -444,25 +436,26 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
444436 }
445437 }
446438
447- let mut passes: Vec < String > =
448- passes:: defaults ( default_passes) . iter ( ) . map ( |p| p. to_string ( ) ) . collect ( ) ;
449- passes. extend ( manual_passes) ;
439+ let passes = passes:: defaults ( default_passes) . iter ( ) . chain ( manual_passes. into_iter ( )
440+ . flat_map ( |name| {
441+ if let Some ( pass) = passes:: find_pass ( & name) {
442+ Some ( pass)
443+ } else {
444+ error ! ( "unknown pass {}, skipping" , name) ;
445+ None
446+ }
447+ } ) ) ;
450448
451449 info ! ( "Executing passes" ) ;
452450
453- for pass_name in & passes {
454- match passes:: find_pass ( pass_name) . map ( |p| p. pass ) {
455- Some ( pass) => {
456- debug ! ( "running pass {}" , pass_name) ;
457- krate = pass ( krate, & ctxt) ;
458- }
459- None => error ! ( "unknown pass {}, skipping" , * pass_name) ,
460- }
451+ for pass in passes {
452+ debug ! ( "running pass {}" , pass. name) ;
453+ krate = ( pass. pass ) ( krate, & ctxt) ;
461454 }
462455
463456 ctxt. sess ( ) . abort_if_errors ( ) ;
464457
465- ( krate, ctxt. renderinfo . into_inner ( ) , render_options, passes )
458+ ( krate, ctxt. renderinfo . into_inner ( ) , render_options)
466459 } )
467460 } )
468461}
0 commit comments