Skip to content

Commit 13f5ee1

Browse files
---
yaml --- r: 276895 b: refs/heads/try c: f34ae3f h: refs/heads/master i: 276893: e6195ec 276891: 8efa2aa 276887: 676bab1 276879: 9af05dd 276863: 996e7a6
1 parent bb8479b commit 13f5ee1

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: ab835a12da26c2146b2dde1f3fe99df687730725
4+
refs/heads/try: f34ae3f7ed353ccfa0e26a5e2227fca60d008a63
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustdoc/lib.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ use std::sync::mpsc::channel;
6565
use externalfiles::ExternalHtml;
6666
use serialize::Decodable;
6767
use serialize::json::{self, Json};
68+
use rustc::session::early_error;
6869
use rustc::session::search_paths::SearchPaths;
69-
use rustc::session::config::ErrorOutputType;
70+
use rustc::session::config::{get_unstable_features_setting, ErrorOutputType};
71+
use syntax::feature_gate::UnstableFeatures;
7072

7173
// reexported from `clean` so it can be easily updated with the mod itself
7274
pub use clean::SCHEMA_VERSION;
@@ -189,6 +191,7 @@ pub fn opts() -> Vec<getopts::OptGroup> {
189191
optopt("e", "extend-css",
190192
"to redefine some css rules with a given file to generate doc with your \
191193
own theme", "PATH"),
194+
optmulti("Z", "", "internal and debugging options (only on nightly build)", "FLAG"),
192195
)
193196
}
194197

@@ -198,6 +201,20 @@ pub fn usage(argv0: &str) {
198201
&opts()));
199202
}
200203

204+
fn check_unstable_flag_enabled(nightly_build: bool, has_z_unstable_options: bool,
205+
flag_name: &str) {
206+
// check if unstable for --extend-css option
207+
let e = if !nightly_build {
208+
format!("the option `{}` is only accepted on the nightly compiler", flag_name)
209+
} else if !has_z_unstable_options {
210+
format!("the `-Z unstable-options` flag must also be passed to enable the flag `{}`",
211+
flag_name)
212+
} else {
213+
return
214+
};
215+
early_error(ErrorOutputType::default(), &e)
216+
}
217+
201218
pub fn main_args(args: &[String]) -> isize {
202219
let matches = match getopts::getopts(&args[1..], &opts()) {
203220
Ok(m) => m,
@@ -260,7 +277,24 @@ pub fn main_args(args: &[String]) -> isize {
260277
let css_file_extension = matches.opt_str("e").map(|s| PathBuf::from(&s));
261278
let cfgs = matches.opt_strs("cfg");
262279

280+
// we now check if unstable options are allowed and if we're in a nightly build
281+
let mut has_z_unstable_options = false;
282+
for flag in matches.opt_strs("Z").iter() {
283+
if *flag != "unstable-options" {
284+
println!("Unknown flag for `Z` option: {}", flag);
285+
return 1;
286+
} else {
287+
has_z_unstable_options = true;
288+
}
289+
}
290+
let nightly_build = get_unstable_features_setting();
291+
let nightly_build = match nightly_build {
292+
UnstableFeatures::Allow | UnstableFeatures::Cheat => true,
293+
_ => false,
294+
};
295+
263296
if let Some(ref p) = css_file_extension {
297+
check_unstable_flag_enabled(nightly_build, has_z_unstable_options, "extend-css");
264298
if !p.is_file() {
265299
println!("{}", "--extend-css option must take a css file as input");
266300
return 1;

0 commit comments

Comments
 (0)