Skip to content

Commit 8b44cf2

Browse files
committed
rollup merge of rust-lang#22135: apasel422/issue-22131
fixes rust-lang#22131
2 parents 3161cb0 + ad3be9f commit 8b44cf2

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

src/librustdoc/test.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ use rustc::session::{self, config};
2424
use rustc::session::config::get_unstable_features_setting;
2525
use rustc::session::search_paths::{SearchPaths, PathKind};
2626
use rustc_driver::{driver, Compilation};
27-
use syntax::ast;
28-
use syntax::codemap::{CodeMap, dummy_spanned};
27+
use syntax::codemap::CodeMap;
2928
use syntax::diagnostic;
30-
use syntax::parse::token;
31-
use syntax::ptr::P;
3229

3330
use core;
3431
use clean;
@@ -67,10 +64,7 @@ pub fn run(input: &str,
6764
span_diagnostic_handler);
6865

6966
let mut cfg = config::build_configuration(&sess);
70-
cfg.extend(cfgs.into_iter().map(|cfg_| {
71-
let cfg_ = token::intern_and_get_ident(&cfg_);
72-
P(dummy_spanned(ast::MetaWord(cfg_)))
73-
}));
67+
cfg.extend(config::parse_cfgspecs(cfgs).into_iter());
7468
let krate = driver::phase_1_parse_input(&sess, cfg, &input);
7569
let krate = driver::phase_2_configure_and_expand(&sess, krate,
7670
"rustdoc-test", None)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-include ../tools.mk
2+
3+
all: foo.rs
4+
$(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs
5+
$(RUSTDOC) --test --cfg 'feature="bar"' -L $(TMPDIR) foo.rs |\
6+
grep --quiet 'test foo_0 ... ok'

src/test/run-make/issue-22131/foo.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_name="foo"]
12+
13+
/// ```rust
14+
/// assert_eq!(foo::foo(), 1);
15+
/// ```
16+
#[cfg(feature = "bar")]
17+
pub fn foo() -> i32 { 1 }

0 commit comments

Comments
 (0)