about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2014-10-06 19:39:01 -0700
committerSteven Fackler <sfackler@gmail.com>2014-10-06 19:39:23 -0700
commita585b4e8a0ca41a2445838245f3d44358a82a4dc (patch)
tree809087907c3c981feb0e6acfc9d28889f6a8ff35 /src
parent6d15f28986e00e1a1b290b0f0fcf76c3f4e6e261 (diff)
downloadrust-a585b4e8a0ca41a2445838245f3d44358a82a4dc.tar.gz
rust-a585b4e8a0ca41a2445838245f3d44358a82a4dc.zip
Properly handle cfgs in rustdoc
Rustdoc would previously improperly handle key="value" style cfgs, which
are notably used for Cargo features.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/driver/config.rs2
-rw-r--r--src/librustdoc/core.rs9
2 files changed, 3 insertions, 8 deletions
diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs
index 9804382dbd9..9ce01250244 100644
--- a/src/librustc/driver/config.rs
+++ b/src/librustc/driver/config.rs
@@ -630,7 +630,7 @@ pub fn optgroups() -> Vec<getopts::OptGroup> {
 
 
 // Convert strings provided as --cfg [cfgspec] into a crate_cfg
-fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
+pub fn parse_cfgspecs(cfgspecs: Vec<String> ) -> ast::CrateConfig {
     cfgspecs.into_iter().map(|s| {
         parse::parse_meta_from_source_str("cfgspec".to_string(),
                                           s.to_string(),
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index c5aece4ceac..f0f08ff7077 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -14,8 +14,6 @@ use rustc::lint;
 use rustc::back::link;
 
 use syntax::{ast, ast_map, codemap, diagnostic};
-use syntax::parse::token;
-use syntax::ptr::P;
 
 use std::cell::RefCell;
 use std::os;
@@ -95,6 +93,7 @@ pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
         lint_opts: vec!((warning_lint, lint::Allow)),
         externs: externs,
         target_triple: triple.unwrap_or(driver::host_triple().to_string()),
+        cfg: config::parse_cfgspecs(cfgs),
         ..config::basic_options().clone()
     };
 
@@ -108,11 +107,7 @@ pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
                                        Some(cpath.clone()),
                                        span_diagnostic_handler);
 
-    let mut cfg = config::build_configuration(&sess);
-    for cfg_ in cfgs.into_iter() {
-        let cfg_ = token::intern_and_get_ident(cfg_.as_slice());
-        cfg.push(P(codemap::dummy_spanned(ast::MetaWord(cfg_))));
-    }
+    let cfg = config::build_configuration(&sess);
 
     let krate = driver::phase_1_parse_input(&sess, cfg, &input);