From 42f75f1e462f90bfe20f458690113c3cb2a26271 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 7 Dec 2022 08:42:21 +0000 Subject: Group some commonly passed together values into a struct --- compiler/rustc_interface/src/interface.rs | 44 ++++++++++++------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'compiler/rustc_interface/src/interface.rs') diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 22a01db5e75..e3c4f9052ce 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -35,15 +35,19 @@ pub type Result = result::Result; pub struct Compiler { pub(crate) sess: Lrc, codegen_backend: Lrc>, - pub(crate) input: Input, - pub(crate) output_dir: Option, - pub(crate) output_file: Option, - pub(crate) temps_dir: Option, + pub(crate) io: CompilerIO, pub(crate) register_lints: Option>, pub(crate) override_queries: Option, } +pub struct CompilerIO { + pub input: Input, + pub output_dir: Option, + pub output_file: Option, + pub temps_dir: Option, +} + impl Compiler { pub fn session(&self) -> &Lrc { &self.sess @@ -51,17 +55,8 @@ impl Compiler { pub fn codegen_backend(&self) -> &Lrc> { &self.codegen_backend } - pub fn input(&self) -> &Input { - &self.input - } - pub fn output_dir(&self) -> &Option { - &self.output_dir - } - pub fn output_file(&self) -> &Option { - &self.output_file - } - pub fn temps_dir(&self) -> &Option { - &self.temps_dir + pub fn io(&self) -> &CompilerIO { + &self.io } pub fn register_lints(&self) -> &Option> { &self.register_lints @@ -71,14 +66,7 @@ impl Compiler { sess: &Session, attrs: &[ast::Attribute], ) -> OutputFilenames { - util::build_output_filenames( - &self.input, - &self.output_dir, - &self.output_file, - &self.temps_dir, - attrs, - sess, - ) + util::build_output_filenames(&self.io, attrs, sess) } } @@ -305,10 +293,12 @@ pub fn run_compiler(config: Config, f: impl FnOnce(&Compiler) -> R + Se let compiler = Compiler { sess: Lrc::new(sess), codegen_backend: Lrc::new(codegen_backend), - input: config.input, - output_dir: config.output_dir, - output_file: config.output_file, - temps_dir, + 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, }; -- cgit 1.4.1-3-g733a5