Skip to content

Commit

Permalink
Privatize private fields of OutputFilenames
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum authored and sinkuu committed Jan 21, 2020
1 parent b5a3341 commit d1bb7e1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
33 changes: 14 additions & 19 deletions src/librustc_interface/util.rs
Expand Up @@ -550,13 +550,13 @@ pub fn build_output_filenames(
.or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
.unwrap_or_else(|| input.filestem().to_owned());

OutputFilenames {
out_directory: dirpath,
out_filestem: stem,
single_output_file: None,
extra: sess.opts.cg.extra_filename.clone(),
outputs: sess.opts.output_types.clone(),
}
OutputFilenames::new(
dirpath,
stem,
None,
sess.opts.cg.extra_filename.clone(),
sess.opts.output_types.clone(),
)
}

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

OutputFilenames {
out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
out_filestem: out_file
.file_stem()
.unwrap_or_default()
.to_str()
.unwrap()
.to_string(),
single_output_file: ofile,
extra: sess.opts.cg.extra_filename.clone(),
outputs: sess.opts.output_types.clone(),
}
OutputFilenames::new(
out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
out_file.file_stem().unwrap_or_default().to_str().unwrap().to_string(),
ofile,
sess.opts.cg.extra_filename.clone(),
sess.opts.output_types.clone(),
)
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/librustc_session/config.rs
Expand Up @@ -447,9 +447,9 @@ impl Input {
#[derive(Clone, Hash)]
pub struct OutputFilenames {
pub out_directory: PathBuf,
pub out_filestem: String,
out_filestem: String,
pub single_output_file: Option<PathBuf>,
pub extra: String,
extra: String,
pub outputs: OutputTypes,
}

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

impl OutputFilenames {
pub fn new(
out_directory: PathBuf,
out_filestem: String,
single_output_file: Option<PathBuf>,
extra: String,
outputs: OutputTypes,
) -> Self {
OutputFilenames { out_directory, out_filestem, single_output_file, extra, outputs }
}

pub fn path(&self, flavor: OutputType) -> PathBuf {
self.outputs
.get(&flavor)
Expand Down

0 comments on commit d1bb7e1

Please sign in to comment.