rollup merge of #22135: apasel422/issue-22131

fixes #22131
This commit is contained in:
Alex Crichton 2015-02-10 08:43:14 -08:00
commit 8b44cf2a40
3 changed files with 25 additions and 8 deletions

View File

@ -24,11 +24,8 @@
use rustc::session::config::get_unstable_features_setting; use rustc::session::config::get_unstable_features_setting;
use rustc::session::search_paths::{SearchPaths, PathKind}; use rustc::session::search_paths::{SearchPaths, PathKind};
use rustc_driver::{driver, Compilation}; use rustc_driver::{driver, Compilation};
use syntax::ast; use syntax::codemap::CodeMap;
use syntax::codemap::{CodeMap, dummy_spanned};
use syntax::diagnostic; use syntax::diagnostic;
use syntax::parse::token;
use syntax::ptr::P;
use core; use core;
use clean; use clean;
@ -67,10 +64,7 @@ pub fn run(input: &str,
span_diagnostic_handler); span_diagnostic_handler);
let mut cfg = config::build_configuration(&sess); let mut cfg = config::build_configuration(&sess);
cfg.extend(cfgs.into_iter().map(|cfg_| { cfg.extend(config::parse_cfgspecs(cfgs).into_iter());
let cfg_ = token::intern_and_get_ident(&cfg_);
P(dummy_spanned(ast::MetaWord(cfg_)))
}));
let krate = driver::phase_1_parse_input(&sess, cfg, &input); let krate = driver::phase_1_parse_input(&sess, cfg, &input);
let krate = driver::phase_2_configure_and_expand(&sess, krate, let krate = driver::phase_2_configure_and_expand(&sess, krate,
"rustdoc-test", None) "rustdoc-test", None)

View File

@ -0,0 +1,6 @@
-include ../tools.mk
all: foo.rs
$(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs
$(RUSTDOC) --test --cfg 'feature="bar"' -L $(TMPDIR) foo.rs |\
grep --quiet 'test foo_0 ... ok'

View File

@ -0,0 +1,17 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![crate_name="foo"]
/// ```rust
/// assert_eq!(foo::foo(), 1);
/// ```
#[cfg(feature = "bar")]
pub fn foo() -> i32 { 1 }