diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /compiler/rustc_driver/src/args.rs | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-upstream/1.69.0+dfsg1.tar.xz rustc-upstream/1.69.0+dfsg1.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_driver/src/args.rs')
-rw-r--r-- | compiler/rustc_driver/src/args.rs | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/compiler/rustc_driver/src/args.rs b/compiler/rustc_driver/src/args.rs deleted file mode 100644 index 42c97cc6a..000000000 --- a/compiler/rustc_driver/src/args.rs +++ /dev/null @@ -1,51 +0,0 @@ -use std::error; -use std::fmt; -use std::fs; -use std::io; - -fn arg_expand(arg: String) -> Result<Vec<String>, Error> { - if let Some(path) = arg.strip_prefix('@') { - let file = match fs::read_to_string(path) { - Ok(file) => file, - Err(ref err) if err.kind() == io::ErrorKind::InvalidData => { - return Err(Error::Utf8Error(Some(path.to_string()))); - } - Err(err) => return Err(Error::IOError(path.to_string(), err)), - }; - Ok(file.lines().map(ToString::to_string).collect()) - } else { - Ok(vec![arg]) - } -} - -pub fn arg_expand_all(at_args: &[String]) -> Vec<String> { - let mut args = Vec::new(); - for arg in at_args { - match arg_expand(arg.clone()) { - Ok(arg) => args.extend(arg), - Err(err) => rustc_session::early_error( - rustc_session::config::ErrorOutputType::default(), - &format!("Failed to load argument file: {err}"), - ), - } - } - args -} - -#[derive(Debug)] -pub enum Error { - Utf8Error(Option<String>), - IOError(String, io::Error), -} - -impl fmt::Display for Error { - fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - Error::Utf8Error(None) => write!(fmt, "Utf8 error"), - Error::Utf8Error(Some(path)) => write!(fmt, "Utf8 error in {path}"), - Error::IOError(path, err) => write!(fmt, "IO Error: {path}: {err}"), - } - } -} - -impl error::Error for Error {} |