Skip to content

Commit 96a6fc8

Browse files
---
yaml --- r: 272349 b: refs/heads/auto c: f34ae3f h: refs/heads/master i: 272347: b62b2d0
1 parent 6fcd06a commit 96a6fc8

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
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: ab835a12da26c2146b2dde1f3fe99df687730725
11+
refs/heads/auto: f34ae3f7ed353ccfa0e26a5e2227fca60d008a63
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/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)