Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
// Register the loaded external files in the source map so they show up in depinfo.
// We can't load them via the source map because it gets created after we process the options.
for external_path in &loaded_paths {
let _ = sess.source_map().load_file(external_path);
let _ = sess.source_map().load_binary_file(external_path);
}

if sess.opts.describe_lints {
Expand Down
5 changes: 5 additions & 0 deletions src/librustdoc/scrape_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ pub(crate) fn run(
bin_crate: bool,
) {
let inner = move || -> Result<(), String> {
let emit_dep_info = renderopts.dep_info().is_some();
// Generates source files for examples
renderopts.no_emit_shared = true;
let (cx, _) = Context::init(krate, renderopts, cache, tcx, Default::default())
Expand Down Expand Up @@ -320,6 +321,10 @@ pub(crate) fn run(
calls.encode(&mut encoder);
encoder.finish().map_err(|(_path, e)| e.to_string())?;

if emit_dep_info {
rustc_interface::passes::write_dep_info(tcx);
}

Ok(())
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {}

#[test]
fn a_test() {
foobar::ok();
}
19 changes: 19 additions & 0 deletions tests/run-make/rustdoc-scrape-examples-dep-info/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ needs-target-std
use run_make_support::{assert_contains, rfs};

#[path = "../rustdoc-scrape-examples-remap/scrape.rs"]
mod scrape;

fn main() {
scrape::scrape(
&["--scrape-tests", "--emit=dep-info"],
&["--emit=dep-info,invocation-specific"],
);

let content = rfs::read_to_string("foobar.d").replace(r"\", "/");
assert_contains(&content, "lib.rs:");
assert_contains(&content, "rustdoc/ex.calls:");

let content = rfs::read_to_string("ex.d").replace(r"\", "/");
assert_contains(&content, "examples/ex.rs:");
}
3 changes: 3 additions & 0 deletions tests/run-make/rustdoc-scrape-examples-dep-info/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//@ has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' ''

pub fn ok() {}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
mod scrape;

fn main() {
scrape::scrape(&[]);
scrape::scrape(&[], &[]);
}
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-scrape-examples-multiple/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
mod scrape;

fn main() {
scrape::scrape(&[]);
scrape::scrape(&[], &[]);
}
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
mod scrape;

fn main() {
scrape::scrape(&[]);
scrape::scrape(&[], &[]);
}
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-scrape-examples-remap/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
mod scrape;

fn main() {
scrape::scrape(&[]);
scrape::scrape(&[], &[]);
}
5 changes: 3 additions & 2 deletions tests/run-make/rustdoc-scrape-examples-remap/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::Path;

use run_make_support::{htmldocck, rfs, rustc, rustdoc};

pub fn scrape(extra_args: &[&str]) {
pub fn scrape(extra_args_scrape: &[&str], extra_args_doc: &[&str]) {
let out_dir = Path::new("rustdoc");
let crate_name = "foobar";
let deps = rfs::read_dir("examples")
Expand All @@ -27,7 +27,7 @@ pub fn scrape(extra_args: &[&str]) {
.arg(&out_example)
.arg("--scrape-examples-target-crate")
.arg(crate_name)
.args(extra_args)
.args(extra_args_scrape)
.run();
out_deps.push(out_example);
}
Expand All @@ -42,6 +42,7 @@ pub fn scrape(extra_args: &[&str]) {
for dep in out_deps {
rustdoc.arg("--with-examples").arg(dep);
}
rustdoc.args(extra_args_doc);
rustdoc.run();

htmldocck().arg(out_dir).arg("src/lib.rs").run();
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-scrape-examples-test/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
mod scrape;

fn main() {
scrape::scrape(&["--scrape-tests"]);
scrape::scrape(&["--scrape-tests"], &[]);
}
2 changes: 1 addition & 1 deletion tests/run-make/rustdoc-scrape-examples-whitespace/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
mod scrape;

fn main() {
scrape::scrape(&[]);
scrape::scrape(&[], &[]);
}
Loading