Skip to content

Commit c836f95

Browse files
committed
rustdoc: Nuke --passes=list
1 parent 91ab308 commit c836f95

15 files changed

+67
-200
lines changed

src/librustdoc/config.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use crate::externalfiles::ExternalHtml;
2424
use crate::html::markdown::IdMap;
2525
use crate::html::render::StylePath;
2626
use crate::html::static_files;
27-
use crate::passes::{self, Condition};
2827
use crate::scrape_examples::{AllCallLocations, ScrapeExamplesOptions};
2928
use crate::{html, opts, theme};
3029

@@ -421,38 +420,6 @@ impl Options {
421420
// check for deprecated options
422421
check_deprecated_options(matches, dcx);
423422

424-
if matches.opt_strs("passes") == ["list"] {
425-
println!("Available passes for running rustdoc:");
426-
for pass in passes::PASSES {
427-
println!("{:>20} - {}", pass.name, pass.description);
428-
}
429-
println!("\nDefault passes for rustdoc:");
430-
for p in passes::DEFAULT_PASSES {
431-
print!("{:>20}", p.pass.name);
432-
println_condition(p.condition);
433-
}
434-
435-
if nightly_options::match_is_nightly_build(matches) {
436-
println!("\nPasses run with `--show-coverage`:");
437-
for p in passes::COVERAGE_PASSES {
438-
print!("{:>20}", p.pass.name);
439-
println_condition(p.condition);
440-
}
441-
}
442-
443-
fn println_condition(condition: Condition) {
444-
use Condition::*;
445-
match condition {
446-
Always => println!(),
447-
WhenDocumentPrivate => println!(" (when --document-private-items)"),
448-
WhenNotDocumentPrivate => println!(" (when not --document-private-items)"),
449-
WhenNotDocumentHidden => println!(" (when not --document-hidden-items)"),
450-
}
451-
}
452-
453-
return None;
454-
}
455-
456423
let mut emit = FxIndexMap::<_, EmitType>::default();
457424
for list in matches.opt_strs("emit") {
458425
for kind in list.split(',') {

src/librustdoc/passes/calculate_doc_coverage.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
//! Calculates information used for the --show-coverage flag.
1+
//! Calculates information used for the `--show-coverage` flag.
2+
//!
3+
//! More specifically, it counts the number of items with documentation, ones with
4+
//! "examples" (i.e., non-ignored Rust code blocks) and various totals.
25
36
use std::collections::BTreeMap;
47
use std::ops;
@@ -18,11 +21,8 @@ use crate::passes::Pass;
1821
use crate::passes::check_doc_test_visibility::{Tests, should_have_doc_example};
1922
use crate::visit::DocVisitor;
2023

21-
pub(crate) const CALCULATE_DOC_COVERAGE: Pass = Pass {
22-
name: "calculate-doc-coverage",
23-
run: Some(calculate_doc_coverage),
24-
description: "counts the number of items with and without documentation",
25-
};
24+
pub(crate) const CALCULATE_DOC_COVERAGE: Pass =
25+
Pass { name: "calculate-doc-coverage", run: Some(calculate_doc_coverage) };
2626

2727
fn calculate_doc_coverage(krate: clean::Crate, ctx: &mut DocContext<'_>) -> clean::Crate {
2828
let mut calc = CoverageCalculator { items: Default::default(), ctx };

src/librustdoc/passes/check_doc_cfg.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Checks `#[doc(cfg(…))]` for unexpected cfgs wrt. `--check-cfg`.
2+
13
use rustc_hir::HirId;
24
use rustc_hir::def_id::LocalDefId;
35
use rustc_middle::ty::TyCtxt;
@@ -8,11 +10,7 @@ use crate::clean::{Attributes, Crate, Item};
810
use crate::core::DocContext;
911
use crate::visit::DocVisitor;
1012

11-
pub(crate) const CHECK_DOC_CFG: Pass = Pass {
12-
name: "check-doc-cfg",
13-
run: Some(check_doc_cfg),
14-
description: "checks `#[doc(cfg(...))]` for stability feature and unexpected cfgs",
15-
};
13+
pub(crate) const CHECK_DOC_CFG: Pass = Pass { name: "check-doc-cfg", run: Some(check_doc_cfg) };
1614

1715
pub(crate) fn check_doc_cfg(krate: Crate, cx: &mut DocContext<'_>) -> Crate {
1816
let mut checker = DocCfgChecker { cx };

src/librustdoc/passes/check_doc_test_visibility.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ use crate::core::DocContext;
1818
use crate::html::markdown::{ErrorCodes, Ignore, LangString, MdRelLine, find_testable_code};
1919
use crate::visit::DocVisitor;
2020

21-
pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass {
22-
name: "check_doc_test_visibility",
23-
run: Some(check_doc_test_visibility),
24-
description: "run various visibility-related lints on doctests",
25-
};
21+
pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass =
22+
Pass { name: "check_doc_test_visibility", run: Some(check_doc_test_visibility) };
2623

2724
struct DocTestVisibilityLinter<'a, 'tcx> {
2825
cx: &'a mut DocContext<'tcx>,

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! This module implements [RFC 1946]: Intra-rustdoc-links
1+
//! Resolves intra-doc links ([RFC 1946]).
22
//!
3-
//! [RFC 1946]: https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md
3+
//! [RFC 1946]: https://rust-lang.github.io/rfcs/1946-intra-rustdoc-links.html
44
55
use std::borrow::Cow;
66
use std::fmt::Display;
@@ -38,7 +38,7 @@ use crate::passes::Pass;
3838
use crate::visit::DocVisitor;
3939

4040
pub(crate) const COLLECT_INTRA_DOC_LINKS: Pass =
41-
Pass { name: "collect-intra-doc-links", run: None, description: "resolves intra-doc links" };
41+
Pass { name: "collect-intra-doc-links", run: None };
4242

4343
pub(crate) fn collect_intra_doc_links<'a, 'tcx>(
4444
krate: Crate,

src/librustdoc/passes/collect_trait_impls.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
//! Collects trait impls for each item in the crate. For example, if a crate
2-
//! defines a struct that implements a trait, this pass will note that the
3-
//! struct implements that trait.
1+
//! Collects trait impls for each item in the crate.
2+
//!
3+
//! For example, if a crate defines a struct that implements a trait,
4+
//! this pass will note that the struct implements that trait.
45
56
use rustc_data_structures::fx::FxHashSet;
67
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
@@ -14,11 +15,8 @@ use crate::core::DocContext;
1415
use crate::formats::cache::Cache;
1516
use crate::visit::DocVisitor;
1617

17-
pub(crate) const COLLECT_TRAIT_IMPLS: Pass = Pass {
18-
name: "collect-trait-impls",
19-
run: Some(collect_trait_impls),
20-
description: "retrieves trait impls for items in the crate",
21-
};
18+
pub(crate) const COLLECT_TRAIT_IMPLS: Pass =
19+
Pass { name: "collect-trait-impls", run: Some(collect_trait_impls) };
2220

2321
pub(crate) fn collect_trait_impls(mut krate: Crate, cx: &mut DocContext<'_>) -> Crate {
2422
let tcx = cx.tcx;

src/librustdoc/passes/lint.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//! Runs several rustdoc lints, consolidating them into a single pass for
2-
//! efficiency and simplicity.
1+
//! Runs several rustdoc lints, consolidating them into a single pass for efficiency and simplicity.
32
43
mod bare_urls;
54
mod check_code_block_syntax;
@@ -12,8 +11,7 @@ use crate::clean::*;
1211
use crate::core::DocContext;
1312
use crate::visit::DocVisitor;
1413

15-
pub(crate) const RUN_LINTS: Pass =
16-
Pass { name: "run-lints", run: Some(run_lints), description: "runs some of rustdoc's lints" };
14+
pub(crate) const RUN_LINTS: Pass = Pass { name: "run-lints", run: Some(run_lints) };
1715

1816
struct Linter<'a, 'tcx> {
1917
cx: &'a mut DocContext<'tcx>,

src/librustdoc/passes/mod.rs

Lines changed: 25 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,18 @@ use crate::core::DocContext;
88
mod stripper;
99
pub(crate) use stripper::*;
1010

11-
mod strip_aliased_non_local;
12-
pub(crate) use self::strip_aliased_non_local::STRIP_ALIASED_NON_LOCAL;
13-
14-
mod strip_hidden;
15-
pub(crate) use self::strip_hidden::STRIP_HIDDEN;
16-
17-
mod strip_private;
18-
pub(crate) use self::strip_private::STRIP_PRIVATE;
19-
20-
mod strip_priv_imports;
21-
pub(crate) use self::strip_priv_imports::STRIP_PRIV_IMPORTS;
22-
23-
mod propagate_doc_cfg;
24-
pub(crate) use self::propagate_doc_cfg::PROPAGATE_DOC_CFG;
25-
26-
mod propagate_stability;
27-
pub(crate) use self::propagate_stability::PROPAGATE_STABILITY;
28-
29-
pub(crate) mod collect_intra_doc_links;
30-
pub(crate) use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS;
31-
32-
mod check_doc_test_visibility;
33-
pub(crate) use self::check_doc_test_visibility::CHECK_DOC_TEST_VISIBILITY;
34-
11+
mod calculate_doc_coverage;
3512
mod check_doc_cfg;
36-
pub(crate) use self::check_doc_cfg::CHECK_DOC_CFG;
37-
13+
mod check_doc_test_visibility;
14+
pub(crate) mod collect_intra_doc_links;
3815
mod collect_trait_impls;
39-
pub(crate) use self::collect_trait_impls::COLLECT_TRAIT_IMPLS;
40-
41-
mod calculate_doc_coverage;
42-
pub(crate) use self::calculate_doc_coverage::CALCULATE_DOC_COVERAGE;
43-
4416
mod lint;
45-
pub(crate) use self::lint::RUN_LINTS;
17+
mod propagate_doc_cfg;
18+
mod propagate_stability;
19+
mod strip_aliased_non_local;
20+
mod strip_hidden;
21+
mod strip_priv_imports;
22+
mod strip_private;
4623

4724
/// A single pass over the cleaned documentation.
4825
///
@@ -51,7 +28,6 @@ pub(crate) use self::lint::RUN_LINTS;
5128
pub(crate) struct Pass {
5229
pub(crate) name: &'static str,
5330
pub(crate) run: Option<fn(clean::Crate, &mut DocContext<'_>) -> clean::Crate>,
54-
pub(crate) description: &'static str,
5531
}
5632

5733
/// In a list of passes, a pass that may or may not need to be run depending on options.
@@ -73,42 +49,26 @@ pub(crate) enum Condition {
7349
WhenNotDocumentHidden,
7450
}
7551

76-
/// The full list of passes.
77-
pub(crate) const PASSES: &[Pass] = &[
78-
CHECK_DOC_CFG,
79-
CHECK_DOC_TEST_VISIBILITY,
80-
PROPAGATE_DOC_CFG,
81-
STRIP_ALIASED_NON_LOCAL,
82-
STRIP_HIDDEN,
83-
STRIP_PRIVATE,
84-
STRIP_PRIV_IMPORTS,
85-
PROPAGATE_STABILITY,
86-
COLLECT_INTRA_DOC_LINKS,
87-
COLLECT_TRAIT_IMPLS,
88-
CALCULATE_DOC_COVERAGE,
89-
RUN_LINTS,
90-
];
91-
9252
/// The list of passes run by default.
93-
pub(crate) const DEFAULT_PASSES: &[ConditionalPass] = &[
94-
ConditionalPass::always(COLLECT_TRAIT_IMPLS),
95-
ConditionalPass::always(CHECK_DOC_TEST_VISIBILITY),
96-
ConditionalPass::always(CHECK_DOC_CFG),
97-
ConditionalPass::always(STRIP_ALIASED_NON_LOCAL),
98-
ConditionalPass::always(PROPAGATE_DOC_CFG),
99-
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
100-
ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate),
101-
ConditionalPass::new(STRIP_PRIV_IMPORTS, WhenDocumentPrivate),
102-
ConditionalPass::always(COLLECT_INTRA_DOC_LINKS),
103-
ConditionalPass::always(PROPAGATE_STABILITY),
104-
ConditionalPass::always(RUN_LINTS),
53+
const DEFAULT_PASSES: &[ConditionalPass] = &[
54+
ConditionalPass::always(collect_trait_impls::COLLECT_TRAIT_IMPLS),
55+
ConditionalPass::always(check_doc_test_visibility::CHECK_DOC_TEST_VISIBILITY),
56+
ConditionalPass::always(check_doc_cfg::CHECK_DOC_CFG),
57+
ConditionalPass::always(strip_aliased_non_local::STRIP_ALIASED_NON_LOCAL),
58+
ConditionalPass::always(propagate_doc_cfg::PROPAGATE_DOC_CFG),
59+
ConditionalPass::new(strip_hidden::STRIP_HIDDEN, WhenNotDocumentHidden),
60+
ConditionalPass::new(strip_private::STRIP_PRIVATE, WhenNotDocumentPrivate),
61+
ConditionalPass::new(strip_priv_imports::STRIP_PRIV_IMPORTS, WhenDocumentPrivate),
62+
ConditionalPass::always(collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS),
63+
ConditionalPass::always(propagate_stability::PROPAGATE_STABILITY),
64+
ConditionalPass::always(lint::RUN_LINTS),
10565
];
10666

10767
/// The list of default passes run when `--doc-coverage` is passed to rustdoc.
108-
pub(crate) const COVERAGE_PASSES: &[ConditionalPass] = &[
109-
ConditionalPass::new(STRIP_HIDDEN, WhenNotDocumentHidden),
110-
ConditionalPass::new(STRIP_PRIVATE, WhenNotDocumentPrivate),
111-
ConditionalPass::always(CALCULATE_DOC_COVERAGE),
68+
const COVERAGE_PASSES: &[ConditionalPass] = &[
69+
ConditionalPass::new(strip_hidden::STRIP_HIDDEN, WhenNotDocumentHidden),
70+
ConditionalPass::new(strip_private::STRIP_PRIVATE, WhenNotDocumentPrivate),
71+
ConditionalPass::always(calculate_doc_coverage::CALCULATE_DOC_COVERAGE),
11272
];
11373

11474
impl ConditionalPass {

src/librustdoc/passes/propagate_doc_cfg.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
//! Propagates [`#[doc(cfg(...))]`](https://github.com/rust-lang/rust/issues/43781) to child items.
1+
//! Propagates `#[doc(cfg(…))]` ([RFC 3631]) to child items.
2+
//!
3+
//! [RFC 3631]: https://rust-lang.github.io/rfcs/3631-rustdoc-cfgs-handling.html
24
35
use rustc_ast::token::{Token, TokenKind};
46
use rustc_ast::tokenstream::{TokenStream, TokenTree};
@@ -11,11 +13,8 @@ use crate::core::DocContext;
1113
use crate::fold::DocFolder;
1214
use crate::passes::Pass;
1315

14-
pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
15-
name: "propagate-doc-cfg",
16-
run: Some(propagate_doc_cfg),
17-
description: "propagates `#[doc(cfg(...))]` to child items",
18-
};
16+
pub(crate) const PROPAGATE_DOC_CFG: Pass =
17+
Pass { name: "propagate-doc-cfg", run: Some(propagate_doc_cfg) };
1918

2019
pub(crate) fn propagate_doc_cfg(cr: Crate, cx: &mut DocContext<'_>) -> Crate {
2120
if cx.tcx.features().doc_cfg() {

src/librustdoc/passes/propagate_stability.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ use crate::core::DocContext;
1414
use crate::fold::DocFolder;
1515
use crate::passes::Pass;
1616

17-
pub(crate) const PROPAGATE_STABILITY: Pass = Pass {
18-
name: "propagate-stability",
19-
run: Some(propagate_stability),
20-
description: "propagates stability to child items",
21-
};
17+
pub(crate) const PROPAGATE_STABILITY: Pass =
18+
Pass { name: "propagate-stability", run: Some(propagate_stability) };
2219

2320
pub(crate) fn propagate_stability(cr: Crate, cx: &mut DocContext<'_>) -> Crate {
2421
let crate_stability = cx.tcx.lookup_stability(CRATE_DEF_ID);

0 commit comments

Comments
 (0)