Rollup merge of #64741 - GuillaumeGomez:prevent-rustdoc-feature-doctests, r=QuietMisdreavus

Prevent rustdoc feature doctests

Part of https://github.com/rust-lang/rust/pull/61351

cc @ollie27
This commit is contained in:
Tyler Mandry 2019-10-03 16:25:41 -07:00 committed by GitHub
commit 69837b14d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 3 deletions

View file

@ -344,7 +344,6 @@ impl Options {
.map(|s| PathBuf::from(&s))
.unwrap_or_else(|| PathBuf::from("doc"));
let mut cfgs = matches.opt_strs("cfg");
cfgs.push("rustdoc".to_string());
if should_test {
cfgs.push("doctest".to_string());
}

View file

@ -234,7 +234,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
error_format,
libs,
externs,
cfgs,
mut cfgs,
codegen_options,
debugging_options,
target,
@ -250,6 +250,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
..
} = options;
// Add the rustdoc cfg into the doc build.
cfgs.push("rustdoc".to_string());
let cpath = Some(input.clone());
let input = Input::File(input);

View file

@ -62,9 +62,11 @@ pub fn run(options: Options) -> i32 {
..config::Options::default()
};
let mut cfgs = options.cfgs.clone();
cfgs.push("rustdoc".to_owned());
let config = interface::Config {
opts: sessopts,
crate_cfg: config::parse_cfgspecs(options.cfgs.clone()),
crate_cfg: config::parse_cfgspecs(cfgs),
input,
input_path: None,
output_file: None,

View file

@ -0,0 +1,14 @@
// build-pass
// compile-flags:--test
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
#![feature(doc_cfg)]
// Make sure `cfg(rustdoc)` is set when finding doctests but not inside the doctests.
/// ```
/// #![feature(doc_cfg)]
/// assert!(!cfg!(rustdoc));
/// ```
#[cfg(rustdoc)]
pub struct Foo;

View file

@ -0,0 +1,6 @@
running 1 test
test $DIR/doc-test-rustdoc-feature.rs - Foo (line 9) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out