about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-10 08:43:14 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-10 08:43:14 -0800
commit8b44cf2a40b93c5407b16de4cb988b01d265fa51 (patch)
tree843f29b93e352fa44e84a15a76a6ae2e59b1cca7
parent3161cb096f2e966a7d907afd69c175dab9eb55ed (diff)
parentad3be9f23f9389c71f7f712ae5195d4190becf05 (diff)
downloadrust-8b44cf2a40b93c5407b16de4cb988b01d265fa51.tar.gz
rust-8b44cf2a40b93c5407b16de4cb988b01d265fa51.zip
rollup merge of #22135: apasel422/issue-22131
fixes #22131
-rw-r--r--src/librustdoc/test.rs10
-rw-r--r--src/test/run-make/issue-22131/Makefile6
-rw-r--r--src/test/run-make/issue-22131/foo.rs17
3 files changed, 25 insertions, 8 deletions
diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs
index e43c3a6da3a..09df9fc8cbb 100644
--- a/src/librustdoc/test.rs
+++ b/src/librustdoc/test.rs
@@ -24,11 +24,8 @@ use rustc::session::{self, config};
 use rustc::session::config::get_unstable_features_setting;
 use rustc::session::search_paths::{SearchPaths, PathKind};
 use rustc_driver::{driver, Compilation};
-use syntax::ast;
-use syntax::codemap::{CodeMap, dummy_spanned};
+use syntax::codemap::CodeMap;
 use syntax::diagnostic;
-use syntax::parse::token;
-use syntax::ptr::P;
 
 use core;
 use clean;
@@ -67,10 +64,7 @@ pub fn run(input: &str,
                                       span_diagnostic_handler);
 
     let mut cfg = config::build_configuration(&sess);
-    cfg.extend(cfgs.into_iter().map(|cfg_| {
-        let cfg_ = token::intern_and_get_ident(&cfg_);
-        P(dummy_spanned(ast::MetaWord(cfg_)))
-    }));
+    cfg.extend(config::parse_cfgspecs(cfgs).into_iter());
     let krate = driver::phase_1_parse_input(&sess, cfg, &input);
     let krate = driver::phase_2_configure_and_expand(&sess, krate,
                                                      "rustdoc-test", None)
diff --git a/src/test/run-make/issue-22131/Makefile b/src/test/run-make/issue-22131/Makefile
new file mode 100644
index 00000000000..46d89f0e2a6
--- /dev/null
+++ b/src/test/run-make/issue-22131/Makefile
@@ -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'
diff --git a/src/test/run-make/issue-22131/foo.rs b/src/test/run-make/issue-22131/foo.rs
new file mode 100644
index 00000000000..0b1f1291df0
--- /dev/null
+++ b/src/test/run-make/issue-22131/foo.rs
@@ -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 }