diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 9dc95366cdc..6e97382fd65 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -743,7 +743,7 @@ fn prepare_rustdoc(cx: &Context<'_, '_>, unit: &Unit) -> CargoResult Self { + Self { foo, yes: true } + } + + pub fn maybe(&self) { + if self.yes { + println!("{}", self.foo) + } + } +}"#, + ) + .build(); + + p.cargo("doc -Zunstable-options -Zrustdoc-scrape-examples --no-deps") + .masquerade_as_nightly_cargo(&["rustdoc-scrape-examples"]) + .with_stderr_unordered( + "\ +[CHECKING] a v0.0.1 ([CWD]/crates/a) +[CHECKING] foo v0.0.1 ([CWD]) +[SCRAPING] foo v0.0.1 ([CWD]) +[DOCUMENTING] foo v0.0.1 ([CWD]) +[FINISHED] [..] +[GENERATED] [CWD]/target/doc/foo/index.html", + ) + .run(); + + let doc_html = p.read_file("target/doc/foo/struct.Foo.html"); + assert!(doc_html.contains("Examples found in repository")); +} + #[cargo_test(nightly, reason = "rustdoc scrape examples flags are unstable")] fn avoid_build_script_cycle() { let p = project()