Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 73c7873

Browse files
committedAug 5, 2018
Auto merge of #52800 - QuietMisdreavus:do-not-pass-go, r=GuillaumeGomez
rustdoc: refactor how passes are structured, and turn intra-doc-link collection into a pass This builds on #52751 and should not be merged until that finally finishes the bors queue Part 2 of my passes refactor. This introduces the concept of an "early pass", which is run right before exiting the compiler context. This is important for passes that may want to ask the compiler about things. For example, i took out the intra-doc-link collection and turned it into a early pass. I also made the `strip-hidden`, `strip-private` and `strip-priv-imports` passes occur as early passes, so that intra-doc-link collection wouldn't run on docs that weren't getting printed. Fixes #51684, technically #51468 too but that version of `h2` hits a legit intra-link error after that `>_>` r? @rust-lang/rustdoc
2 parents 93a4cab + e332985 commit 73c7873

File tree

15 files changed

+899
-672
lines changed

15 files changed

+899
-672
lines changed
 

‎src/librustdoc/clean/mod.rs

Lines changed: 13 additions & 551 deletions
Large diffs are not rendered by default.

‎src/librustdoc/core.rs

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use rustc_metadata::creader::CrateLoader;
2626
use rustc_metadata::cstore::CStore;
2727
use rustc_target::spec::TargetTriple;
2828

29-
use syntax::ast::{self, Ident, Name, NodeId};
29+
use syntax::ast::{self, Ident};
3030
use syntax::codemap;
3131
use syntax::edition::Edition;
3232
use syntax::feature_gate::UnstableFeatures;
@@ -45,8 +45,9 @@ use std::path::PathBuf;
4545

4646
use visit_ast::RustdocVisitor;
4747
use clean;
48-
use clean::{get_path_for_type, Clean, MAX_DEF_ID};
48+
use clean::{get_path_for_type, Clean, MAX_DEF_ID, AttributesExt};
4949
use html::render::RenderInfo;
50+
use passes;
5051

5152
pub use rustc::session::config::{Input, Options, CodegenOptions};
5253
pub use rustc::session::search_paths::SearchPaths;
@@ -57,7 +58,6 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> {
5758
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
5859
pub resolver: &'a RefCell<resolve::Resolver<'rcx, 'cstore>>,
5960
/// The stack of module NodeIds up till this point
60-
pub mod_ids: RefCell<Vec<NodeId>>,
6161
pub crate_name: Option<String>,
6262
pub cstore: Rc<CStore>,
6363
pub populated_all_crate_impls: Cell<bool>,
@@ -87,7 +87,6 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a, 'cstore: 'rcx> {
8787
pub all_fake_def_ids: RefCell<FxHashSet<DefId>>,
8888
/// Maps (type_id, trait_id) -> auto trait impl
8989
pub generated_synthetics: RefCell<FxHashSet<(DefId, DefId)>>,
90-
pub current_item_name: RefCell<Option<Name>>,
9190
pub all_traits: Vec<DefId>,
9291
}
9392

@@ -322,7 +321,10 @@ pub fn run_core(search_paths: SearchPaths,
322321
error_format: ErrorOutputType,
323322
cmd_lints: Vec<(String, lint::Level)>,
324323
lint_cap: Option<lint::Level>,
325-
describe_lints: bool) -> (clean::Crate, RenderInfo)
324+
describe_lints: bool,
325+
mut manual_passes: Vec<String>,
326+
mut default_passes: passes::DefaultPassOption)
327+
-> (clean::Crate, RenderInfo, Vec<String>)
326328
{
327329
// Parse, resolve, and typecheck the given crate.
328330

@@ -517,23 +519,86 @@ pub fn run_core(search_paths: SearchPaths,
517519
ty_substs: Default::default(),
518520
lt_substs: Default::default(),
519521
impl_trait_bounds: Default::default(),
520-
mod_ids: Default::default(),
521522
send_trait: send_trait,
522523
fake_def_ids: RefCell::new(FxHashMap()),
523524
all_fake_def_ids: RefCell::new(FxHashSet()),
524525
generated_synthetics: RefCell::new(FxHashSet()),
525-
current_item_name: RefCell::new(None),
526526
all_traits: tcx.all_traits(LOCAL_CRATE).to_vec(),
527527
};
528528
debug!("crate: {:?}", tcx.hir.krate());
529529

530-
let krate = {
530+
let mut krate = {
531531
let mut v = RustdocVisitor::new(&ctxt);
532532
v.visit(tcx.hir.krate());
533533
v.clean(&ctxt)
534534
};
535535

536-
(krate, ctxt.renderinfo.into_inner())
536+
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
537+
let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
538+
considered deprecated", name));
539+
msg.warn("please see https://github.com/rust-lang/rust/issues/44136");
540+
541+
if name == "no_default_passes" {
542+
msg.help("you may want to use `#![doc(document_private_items)]`");
543+
}
544+
545+
msg.emit();
546+
}
547+
548+
// Process all of the crate attributes, extracting plugin metadata along
549+
// with the passes which we are supposed to run.
550+
for attr in krate.module.as_ref().unwrap().attrs.lists("doc") {
551+
let diag = ctxt.sess().diagnostic();
552+
553+
let name = attr.name().map(|s| s.as_str());
554+
let name = name.as_ref().map(|s| &s[..]);
555+
if attr.is_word() {
556+
if name == Some("no_default_passes") {
557+
report_deprecated_attr("no_default_passes", diag);
558+
if default_passes == passes::DefaultPassOption::Default {
559+
default_passes = passes::DefaultPassOption::None;
560+
}
561+
}
562+
} else if let Some(value) = attr.value_str() {
563+
let sink = match name {
564+
Some("passes") => {
565+
report_deprecated_attr("passes = \"...\"", diag);
566+
&mut manual_passes
567+
},
568+
Some("plugins") => {
569+
report_deprecated_attr("plugins = \"...\"", diag);
570+
eprintln!("WARNING: #![doc(plugins = \"...\")] no longer functions; \
571+
see CVE-2018-1000622");
572+
continue
573+
},
574+
_ => continue,
575+
};
576+
for p in value.as_str().split_whitespace() {
577+
sink.push(p.to_string());
578+
}
579+
}
580+
581+
if attr.is_word() && name == Some("document_private_items") {
582+
if default_passes == passes::DefaultPassOption::Default {
583+
default_passes = passes::DefaultPassOption::Private;
584+
}
585+
}
586+
}
587+
588+
let mut passes: Vec<String> =
589+
passes::defaults(default_passes).iter().map(|p| p.to_string()).collect();
590+
passes.extend(manual_passes);
591+
592+
for pass in &passes {
593+
// the "unknown pass" error will be reported when late passes are run
594+
if let Some(pass) = passes::find_pass(pass).and_then(|p| p.early_fn()) {
595+
krate = pass(krate, &ctxt);
596+
}
597+
}
598+
599+
ctxt.sess().abort_if_errors();
600+
601+
(krate, ctxt.renderinfo.into_inner(), passes)
537602
}), &sess)
538603
})
539604
}

‎src/librustdoc/lib.rs

Lines changed: 15 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#![feature(entry_and_modify)]
2727
#![feature(ptr_offset_from)]
2828
#![feature(crate_visibility_modifier)]
29+
#![feature(const_fn)]
2930

3031
#![recursion_limit="256"]
3132

@@ -96,8 +97,6 @@ mod visit_lib;
9697
mod test;
9798
mod theme;
9899

99-
use clean::AttributesExt;
100-
101100
struct Output {
102101
krate: clean::Crate,
103102
renderinfo: html::render::RenderInfo,
@@ -367,8 +366,8 @@ fn main_args(args: &[String]) -> isize {
367366

368367
if matches.opt_strs("passes") == ["list"] {
369368
println!("Available passes for running rustdoc:");
370-
for &(name, _, description) in passes::PASSES {
371-
println!("{:>20} - {}", name, description);
369+
for pass in passes::PASSES {
370+
println!("{:>20} - {}", pass.name(), pass.description());
372371
}
373372
println!("\nDefault passes for rustdoc:");
374373
for &name in passes::DEFAULT_PASSES {
@@ -630,16 +629,16 @@ fn rust_input<R, F>(cratefile: PathBuf,
630629
where R: 'static + Send,
631630
F: 'static + Send + FnOnce(Output) -> R
632631
{
633-
let mut default_passes = if matches.opt_present("no-defaults") {
632+
let default_passes = if matches.opt_present("no-defaults") {
634633
passes::DefaultPassOption::None
635634
} else if matches.opt_present("document-private-items") {
636635
passes::DefaultPassOption::Private
637636
} else {
638637
passes::DefaultPassOption::Default
639638
};
640639

641-
let mut manual_passes = matches.opt_strs("passes");
642-
let mut plugins = matches.opt_strs("plugins");
640+
let manual_passes = matches.opt_strs("passes");
641+
let plugins = matches.opt_strs("plugins");
643642

644643
// First, parse the crate and extract all relevant information.
645644
let mut paths = SearchPaths::new();
@@ -673,11 +672,11 @@ where R: 'static + Send,
673672
let result = rustc_driver::monitor(move || syntax::with_globals(move || {
674673
use rustc::session::config::Input;
675674

676-
let (mut krate, renderinfo) =
675+
let (mut krate, renderinfo, passes) =
677676
core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
678677
display_warnings, crate_name.clone(),
679678
force_unstable_if_unmarked, edition, cg, error_format,
680-
lint_opts, lint_cap, describe_lints);
679+
lint_opts, lint_cap, describe_lints, manual_passes, default_passes);
681680

682681
info!("finished with rustc");
683682

@@ -687,58 +686,6 @@ where R: 'static + Send,
687686

688687
krate.version = crate_version;
689688

690-
let diag = core::new_handler(error_format, None);
691-
692-
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
693-
let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
694-
considered deprecated", name));
695-
msg.warn("please see https://github.com/rust-lang/rust/issues/44136");
696-
697-
if name == "no_default_passes" {
698-
msg.help("you may want to use `#![doc(document_private_items)]`");
699-
}
700-
701-
msg.emit();
702-
}
703-
704-
// Process all of the crate attributes, extracting plugin metadata along
705-
// with the passes which we are supposed to run.
706-
for attr in krate.module.as_ref().unwrap().attrs.lists("doc") {
707-
let name = attr.name().map(|s| s.as_str());
708-
let name = name.as_ref().map(|s| &s[..]);
709-
if attr.is_word() {
710-
if name == Some("no_default_passes") {
711-
report_deprecated_attr("no_default_passes", &diag);
712-
if default_passes == passes::DefaultPassOption::Default {
713-
default_passes = passes::DefaultPassOption::None;
714-
}
715-
}
716-
} else if let Some(value) = attr.value_str() {
717-
let sink = match name {
718-
Some("passes") => {
719-
report_deprecated_attr("passes = \"...\"", &diag);
720-
&mut manual_passes
721-
},
722-
Some("plugins") => {
723-
report_deprecated_attr("plugins = \"...\"", &diag);
724-
&mut plugins
725-
},
726-
_ => continue,
727-
};
728-
sink.extend(value.as_str().split_whitespace().map(|p| p.to_string()));
729-
}
730-
731-
if attr.is_word() && name == Some("document_private_items") {
732-
if default_passes == passes::DefaultPassOption::Default {
733-
default_passes = passes::DefaultPassOption::Private;
734-
}
735-
}
736-
}
737-
738-
let mut passes: Vec<String> =
739-
passes::defaults(default_passes).iter().map(|p| p.to_string()).collect();
740-
passes.extend(manual_passes);
741-
742689
if !plugins.is_empty() {
743690
eprintln!("WARNING: --plugins no longer functions; see CVE-2018-1000622");
744691
}
@@ -751,8 +698,13 @@ where R: 'static + Send,
751698

752699
for pass in &passes {
753700
// determine if we know about this pass
754-
let pass = match passes::PASSES.iter().find(|(p, ..)| p == pass) {
755-
Some(pass) => pass.1,
701+
let pass = match passes::find_pass(pass) {
702+
Some(pass) => if let Some(pass) = pass.late_fn() {
703+
pass
704+
} else {
705+
// not a late pass, but still valid so don't report the error
706+
continue
707+
}
756708
None => {
757709
error!("unknown pass {}, skipping", *pass);
758710

‎src/librustdoc/passes/collapse_docs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@
1111
use clean::{self, DocFragment, Item};
1212
use fold;
1313
use fold::DocFolder;
14+
use passes::Pass;
1415
use std::mem::replace;
1516

17+
pub const COLLAPSE_DOCS: Pass =
18+
Pass::late("collapse-docs", collapse_docs,
19+
"concatenates all document attributes into one document attribute");
20+
1621
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1722
enum DocFragmentKind {
1823
Sugared,

‎src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 597 additions & 0 deletions
Large diffs are not rendered by default.

‎src/librustdoc/passes/mod.rs

Lines changed: 113 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,95 +8,161 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
//! Contains information about "passes", used to modify crate information during the documentation
12+
//! process.
13+
1114
use rustc::hir::def_id::DefId;
1215
use rustc::middle::privacy::AccessLevels;
1316
use rustc::util::nodemap::DefIdSet;
1417
use std::mem;
18+
use std::fmt;
1519

1620
use clean::{self, GetDefId, Item};
21+
use core::DocContext;
1722
use fold;
1823
use fold::StripItem;
1924

2025
mod collapse_docs;
21-
pub use self::collapse_docs::collapse_docs;
26+
pub use self::collapse_docs::COLLAPSE_DOCS;
2227

2328
mod strip_hidden;
24-
pub use self::strip_hidden::strip_hidden;
29+
pub use self::strip_hidden::STRIP_HIDDEN;
2530

2631
mod strip_private;
27-
pub use self::strip_private::strip_private;
32+
pub use self::strip_private::STRIP_PRIVATE;
2833

2934
mod strip_priv_imports;
30-
pub use self::strip_priv_imports::strip_priv_imports;
35+
pub use self::strip_priv_imports::STRIP_PRIV_IMPORTS;
3136

3237
mod unindent_comments;
33-
pub use self::unindent_comments::unindent_comments;
38+
pub use self::unindent_comments::UNINDENT_COMMENTS;
3439

3540
mod propagate_doc_cfg;
36-
pub use self::propagate_doc_cfg::propagate_doc_cfg;
41+
pub use self::propagate_doc_cfg::PROPAGATE_DOC_CFG;
42+
43+
mod collect_intra_doc_links;
44+
pub use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS;
45+
46+
/// Represents a single pass.
47+
#[derive(Copy, Clone)]
48+
pub enum Pass {
49+
/// An "early pass" is run in the compiler context, and can gather information about types and
50+
/// traits and the like.
51+
EarlyPass {
52+
name: &'static str,
53+
pass: fn(clean::Crate, &DocContext) -> clean::Crate,
54+
description: &'static str,
55+
},
56+
/// A "late pass" is run between crate cleaning and page generation.
57+
LatePass {
58+
name: &'static str,
59+
pass: fn(clean::Crate) -> clean::Crate,
60+
description: &'static str,
61+
},
62+
}
63+
64+
impl fmt::Debug for Pass {
65+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
66+
let mut dbg = match *self {
67+
Pass::EarlyPass { .. } => f.debug_struct("EarlyPass"),
68+
Pass::LatePass { .. } => f.debug_struct("LatePass"),
69+
};
70+
71+
dbg.field("name", &self.name())
72+
.field("pass", &"...")
73+
.field("description", &self.description())
74+
.finish()
75+
}
76+
}
3777

38-
type Pass = (
39-
&'static str, // name
40-
fn(clean::Crate) -> clean::Crate, // fn
41-
&'static str,
42-
); // description
78+
impl Pass {
79+
/// Constructs a new early pass.
80+
pub const fn early(name: &'static str,
81+
pass: fn(clean::Crate, &DocContext) -> clean::Crate,
82+
description: &'static str) -> Pass {
83+
Pass::EarlyPass { name, pass, description }
84+
}
4385

86+
/// Constructs a new late pass.
87+
pub const fn late(name: &'static str,
88+
pass: fn(clean::Crate) -> clean::Crate,
89+
description: &'static str) -> Pass {
90+
Pass::LatePass { name, pass, description }
91+
}
92+
93+
/// Returns the name of this pass.
94+
pub fn name(self) -> &'static str {
95+
match self {
96+
Pass::EarlyPass { name, .. } |
97+
Pass::LatePass { name, .. } => name,
98+
}
99+
}
100+
101+
/// Returns the description of this pass.
102+
pub fn description(self) -> &'static str {
103+
match self {
104+
Pass::EarlyPass { description, .. } |
105+
Pass::LatePass { description, .. } => description,
106+
}
107+
}
108+
109+
/// If this pass is an early pass, returns the pointer to its function.
110+
pub fn early_fn(self) -> Option<fn(clean::Crate, &DocContext) -> clean::Crate> {
111+
match self {
112+
Pass::EarlyPass { pass, .. } => Some(pass),
113+
_ => None,
114+
}
115+
}
116+
117+
/// If this pass is a late pass, returns the pointer to its function.
118+
pub fn late_fn(self) -> Option<fn(clean::Crate) -> clean::Crate> {
119+
match self {
120+
Pass::LatePass { pass, .. } => Some(pass),
121+
_ => None,
122+
}
123+
}
124+
}
125+
126+
/// The full list of passes.
44127
pub const PASSES: &'static [Pass] = &[
45-
(
46-
"strip-hidden",
47-
strip_hidden,
48-
"strips all doc(hidden) items from the output",
49-
),
50-
(
51-
"unindent-comments",
52-
unindent_comments,
53-
"removes excess indentation on comments in order for markdown to like it",
54-
),
55-
(
56-
"collapse-docs",
57-
collapse_docs,
58-
"concatenates all document attributes into one document attribute",
59-
),
60-
(
61-
"strip-private",
62-
strip_private,
63-
"strips all private items from a crate which cannot be seen externally, \
64-
implies strip-priv-imports",
65-
),
66-
(
67-
"strip-priv-imports",
68-
strip_priv_imports,
69-
"strips all private import statements (`use`, `extern crate`) from a crate",
70-
),
71-
(
72-
"propagate-doc-cfg",
73-
propagate_doc_cfg,
74-
"propagates `#[doc(cfg(...))]` to child items",
75-
),
128+
STRIP_HIDDEN,
129+
UNINDENT_COMMENTS,
130+
COLLAPSE_DOCS,
131+
STRIP_PRIVATE,
132+
STRIP_PRIV_IMPORTS,
133+
PROPAGATE_DOC_CFG,
134+
COLLECT_INTRA_DOC_LINKS,
76135
];
77136

137+
/// The list of passes run by default.
78138
pub const DEFAULT_PASSES: &'static [&'static str] = &[
79139
"strip-hidden",
80140
"strip-private",
141+
"collect-intra-doc-links",
81142
"collapse-docs",
82143
"unindent-comments",
83144
"propagate-doc-cfg",
84145
];
85146

147+
/// The list of default passes run with `--document-private-items` is passed to rustdoc.
86148
pub const DEFAULT_PRIVATE_PASSES: &'static [&'static str] = &[
87149
"strip-priv-imports",
150+
"collect-intra-doc-links",
88151
"collapse-docs",
89152
"unindent-comments",
90153
"propagate-doc-cfg",
91154
];
92155

156+
/// A shorthand way to refer to which set of passes to use, based on the presence of
157+
/// `--no-defaults` or `--document-private-items`.
93158
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
94159
pub enum DefaultPassOption {
95160
Default,
96161
Private,
97162
None,
98163
}
99164

165+
/// Returns the given default set of passes.
100166
pub fn defaults(default_set: DefaultPassOption) -> &'static [&'static str] {
101167
match default_set {
102168
DefaultPassOption::Default => DEFAULT_PASSES,
@@ -105,6 +171,11 @@ pub fn defaults(default_set: DefaultPassOption) -> &'static [&'static str] {
105171
}
106172
}
107173

174+
/// If the given name matches a known pass, returns its information.
175+
pub fn find_pass(pass_name: &str) -> Option<Pass> {
176+
PASSES.iter().find(|p| p.name() == pass_name).cloned()
177+
}
178+
108179
struct Stripper<'a> {
109180
retained: &'a mut DefIdSet,
110181
access_levels: &'a AccessLevels<DefId>,

‎src/librustdoc/passes/propagate_doc_cfg.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ use std::sync::Arc;
1313
use clean::{Crate, Item};
1414
use clean::cfg::Cfg;
1515
use fold::DocFolder;
16+
use passes::Pass;
17+
18+
pub const PROPAGATE_DOC_CFG: Pass =
19+
Pass::late("propagate-doc-cfg", propagate_doc_cfg,
20+
"propagates `#[doc(cfg(...))]` to child items");
1621

1722
pub fn propagate_doc_cfg(cr: Crate) -> Crate {
1823
CfgPropagator { parent_cfg: None }.fold_crate(cr)

‎src/librustdoc/passes/strip_hidden.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ use std::mem;
1313

1414
use clean::{self, AttributesExt, NestedAttributesExt};
1515
use clean::Item;
16+
use core::DocContext;
1617
use fold;
1718
use fold::DocFolder;
1819
use fold::StripItem;
19-
use passes::ImplStripper;
20+
use passes::{ImplStripper, Pass};
21+
22+
pub const STRIP_HIDDEN: Pass =
23+
Pass::early("strip-hidden", strip_hidden,
24+
"strips all doc(hidden) items from the output");
2025

2126
/// Strip items marked `#[doc(hidden)]`
22-
pub fn strip_hidden(krate: clean::Crate) -> clean::Crate {
27+
pub fn strip_hidden(krate: clean::Crate, _: &DocContext) -> clean::Crate {
2328
let mut retained = DefIdSet();
2429

2530
// strip all #[doc(hidden)] items

‎src/librustdoc/passes/strip_priv_imports.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
// except according to those terms.
1010

1111
use clean;
12+
use core::DocContext;
1213
use fold::DocFolder;
13-
use passes::ImportStripper;
14+
use passes::{ImportStripper, Pass};
1415

15-
pub fn strip_priv_imports(krate: clean::Crate) -> clean::Crate {
16+
pub const STRIP_PRIV_IMPORTS: Pass = Pass::early("strip-priv-imports", strip_priv_imports,
17+
"strips all private import statements (`use`, `extern crate`) from a crate");
18+
19+
pub fn strip_priv_imports(krate: clean::Crate, _: &DocContext) -> clean::Crate {
1620
ImportStripper.fold_crate(krate)
1721
}

‎src/librustdoc/passes/strip_private.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@
1111
use rustc::util::nodemap::DefIdSet;
1212

1313
use clean;
14+
use core::DocContext;
1415
use fold::DocFolder;
15-
use passes::{ImplStripper, ImportStripper, Stripper};
16+
use passes::{ImplStripper, ImportStripper, Stripper, Pass};
17+
18+
pub const STRIP_PRIVATE: Pass =
19+
Pass::early("strip-private", strip_private,
20+
"strips all private items from a crate which cannot be seen externally, \
21+
implies strip-priv-imports");
1622

1723
/// Strip private items from the point of view of a crate or externally from a
1824
/// crate, specified by the `xcrate` flag.
19-
pub fn strip_private(mut krate: clean::Crate) -> clean::Crate {
25+
pub fn strip_private(mut krate: clean::Crate, _: &DocContext) -> clean::Crate {
2026
// This stripper collects all *retained* nodes.
2127
let mut retained = DefIdSet();
2228
let access_levels = krate.access_levels.clone();

‎src/librustdoc/passes/unindent_comments.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ use std::usize;
1414

1515
use clean::{self, DocFragment, Item};
1616
use fold::{self, DocFolder};
17+
use passes::Pass;
18+
19+
pub const UNINDENT_COMMENTS: Pass =
20+
Pass::late("unindent-comments", unindent_comments,
21+
"removes excess indentation on comments in order for markdown to like it");
1722

1823
pub fn unindent_comments(krate: clean::Crate) -> clean::Crate {
1924
CommentCleaner.fold_crate(krate)

‎src/test/run-make-fulldeps/exit-code/lint-failure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
#![deny(intra_doc_link_resolution_failure)]
1212

1313
/// [intradoc::failure]
14-
fn main() {
14+
pub fn main() {
1515
println!("Hello, world!");
1616
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="inner"]
12+
13+
//! ooh, i'm a rebel just for [kicks]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:intra-link-extern-crate.rs
12+
13+
// When loading `extern crate` statements, we would pull in their docs at the same time, even
14+
// though they would never actually get displayed. This tripped intra-doc-link resolution failures,
15+
// for items that aren't under our control, and not actually getting documented!
16+
17+
#![deny(intra_doc_link_resolution_failure)]
18+
19+
extern crate inner;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Rustdoc would previously report resolution failures on items that weren't in the public docs.
12+
// These failures were legitimate, but not truly relevant - the docs in question couldn't be
13+
// checked for accuracy anyway.
14+
15+
#![deny(intra_doc_link_resolution_failure)]
16+
17+
/// ooh, i'm a [rebel] just for kicks
18+
struct SomeStruct;

0 commit comments

Comments
 (0)
Please sign in to comment.