Rollup merge of #66172 - jsgf:stabilize-atfile, r=nikomatsakis
Stabilize @file command line arguments Issue https://github.com/rust-lang/rust/issues/63576
This commit is contained in:
commit
648e8bfe34
2 changed files with 1 additions and 17 deletions
|
@ -3,22 +3,12 @@ use std::fmt;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
|
|
||||||
static USED_ARGSFILE_FEATURE: AtomicBool = AtomicBool::new(false);
|
|
||||||
|
|
||||||
pub fn used_unstable_argsfile() -> bool {
|
|
||||||
USED_ARGSFILE_FEATURE.load(Ordering::Relaxed)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
|
pub fn arg_expand(arg: String) -> Result<Vec<String>, Error> {
|
||||||
if arg.starts_with("@") {
|
if arg.starts_with("@") {
|
||||||
let path = &arg[1..];
|
let path = &arg[1..];
|
||||||
let file = match fs::read_to_string(path) {
|
let file = match fs::read_to_string(path) {
|
||||||
Ok(file) => {
|
Ok(file) => file,
|
||||||
USED_ARGSFILE_FEATURE.store(true, Ordering::Relaxed);
|
|
||||||
file
|
|
||||||
}
|
|
||||||
Err(ref err) if err.kind() == io::ErrorKind::InvalidData => {
|
Err(ref err) if err.kind() == io::ErrorKind::InvalidData => {
|
||||||
return Err(Error::Utf8Error(Some(path.to_string())));
|
return Err(Error::Utf8Error(Some(path.to_string())));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1044,12 +1044,6 @@ pub fn handle_options(args: &[String]) -> Option<getopts::Matches> {
|
||||||
// (unstable option being used on stable)
|
// (unstable option being used on stable)
|
||||||
nightly_options::check_nightly_options(&matches, &config::rustc_optgroups());
|
nightly_options::check_nightly_options(&matches, &config::rustc_optgroups());
|
||||||
|
|
||||||
// Late check to see if @file was used without unstable options enabled
|
|
||||||
if crate::args::used_unstable_argsfile() && !nightly_options::is_unstable_enabled(&matches) {
|
|
||||||
early_error(ErrorOutputType::default(),
|
|
||||||
"@path is unstable - use -Z unstable-options to enable its use");
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches.opt_present("h") || matches.opt_present("help") {
|
if matches.opt_present("h") || matches.opt_present("help") {
|
||||||
// Only show unstable options in --help if we accept unstable options.
|
// Only show unstable options in --help if we accept unstable options.
|
||||||
usage(matches.opt_present("verbose"), nightly_options::is_unstable_enabled(&matches));
|
usage(matches.opt_present("verbose"), nightly_options::is_unstable_enabled(&matches));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue