diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-12-07 08:42:21 +0000 | 
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2023-01-16 14:46:40 +0000 | 
| commit | 42f75f1e462f90bfe20f458690113c3cb2a26271 (patch) | |
| tree | 48a8f97af4fda779178da389e51dad48f4ce497b /compiler/rustc_interface/src/util.rs | |
| parent | f5c601492ee520d2ee4f6c133f7f4dfa7b0c13e2 (diff) | |
| download | rust-42f75f1e462f90bfe20f458690113c3cb2a26271.tar.gz rust-42f75f1e462f90bfe20f458690113c3cb2a26271.zip | |
Group some commonly passed together values into a struct
Diffstat (limited to 'compiler/rustc_interface/src/util.rs')
| -rw-r--r-- | compiler/rustc_interface/src/util.rs | 21 | 
1 files changed, 10 insertions, 11 deletions
| diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 02a7756c8d4..f19b03c75eb 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -8,7 +8,7 @@ use rustc_parse::validate_attr; use rustc_session as session; use rustc_session::config::CheckCfg; use rustc_session::config::{self, CrateType}; -use rustc_session::config::{ErrorOutputType, Input, OutputFilenames}; +use rustc_session::config::{ErrorOutputType, OutputFilenames}; use rustc_session::filesearch::sysroot_candidates; use rustc_session::lint::{self, BuiltinLintDiagnostics, LintBuffer}; use rustc_session::parse::CrateConfig; @@ -25,6 +25,8 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::OnceLock; use std::thread; +use crate::interface::CompilerIO; + /// Function pointer type that constructs a new CodegenBackend. pub type MakeBackendFn = fn() -> Box<dyn CodegenBackend>; @@ -487,19 +489,16 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<C } pub fn build_output_filenames( - input: &Input, - odir: &Option<PathBuf>, - ofile: &Option<PathBuf>, - temps_dir: &Option<PathBuf>, + io: &CompilerIO, attrs: &[ast::Attribute], sess: &Session, ) -> OutputFilenames { - match *ofile { + match io.output_file { None => { // "-" as input file will cause the parser to read from stdin so we // have to make up a name // We want to toss everything after the final '.' - let dirpath = (*odir).as_ref().cloned().unwrap_or_default(); + let dirpath = io.output_dir.clone().unwrap_or_default(); // If a crate name is present, we use it as the link name let stem = sess @@ -507,13 +506,13 @@ pub fn build_output_filenames( .crate_name .clone() .or_else(|| rustc_attr::find_crate_name(sess, attrs).map(|n| n.to_string())) - .unwrap_or_else(|| input.filestem().to_owned()); + .unwrap_or_else(|| io.input.filestem().to_owned()); OutputFilenames::new( dirpath, stem, None, - temps_dir.clone(), + io.temps_dir.clone(), sess.opts.cg.extra_filename.clone(), sess.opts.output_types.clone(), ) @@ -534,7 +533,7 @@ pub fn build_output_filenames( } Some(out_file.clone()) }; - if *odir != None { + if io.output_dir != None { sess.warn("ignoring --out-dir flag due to -o flag"); } @@ -542,7 +541,7 @@ pub fn build_output_filenames( out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(), out_file.file_stem().unwrap_or_default().to_str().unwrap().to_string(), ofile, - temps_dir.clone(), + io.temps_dir.clone(), sess.opts.cg.extra_filename.clone(), sess.opts.output_types.clone(), ) | 
