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:
commit
69837b14d6
5 changed files with 27 additions and 3 deletions
|
@ -344,7 +344,6 @@ impl Options {
|
||||||
.map(|s| PathBuf::from(&s))
|
.map(|s| PathBuf::from(&s))
|
||||||
.unwrap_or_else(|| PathBuf::from("doc"));
|
.unwrap_or_else(|| PathBuf::from("doc"));
|
||||||
let mut cfgs = matches.opt_strs("cfg");
|
let mut cfgs = matches.opt_strs("cfg");
|
||||||
cfgs.push("rustdoc".to_string());
|
|
||||||
if should_test {
|
if should_test {
|
||||||
cfgs.push("doctest".to_string());
|
cfgs.push("doctest".to_string());
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||||
error_format,
|
error_format,
|
||||||
libs,
|
libs,
|
||||||
externs,
|
externs,
|
||||||
cfgs,
|
mut cfgs,
|
||||||
codegen_options,
|
codegen_options,
|
||||||
debugging_options,
|
debugging_options,
|
||||||
target,
|
target,
|
||||||
|
@ -250,6 +250,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||||
..
|
..
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
|
// Add the rustdoc cfg into the doc build.
|
||||||
|
cfgs.push("rustdoc".to_string());
|
||||||
|
|
||||||
let cpath = Some(input.clone());
|
let cpath = Some(input.clone());
|
||||||
let input = Input::File(input);
|
let input = Input::File(input);
|
||||||
|
|
||||||
|
|
|
@ -62,9 +62,11 @@ pub fn run(options: Options) -> i32 {
|
||||||
..config::Options::default()
|
..config::Options::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut cfgs = options.cfgs.clone();
|
||||||
|
cfgs.push("rustdoc".to_owned());
|
||||||
let config = interface::Config {
|
let config = interface::Config {
|
||||||
opts: sessopts,
|
opts: sessopts,
|
||||||
crate_cfg: config::parse_cfgspecs(options.cfgs.clone()),
|
crate_cfg: config::parse_cfgspecs(cfgs),
|
||||||
input,
|
input,
|
||||||
input_path: None,
|
input_path: None,
|
||||||
output_file: None,
|
output_file: None,
|
||||||
|
|
14
src/test/rustdoc-ui/doc-test-rustdoc-feature.rs
Normal file
14
src/test/rustdoc-ui/doc-test-rustdoc-feature.rs
Normal 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;
|
6
src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout
Normal file
6
src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout
Normal 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
|
||||||
|
|
Loading…
Add table
Reference in a new issue