Skip to content

Commit d1bb7e1

Browse files
Mark-Simulacrumsinkuu
authored andcommitted
Privatize private fields of OutputFilenames
1 parent b5a3341 commit d1bb7e1

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

src/librustc_interface/util.rs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,13 @@ pub fn build_output_filenames(
550550
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
551551
.unwrap_or_else(|| input.filestem().to_owned());
552552

553-
OutputFilenames {
554-
out_directory: dirpath,
555-
out_filestem: stem,
556-
single_output_file: None,
557-
extra: sess.opts.cg.extra_filename.clone(),
558-
outputs: sess.opts.output_types.clone(),
559-
}
553+
OutputFilenames::new(
554+
dirpath,
555+
stem,
556+
None,
557+
sess.opts.cg.extra_filename.clone(),
558+
sess.opts.output_types.clone(),
559+
)
560560
}
561561

562562
Some(ref out_file) => {
@@ -578,18 +578,13 @@ pub fn build_output_filenames(
578578
sess.warn("ignoring --out-dir flag due to -o flag");
579579
}
580580

581-
OutputFilenames {
582-
out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
583-
out_filestem: out_file
584-
.file_stem()
585-
.unwrap_or_default()
586-
.to_str()
587-
.unwrap()
588-
.to_string(),
589-
single_output_file: ofile,
590-
extra: sess.opts.cg.extra_filename.clone(),
591-
outputs: sess.opts.output_types.clone(),
592-
}
581+
OutputFilenames::new(
582+
out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
583+
out_file.file_stem().unwrap_or_default().to_str().unwrap().to_string(),
584+
ofile,
585+
sess.opts.cg.extra_filename.clone(),
586+
sess.opts.output_types.clone(),
587+
)
593588
}
594589
}
595590
}

src/librustc_session/config.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ impl Input {
447447
#[derive(Clone, Hash)]
448448
pub struct OutputFilenames {
449449
pub out_directory: PathBuf,
450-
pub out_filestem: String,
450+
out_filestem: String,
451451
pub single_output_file: Option<PathBuf>,
452-
pub extra: String,
452+
extra: String,
453453
pub outputs: OutputTypes,
454454
}
455455

@@ -458,6 +458,16 @@ impl_stable_hash_via_hash!(OutputFilenames);
458458
pub const RUST_CGU_EXT: &str = "rcgu";
459459

460460
impl OutputFilenames {
461+
pub fn new(
462+
out_directory: PathBuf,
463+
out_filestem: String,
464+
single_output_file: Option<PathBuf>,
465+
extra: String,
466+
outputs: OutputTypes,
467+
) -> Self {
468+
OutputFilenames { out_directory, out_filestem, single_output_file, extra, outputs }
469+
}
470+
461471
pub fn path(&self, flavor: OutputType) -> PathBuf {
462472
self.outputs
463473
.get(&flavor)

0 commit comments

Comments
 (0)