Skip to content

Commit 892ae41

Browse files
committed
Require -Zunstable-options to use @path
1 parent 4fc66a7 commit 892ae41

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/librustc_driver/args/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,17 @@ use std::fmt;
44
use std::fs;
55
use std::io::{self, BufRead};
66
use std::str;
7+
use std::sync::atomic::{AtomicBool, Ordering};
78

89
#[cfg(test)]
910
mod tests;
1011

12+
static USED_ARGSFILE_FEATURE: AtomicBool = AtomicBool::new(false);
13+
14+
pub fn used_unstable_argsfile() -> bool {
15+
USED_ARGSFILE_FEATURE.load(Ordering::Relaxed)
16+
}
17+
1118
struct FileArgs {
1219
path: String,
1320
input: Vec<u8>,
@@ -60,7 +67,10 @@ impl Iterator for ArgsIter {
6067
Some(Ok(ref arg)) if arg.starts_with("@") => {
6168
let path = &arg[1..];
6269
let lines = match fs::read(path) {
63-
Ok(file) => FileArgs::new(path.to_string(), file).lines(),
70+
Ok(file) => {
71+
USED_ARGSFILE_FEATURE.store(true, Ordering::Relaxed);
72+
FileArgs::new(path.to_string(), file).lines()
73+
}
6474
Err(err) => return Some(Err(Error::IOError(path.to_string(), err))),
6575
};
6676
self.file = Some(Box::new(lines));

src/librustc_driver/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
778778
} else {
779779
"\n --help -v Print the full set of options rustc accepts"
780780
};
781-
let at_path = if verbose {
781+
let at_path = if verbose && nightly_options::is_nightly_build() {
782782
" @path Read newline separated options from `path`\n"
783783
} else {
784784
""
@@ -1015,6 +1015,12 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
10151015
// (unstable option being used on stable)
10161016
nightly_options::check_nightly_options(&matches, &config::rustc_optgroups());
10171017

1018+
// Late check to see if @file was used without unstable options enabled
1019+
if crate::args::used_unstable_argsfile() && !nightly_options::is_unstable_enabled(&matches) {
1020+
early_error(ErrorOutputType::default(),
1021+
"@path is unstable - use -Z unstable-options to enable its use");
1022+
}
1023+
10181024
if matches.opt_present("h") || matches.opt_present("help") {
10191025
// Only show unstable options in --help if we accept unstable options.
10201026
usage(matches.opt_present("verbose"), nightly_options::is_unstable_enabled(&matches));

0 commit comments

Comments
 (0)