@@ -22,12 +22,10 @@ use syntax::json::JsonEmitter;
22
22
use syntax:: symbol:: sym;
23
23
use errors;
24
24
use errors:: emitter:: { Emitter , EmitterWriter } ;
25
- use parking_lot:: ReentrantMutex ;
26
25
27
26
use std:: cell:: RefCell ;
28
27
use std:: mem;
29
28
use rustc_data_structures:: sync:: { self , Lrc } ;
30
- use std:: sync:: Arc ;
31
29
use std:: rc:: Rc ;
32
30
33
31
use crate :: config:: { Options as RustdocOptions , RenderOptions } ;
@@ -46,16 +44,14 @@ pub struct DocContext<'tcx> {
46
44
47
45
pub tcx : TyCtxt < ' tcx > ,
48
46
pub resolver : Rc < RefCell < interface:: BoxedResolver > > ,
49
- /// The stack of module NodeIds up till this point
50
- pub crate_name : Option < String > ,
51
47
pub cstore : Lrc < CStore > ,
52
48
/// Later on moved into `html::render::CACHE_KEY`
53
49
pub renderinfo : RefCell < RenderInfo > ,
54
50
/// 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 > > > ,
56
52
/// Used while populating `external_traits` to ensure we don't process the same trait twice at
57
53
/// the same time.
58
- pub active_extern_traits : RefCell < Vec < DefId > > ,
54
+ pub active_extern_traits : RefCell < FxHashSet < DefId > > ,
59
55
// The current set of type and lifetime substitutions,
60
56
// for expanding type aliases at the HIR level:
61
57
@@ -72,7 +68,6 @@ pub struct DocContext<'tcx> {
72
68
/// Auto-trait or blanket impls processed so far, as `(self_ty, trait_def_id)`.
73
69
// FIXME(eddyb) make this a `ty::TraitRef<'tcx>` set.
74
70
pub generated_synthetics : RefCell < FxHashSet < ( Ty < ' tcx > , DefId ) > > ,
75
- pub all_traits : Vec < DefId > ,
76
71
pub auto_traits : Vec < DefId > ,
77
72
}
78
73
@@ -227,7 +222,7 @@ pub fn new_handler(error_format: ErrorOutputType,
227
222
)
228
223
}
229
224
230
- pub fn run_core ( options : RustdocOptions ) -> ( clean:: Crate , RenderInfo , RenderOptions , Vec < String > ) {
225
+ pub fn run_core ( options : RustdocOptions ) -> ( clean:: Crate , RenderInfo , RenderOptions ) {
231
226
// Parse, resolve, and typecheck the given crate.
232
227
233
228
let RustdocOptions {
@@ -332,7 +327,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
332
327
file_loader : None ,
333
328
diagnostic_output : DiagnosticOutput :: Default ,
334
329
stderr : None ,
335
- crate_name : crate_name . clone ( ) ,
330
+ crate_name,
336
331
lint_caps,
337
332
} ;
338
333
@@ -368,11 +363,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
368
363
let mut renderinfo = RenderInfo :: default ( ) ;
369
364
renderinfo. access_levels = access_levels;
370
365
371
- let all_traits = tcx. all_traits ( LOCAL_CRATE ) . to_vec ( ) ;
372
366
let ctxt = DocContext {
373
367
tcx,
374
368
resolver,
375
- crate_name,
376
369
cstore : compiler. cstore ( ) . clone ( ) ,
377
370
external_traits : Default :: default ( ) ,
378
371
active_extern_traits : Default :: default ( ) ,
@@ -384,10 +377,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
384
377
fake_def_ids : Default :: default ( ) ,
385
378
all_fake_def_ids : Default :: default ( ) ,
386
379
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| {
388
381
tcx. trait_is_auto ( * trait_def_id)
389
382
} ) . collect ( ) ,
390
- all_traits,
391
383
} ;
392
384
debug ! ( "crate: {:?}" , tcx. hir( ) . krate( ) ) ;
393
385
@@ -432,8 +424,8 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
432
424
} ,
433
425
_ => continue ,
434
426
} ;
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 ( ) ) ;
437
429
}
438
430
}
439
431
@@ -444,25 +436,26 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
444
436
}
445
437
}
446
438
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
+ } ) ) ;
450
448
451
449
info ! ( "Executing passes" ) ;
452
450
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) ;
461
454
}
462
455
463
456
ctxt. sess ( ) . abort_if_errors ( ) ;
464
457
465
- ( krate, ctxt. renderinfo . into_inner ( ) , render_options, passes )
458
+ ( krate, ctxt. renderinfo . into_inner ( ) , render_options)
466
459
} )
467
460
} )
468
461
}
0 commit comments