File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,17 @@ use std::fmt;
4
4
use std:: fs;
5
5
use std:: io:: { self , BufRead } ;
6
6
use std:: str;
7
+ use std:: sync:: atomic:: { AtomicBool , Ordering } ;
7
8
8
9
#[ cfg( test) ]
9
10
mod tests;
10
11
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
+
11
18
struct FileArgs {
12
19
path : String ,
13
20
input : Vec < u8 > ,
@@ -60,7 +67,10 @@ impl Iterator for ArgsIter {
60
67
Some ( Ok ( ref arg) ) if arg. starts_with ( "@" ) => {
61
68
let path = & arg[ 1 ..] ;
62
69
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
+ }
64
74
Err ( err) => return Some ( Err ( Error :: IOError ( path. to_string ( ) , err) ) ) ,
65
75
} ;
66
76
self . file = Some ( Box :: new ( lines) ) ;
Original file line number Diff line number Diff line change @@ -778,7 +778,7 @@ fn usage(verbose: bool, include_unstable_options: bool) {
778
778
} else {
779
779
"\n --help -v Print the full set of options rustc accepts"
780
780
} ;
781
- let at_path = if verbose {
781
+ let at_path = if verbose && nightly_options :: is_nightly_build ( ) {
782
782
" @path Read newline separated options from `path`\n "
783
783
} else {
784
784
""
@@ -1015,6 +1015,12 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
1015
1015
// (unstable option being used on stable)
1016
1016
nightly_options:: check_nightly_options ( & matches, & config:: rustc_optgroups ( ) ) ;
1017
1017
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
+
1018
1024
if matches. opt_present ( "h" ) || matches. opt_present ( "help" ) {
1019
1025
// Only show unstable options in --help if we accept unstable options.
1020
1026
usage ( matches. opt_present ( "verbose" ) , nightly_options:: is_unstable_enabled ( & matches) ) ;
You can’t perform that action at this time.
0 commit comments