@@ -410,7 +410,7 @@ pub fn run_core(
410
410
let body = hir. body ( hir. body_owned_by ( hir. local_def_id_to_hir_id ( def_id) ) ) ;
411
411
debug ! ( "visiting body for {:?}" , def_id) ;
412
412
tcx. sess . time ( "emit_ignored_resolution_errors" , || {
413
- EmitIgnoredResolutionErrors :: new ( tcx) . visit_body ( body) ;
413
+ EmitIgnoredResolutionErrors :: new ( tcx) . visit_body ( body) ;
414
414
} ) ;
415
415
( rustc_interface:: DEFAULT_QUERY_PROVIDERS . typeck ) ( tcx, def_id)
416
416
} ;
@@ -434,19 +434,19 @@ pub fn run_core(
434
434
// intra-doc-links
435
435
resolver. borrow_mut ( ) . access ( |resolver| {
436
436
sess. time ( "load_extern_crates" , || {
437
- for extern_name in & extern_names {
438
- resolver
439
- . resolve_str_path_error (
440
- DUMMY_SP ,
441
- extern_name,
442
- TypeNS ,
443
- LocalDefId { local_def_index : CRATE_DEF_INDEX } . to_def_id ( ) ,
444
- )
445
- . unwrap_or_else ( |( ) | {
446
- panic ! ( "Unable to resolve external crate {}" , extern_name)
447
- } ) ;
448
- }
449
- } ) ;
437
+ for extern_name in & extern_names {
438
+ resolver
439
+ . resolve_str_path_error (
440
+ DUMMY_SP ,
441
+ extern_name,
442
+ TypeNS ,
443
+ LocalDefId { local_def_index : CRATE_DEF_INDEX } . to_def_id ( ) ,
444
+ )
445
+ . unwrap_or_else ( |( ) | {
446
+ panic ! ( "Unable to resolve external crate {}" , extern_name)
447
+ } ) ;
448
+ }
449
+ } ) ;
450
450
} ) ;
451
451
452
452
// Now we're good to clone the resolver because everything should be loaded
@@ -484,176 +484,176 @@ fn run_global_ctxt(
484
484
render_options : RenderOptions ,
485
485
output_format : Option < OutputFormat > ,
486
486
) -> ( clean:: Crate , RenderInfo , RenderOptions ) {
487
- // Certain queries assume that some checks were run elsewhere
488
- // (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425),
489
- // so type-check everything other than function bodies in this crate before running lints.
490
-
491
- // NOTE: this does not call `tcx.analysis()` so that we won't
492
- // typeck function bodies or run the default rustc lints.
493
- // (see `override_queries` in the `config`)
494
-
495
- // HACK(jynelson) this calls an _extremely_ limited subset of `typeck`
496
- // and might break if queries change their assumptions in the future.
497
-
498
- // NOTE: This is copy/pasted from typeck/lib.rs and should be kept in sync with those changes.
499
- tcx. sess . time ( "item_types_checking" , || {
500
- for & module in tcx. hir ( ) . krate ( ) . modules . keys ( ) {
501
- tcx. ensure ( ) . check_mod_item_types ( tcx. hir ( ) . local_def_id ( module) ) ;
502
- }
503
- } ) ;
504
- tcx. sess . abort_if_errors ( ) ;
487
+ // Certain queries assume that some checks were run elsewhere
488
+ // (see https://github.com/rust-lang/rust/pull/73566#issuecomment-656954425),
489
+ // so type-check everything other than function bodies in this crate before running lints.
490
+
491
+ // NOTE: this does not call `tcx.analysis()` so that we won't
492
+ // typeck function bodies or run the default rustc lints.
493
+ // (see `override_queries` in the `config`)
494
+
495
+ // HACK(jynelson) this calls an _extremely_ limited subset of `typeck`
496
+ // and might break if queries change their assumptions in the future.
497
+
498
+ // NOTE: This is copy/pasted from typeck/lib.rs and should be kept in sync with those changes.
499
+ tcx. sess . time ( "item_types_checking" , || {
500
+ for & module in tcx. hir ( ) . krate ( ) . modules . keys ( ) {
501
+ tcx. ensure ( ) . check_mod_item_types ( tcx. hir ( ) . local_def_id ( module) ) ;
502
+ }
503
+ } ) ;
504
+ tcx. sess . abort_if_errors ( ) ;
505
505
tcx. sess . time ( "missing_docs" , || {
506
- rustc_lint:: check_crate ( tcx, rustc_lint:: builtin:: MissingDoc :: new) ;
507
- } ) ;
506
+ rustc_lint:: check_crate ( tcx, rustc_lint:: builtin:: MissingDoc :: new) ;
507
+ } ) ;
508
508
tcx. sess . time ( "check_mod_attrs" , || {
509
- for & module in tcx. hir ( ) . krate ( ) . modules . keys ( ) {
510
- let local_def_id = tcx. hir ( ) . local_def_id ( module) ;
511
- tcx. ensure ( ) . check_mod_attrs ( local_def_id) ;
512
- }
509
+ for & module in tcx. hir ( ) . krate ( ) . modules . keys ( ) {
510
+ let local_def_id = tcx. hir ( ) . local_def_id ( module) ;
511
+ tcx. ensure ( ) . check_mod_attrs ( local_def_id) ;
512
+ }
513
513
} ) ;
514
514
515
- let access_levels = tcx. privacy_access_levels ( LOCAL_CRATE ) ;
516
- // Convert from a HirId set to a DefId set since we don't always have easy access
517
- // to the map from defid -> hirid
518
- let access_levels = AccessLevels {
519
- map : access_levels
520
- . map
521
- . iter ( )
522
- . map ( |( & k, & v) | ( tcx. hir ( ) . local_def_id ( k) . to_def_id ( ) , v) )
523
- . collect ( ) ,
524
- } ;
525
-
526
- let mut renderinfo = RenderInfo :: default ( ) ;
527
- renderinfo. access_levels = access_levels;
528
- renderinfo. output_format = output_format;
529
-
530
- let mut ctxt = DocContext {
531
- tcx,
532
- resolver,
533
- external_traits : Default :: default ( ) ,
534
- active_extern_traits : Default :: default ( ) ,
535
- renderinfo : RefCell :: new ( renderinfo) ,
536
- ty_substs : Default :: default ( ) ,
537
- lt_substs : Default :: default ( ) ,
538
- ct_substs : Default :: default ( ) ,
539
- impl_trait_bounds : Default :: default ( ) ,
540
- fake_def_ids : Default :: default ( ) ,
541
- all_fake_def_ids : Default :: default ( ) ,
542
- generated_synthetics : Default :: default ( ) ,
543
- auto_traits : tcx
544
- . all_traits ( LOCAL_CRATE )
545
- . iter ( )
546
- . cloned ( )
547
- . filter ( |trait_def_id| tcx. trait_is_auto ( * trait_def_id) )
548
- . collect ( ) ,
549
- render_options,
550
- module_trait_cache : RefCell :: new ( FxHashMap :: default ( ) ) ,
551
- } ;
552
- debug ! ( "crate: {:?}" , tcx. hir( ) . krate( ) ) ;
515
+ let access_levels = tcx. privacy_access_levels ( LOCAL_CRATE ) ;
516
+ // Convert from a HirId set to a DefId set since we don't always have easy access
517
+ // to the map from defid -> hirid
518
+ let access_levels = AccessLevels {
519
+ map : access_levels
520
+ . map
521
+ . iter ( )
522
+ . map ( |( & k, & v) | ( tcx. hir ( ) . local_def_id ( k) . to_def_id ( ) , v) )
523
+ . collect ( ) ,
524
+ } ;
525
+
526
+ let mut renderinfo = RenderInfo :: default ( ) ;
527
+ renderinfo. access_levels = access_levels;
528
+ renderinfo. output_format = output_format;
529
+
530
+ let mut ctxt = DocContext {
531
+ tcx,
532
+ resolver,
533
+ external_traits : Default :: default ( ) ,
534
+ active_extern_traits : Default :: default ( ) ,
535
+ renderinfo : RefCell :: new ( renderinfo) ,
536
+ ty_substs : Default :: default ( ) ,
537
+ lt_substs : Default :: default ( ) ,
538
+ ct_substs : Default :: default ( ) ,
539
+ impl_trait_bounds : Default :: default ( ) ,
540
+ fake_def_ids : Default :: default ( ) ,
541
+ all_fake_def_ids : Default :: default ( ) ,
542
+ generated_synthetics : Default :: default ( ) ,
543
+ auto_traits : tcx
544
+ . all_traits ( LOCAL_CRATE )
545
+ . iter ( )
546
+ . cloned ( )
547
+ . filter ( |trait_def_id| tcx. trait_is_auto ( * trait_def_id) )
548
+ . collect ( ) ,
549
+ render_options,
550
+ module_trait_cache : RefCell :: new ( FxHashMap :: default ( ) ) ,
551
+ } ;
552
+ debug ! ( "crate: {:?}" , tcx. hir( ) . krate( ) ) ;
553
553
554
554
let mut krate = tcx. sess . time ( "clean_crate" , || clean:: krate ( & mut ctxt) ) ;
555
555
556
- if let Some ( ref m) = krate. module {
557
- if let None | Some ( "" ) = m. doc_value ( ) {
558
- let help = "The following guide may be of use:\n \
559
- https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation\
560
- .html";
561
- tcx. struct_lint_node (
562
- rustc_lint:: builtin:: MISSING_CRATE_LEVEL_DOCS ,
563
- ctxt. as_local_hir_id ( m. def_id ) . unwrap ( ) ,
564
- |lint| {
556
+ if let Some ( ref m) = krate. module {
557
+ if let None | Some ( "" ) = m. doc_value ( ) {
558
+ let help = "The following guide may be of use:\n \
559
+ https://doc.rust-lang.org/nightly/rustdoc/how-to-write-documentation\
560
+ .html";
561
+ tcx. struct_lint_node (
562
+ rustc_lint:: builtin:: MISSING_CRATE_LEVEL_DOCS ,
563
+ ctxt. as_local_hir_id ( m. def_id ) . unwrap ( ) ,
564
+ |lint| {
565
565
let mut diag =
566
566
lint. build ( "no documentation found for this crate's top-level module" ) ;
567
- diag. help ( help) ;
568
- diag. emit ( ) ;
569
- } ,
570
- ) ;
571
- }
572
- }
567
+ diag. help ( help) ;
568
+ diag. emit ( ) ;
569
+ } ,
570
+ ) ;
571
+ }
572
+ }
573
573
574
- fn report_deprecated_attr ( name : & str , diag : & rustc_errors:: Handler ) {
574
+ fn report_deprecated_attr ( name : & str , diag : & rustc_errors:: Handler ) {
575
575
let mut msg = diag
576
576
. struct_warn ( & format ! ( "the `#![doc({})]` attribute is considered deprecated" , name) ) ;
577
- msg. warn (
578
- "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
579
- for more information",
580
- ) ;
577
+ msg. warn (
578
+ "see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
579
+ for more information",
580
+ ) ;
581
+
582
+ if name == "no_default_passes" {
583
+ msg. help ( "you may want to use `#![doc(document_private_items)]`" ) ;
584
+ }
581
585
582
- if name == "no_default_passes" {
583
- msg. help ( "you may want to use `#![doc(document_private_items)]`" ) ;
584
- }
586
+ msg. emit ( ) ;
587
+ }
585
588
586
- msg. emit ( ) ;
589
+ // Process all of the crate attributes, extracting plugin metadata along
590
+ // with the passes which we are supposed to run.
591
+ for attr in krate. module . as_ref ( ) . unwrap ( ) . attrs . lists ( sym:: doc) {
592
+ let diag = ctxt. sess ( ) . diagnostic ( ) ;
593
+
594
+ let name = attr. name_or_empty ( ) ;
595
+ if attr. is_word ( ) {
596
+ if name == sym:: no_default_passes {
597
+ report_deprecated_attr ( "no_default_passes" , diag) ;
598
+ if default_passes == passes:: DefaultPassOption :: Default {
599
+ default_passes = passes:: DefaultPassOption :: None ;
600
+ }
601
+ }
602
+ } else if let Some ( value) = attr. value_str ( ) {
603
+ let sink = match name {
604
+ sym:: passes => {
605
+ report_deprecated_attr ( "passes = \" ...\" " , diag) ;
606
+ & mut manual_passes
607
+ }
608
+ sym:: plugins => {
609
+ report_deprecated_attr ( "plugins = \" ...\" " , diag) ;
610
+ eprintln ! (
611
+ "WARNING: `#![doc(plugins = \" ...\" )]` \
612
+ no longer functions; see CVE-2018-1000622"
613
+ ) ;
614
+ continue ;
587
615
}
616
+ _ => continue ,
617
+ } ;
618
+ for name in value. as_str ( ) . split_whitespace ( ) {
619
+ sink. push ( name. to_string ( ) ) ;
620
+ }
621
+ }
588
622
589
- // Process all of the crate attributes, extracting plugin metadata along
590
- // with the passes which we are supposed to run.
591
- for attr in krate. module . as_ref ( ) . unwrap ( ) . attrs . lists ( sym:: doc) {
592
- let diag = ctxt. sess ( ) . diagnostic ( ) ;
593
-
594
- let name = attr. name_or_empty ( ) ;
595
- if attr. is_word ( ) {
596
- if name == sym:: no_default_passes {
597
- report_deprecated_attr ( "no_default_passes" , diag) ;
598
- if default_passes == passes:: DefaultPassOption :: Default {
599
- default_passes = passes:: DefaultPassOption :: None ;
600
- }
601
- }
602
- } else if let Some ( value) = attr. value_str ( ) {
603
- let sink = match name {
604
- sym:: passes => {
605
- report_deprecated_attr ( "passes = \" ...\" " , diag) ;
606
- & mut manual_passes
607
- }
608
- sym:: plugins => {
609
- report_deprecated_attr ( "plugins = \" ...\" " , diag) ;
610
- eprintln ! (
611
- "WARNING: `#![doc(plugins = \" ...\" )]` \
612
- no longer functions; see CVE-2018-1000622"
613
- ) ;
614
- continue ;
615
- }
616
- _ => continue ,
617
- } ;
618
- for name in value. as_str ( ) . split_whitespace ( ) {
619
- sink. push ( name. to_string ( ) ) ;
620
- }
621
- }
623
+ if attr. is_word ( ) && name == sym:: document_private_items {
624
+ ctxt. render_options . document_private = true ;
625
+ }
626
+ }
622
627
623
- if attr. is_word ( ) && name == sym:: document_private_items {
624
- ctxt. render_options . document_private = true ;
625
- }
626
- }
628
+ let passes = passes:: defaults ( default_passes) . iter ( ) . copied ( ) . chain (
629
+ manual_passes. into_iter ( ) . flat_map ( |name| {
630
+ if let Some ( pass) = passes:: find_pass ( & name) {
631
+ Some ( ConditionalPass :: always ( pass) )
632
+ } else {
633
+ error ! ( "unknown pass {}, skipping" , name) ;
634
+ None
635
+ }
636
+ } ) ,
637
+ ) ;
627
638
628
- let passes = passes:: defaults ( default_passes) . iter ( ) . copied ( ) . chain (
629
- manual_passes. into_iter ( ) . flat_map ( |name| {
630
- if let Some ( pass) = passes:: find_pass ( & name) {
631
- Some ( ConditionalPass :: always ( pass) )
632
- } else {
633
- error ! ( "unknown pass {}, skipping" , name) ;
634
- None
635
- }
636
- } ) ,
637
- ) ;
638
-
639
- info ! ( "Executing passes" ) ;
640
-
641
- for p in passes {
642
- let run = match p. condition {
643
- Always => true ,
644
- WhenDocumentPrivate => ctxt. render_options . document_private ,
645
- WhenNotDocumentPrivate => !ctxt. render_options . document_private ,
646
- WhenNotDocumentHidden => !ctxt. render_options . document_hidden ,
647
- } ;
648
- if run {
649
- debug ! ( "running pass {}" , p. pass. name) ;
650
- krate = ctxt. tcx . sess . time ( p. pass . name , || ( p. pass . run ) ( krate, & ctxt) ) ;
651
- }
652
- }
639
+ info ! ( "Executing passes" ) ;
640
+
641
+ for p in passes {
642
+ let run = match p. condition {
643
+ Always => true ,
644
+ WhenDocumentPrivate => ctxt. render_options . document_private ,
645
+ WhenNotDocumentPrivate => !ctxt. render_options . document_private ,
646
+ WhenNotDocumentHidden => !ctxt. render_options . document_hidden ,
647
+ } ;
648
+ if run {
649
+ debug ! ( "running pass {}" , p. pass. name) ;
650
+ krate = ctxt. tcx . sess . time ( p. pass . name , || ( p. pass . run ) ( krate, & ctxt) ) ;
651
+ }
652
+ }
653
653
654
- ctxt. sess ( ) . abort_if_errors ( ) ;
654
+ ctxt. sess ( ) . abort_if_errors ( ) ;
655
655
656
- ( krate, ctxt. renderinfo . into_inner ( ) , ctxt. render_options )
656
+ ( krate, ctxt. renderinfo . into_inner ( ) , ctxt. render_options )
657
657
}
658
658
659
659
/// Due to https://github.com/rust-lang/rust/pull/73566,
0 commit comments