Skip to content

Commit 445e735

Browse files
Prevent rustdoc feature to be passed down to doctests
1 parent 42ec683 commit 445e735

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/librustdoc/config.rs

-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ impl Options {
344344
.map(|s| PathBuf::from(&s))
345345
.unwrap_or_else(|| PathBuf::from("doc"));
346346
let mut cfgs = matches.opt_strs("cfg");
347-
cfgs.push("rustdoc".to_string());
348347
if should_test {
349348
cfgs.push("doctest".to_string());
350349
}

src/librustdoc/core.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
234234
error_format,
235235
libs,
236236
externs,
237-
cfgs,
237+
mut cfgs,
238238
codegen_options,
239239
debugging_options,
240240
target,
@@ -250,6 +250,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
250250
..
251251
} = options;
252252

253+
// Add the rustdoc cfg into the doc build.
254+
cfgs.push("rustdoc".to_string());
255+
253256
let cpath = Some(input.clone());
254257
let input = Input::File(input);
255258

src/librustdoc/test.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ pub fn run(options: Options) -> i32 {
6262
..config::Options::default()
6363
};
6464

65+
let mut cfgs = options.cfgs.clone();
66+
cfgs.push("rustdoc".to_owned());
6567
let config = interface::Config {
6668
opts: sessopts,
67-
crate_cfg: config::parse_cfgspecs(options.cfgs.clone()),
69+
crate_cfg: config::parse_cfgspecs(cfgs),
6870
input,
6971
input_path: None,
7072
output_file: None,

0 commit comments

Comments
 (0)