about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/interface.rs
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-12-07 09:24:00 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2023-01-16 14:46:44 +0000
commit9f5cd0315386e761beae8afd07df94e42a4db154 (patch)
tree6e64a92962daa43d7eb93fc072225d8e9ee79e6b /compiler/rustc_interface/src/interface.rs
parent42f75f1e462f90bfe20f458690113c3cb2a26271 (diff)
downloadrust-9f5cd0315386e761beae8afd07df94e42a4db154.tar.gz
rust-9f5cd0315386e761beae8afd07df94e42a4db154.zip
Move compiler input and ouput paths into session
Diffstat (limited to 'compiler/rustc_interface/src/interface.rs')
-rw-r--r--compiler/rustc_interface/src/interface.rs32
1 files changed, 10 insertions, 22 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs
index e3c4f9052ce..7a5e45ada3f 100644
--- a/compiler/rustc_interface/src/interface.rs
+++ b/compiler/rustc_interface/src/interface.rs
@@ -14,10 +14,10 @@ use rustc_middle::ty;
 use rustc_parse::maybe_new_parser_from_source_str;
 use rustc_query_impl::QueryCtxt;
 use rustc_session::config::{self, CheckCfg, ErrorOutputType, Input, OutputFilenames};
-use rustc_session::early_error;
 use rustc_session::lint;
 use rustc_session::parse::{CrateConfig, ParseSess};
 use rustc_session::Session;
+use rustc_session::{early_error, CompilerIO};
 use rustc_span::source_map::{FileLoader, FileName};
 use rustc_span::symbol::sym;
 use std::path::PathBuf;
@@ -35,19 +35,11 @@ pub type Result<T> = result::Result<T, ErrorGuaranteed>;
 pub struct Compiler {
     pub(crate) sess: Lrc<Session>,
     codegen_backend: Lrc<Box<dyn CodegenBackend>>,
-    pub(crate) io: CompilerIO,
     pub(crate) register_lints: Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>>,
     pub(crate) override_queries:
         Option<fn(&Session, &mut ty::query::Providers, &mut ty::query::ExternProviders)>,
 }
 
-pub struct CompilerIO {
-    pub input: Input,
-    pub output_dir: Option<PathBuf>,
-    pub output_file: Option<PathBuf>,
-    pub temps_dir: Option<PathBuf>,
-}
-
 impl Compiler {
     pub fn session(&self) -> &Lrc<Session> {
         &self.sess
@@ -55,9 +47,6 @@ impl Compiler {
     pub fn codegen_backend(&self) -> &Lrc<Box<dyn CodegenBackend>> {
         &self.codegen_backend
     }
-    pub fn io(&self) -> &CompilerIO {
-        &self.io
-    }
     pub fn register_lints(&self) -> &Option<Box<dyn Fn(&Session, &mut LintStore) + Send + Sync>> {
         &self.register_lints
     }
@@ -66,7 +55,7 @@ impl Compiler {
         sess: &Session,
         attrs: &[ast::Attribute],
     ) -> OutputFilenames {
-        util::build_output_filenames(&self.io, attrs, sess)
+        util::build_output_filenames(attrs, sess)
     }
 }
 
@@ -273,12 +262,19 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
             crate::callbacks::setup_callbacks();
 
             let registry = &config.registry;
+
+            let temps_dir = config.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
             let (mut sess, codegen_backend) = util::create_session(
                 config.opts,
                 config.crate_cfg,
                 config.crate_check_cfg,
                 config.file_loader,
-                config.input.opt_path(),
+                CompilerIO {
+                    input: config.input,
+                    output_dir: config.output_dir,
+                    output_file: config.output_file,
+                    temps_dir,
+                },
                 config.lint_caps,
                 config.make_codegen_backend,
                 registry.clone(),
@@ -288,17 +284,9 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
                 parse_sess_created(&mut sess.parse_sess);
             }
 
-            let temps_dir = sess.opts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
-
             let compiler = Compiler {
                 sess: Lrc::new(sess),
                 codegen_backend: Lrc::new(codegen_backend),
-                io: CompilerIO {
-                    input: config.input,
-                    output_dir: config.output_dir,
-                    output_file: config.output_file,
-                    temps_dir,
-                },
                 register_lints: config.register_lints,
                 override_queries: config.override_queries,
             };