about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize
diff options
context:
space:
mode:
authorJoshua Nelson <github@jyn.dev>2022-12-29 21:53:13 +0000
committerJoshua Nelson <github@jyn.dev>2023-01-02 23:02:58 +0000
commit5c79624bfaf28540b739f33ffe9d2d1f132555d2 (patch)
treee118639297ff7ad8e3b96b77488778910f492532 /compiler/rustc_monomorphize
parenteb53eea60920e28d3c3e053b170d015be7493a74 (diff)
downloadrust-5c79624bfaf28540b739f33ffe9d2d1f132555d2.tar.gz
rust-5c79624bfaf28540b739f33ffe9d2d1f132555d2.zip
Fix `unknown_crate` when `--crate-name` isn't passed on the CLI
Diffstat (limited to 'compiler/rustc_monomorphize')
-rw-r--r--compiler/rustc_monomorphize/src/partitioning/mod.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning/mod.rs b/compiler/rustc_monomorphize/src/partitioning/mod.rs
index f0417b06a04..97fbb458e79 100644
--- a/compiler/rustc_monomorphize/src/partitioning/mod.rs
+++ b/compiler/rustc_monomorphize/src/partitioning/mod.rs
@@ -102,7 +102,7 @@ use std::path::{Path, PathBuf};
 
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_data_structures::sync;
-use rustc_hir::def_id::DefIdSet;
+use rustc_hir::def_id::{DefIdSet, LOCAL_CRATE};
 use rustc_middle::mir;
 use rustc_middle::mir::mono::MonoItem;
 use rustc_middle::mir::mono::{CodegenUnit, Linkage};
@@ -417,7 +417,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
     // Output monomorphization stats per def_id
     if let SwitchWithOptPath::Enabled(ref path) = tcx.sess.opts.unstable_opts.dump_mono_stats {
         if let Err(err) =
-            dump_mono_items_stats(tcx, &codegen_units, path, tcx.sess.opts.crate_name.as_deref())
+            dump_mono_items_stats(tcx, &codegen_units, path, tcx.crate_name(LOCAL_CRATE))
         {
             tcx.sess.emit_fatal(CouldntDumpMonoStats { error: err.to_string() });
         }
@@ -483,7 +483,7 @@ fn dump_mono_items_stats<'tcx>(
     tcx: TyCtxt<'tcx>,
     codegen_units: &[CodegenUnit<'tcx>],
     output_directory: &Option<PathBuf>,
-    crate_name: Option<&str>,
+    crate_name: Symbol,
 ) -> Result<(), Box<dyn std::error::Error>> {
     let output_directory = if let Some(ref directory) = output_directory {
         fs::create_dir_all(directory)?;
@@ -494,7 +494,7 @@ fn dump_mono_items_stats<'tcx>(
 
     let format = tcx.sess.opts.unstable_opts.dump_mono_stats_format;
     let ext = format.extension();
-    let filename = format!("{}.mono_items.{ext}", crate_name.unwrap_or("unknown-crate"));
+    let filename = format!("{crate_name}.mono_items.{ext}");
     let output_path = output_directory.join(&filename);
     let file = File::create(&output_path)?;
     let mut file = BufWriter::new(file);