about summary refs log tree commit diff
path: root/compiler/rustc_monomorphize
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-06-07 07:05:45 +0200
committerGitHub <noreply@github.com>2025-06-07 07:05:45 +0200
commit9f35917dd958307b128da331d2c0fad0ac63515a (patch)
tree5e726793d56f006bbca2d9d76d6db43186c1f1b8 /compiler/rustc_monomorphize
parent06a2daf4db450133510b2834f2483a68b026ef2c (diff)
parentfdb660e8514ad09ebd9a478516d66b924c839f55 (diff)
downloadrust-9f35917dd958307b128da331d2c0fad0ac63515a.tar.gz
rust-9f35917dd958307b128da331d2c0fad0ac63515a.zip
Rollup merge of #141558 - Diggsey:db-limit-cgu-name-length, r=matthewjasper
Limit the size of cgu names when using the `-Zhuman-readable-cgu-name…

…s` option

Prior to this change, cgu names could be generated which would result in filenames longer than the limit imposed by the OS.
Diffstat (limited to 'compiler/rustc_monomorphize')
-rw-r--r--compiler/rustc_monomorphize/src/partitioning.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs
index b4169a060d4..49025673bbd 100644
--- a/compiler/rustc_monomorphize/src/partitioning.rs
+++ b/compiler/rustc_monomorphize/src/partitioning.rs
@@ -461,15 +461,15 @@ fn merge_codegen_units<'tcx>(
 
         for cgu in codegen_units.iter_mut() {
             if let Some(new_cgu_name) = new_cgu_names.get(&cgu.name()) {
-                if cx.tcx.sess.opts.unstable_opts.human_readable_cgu_names {
-                    cgu.set_name(Symbol::intern(new_cgu_name));
+                let new_cgu_name = if cx.tcx.sess.opts.unstable_opts.human_readable_cgu_names {
+                    Symbol::intern(&CodegenUnit::shorten_name(new_cgu_name))
                 } else {
                     // If we don't require CGU names to be human-readable,
                     // we use a fixed length hash of the composite CGU name
                     // instead.
-                    let new_cgu_name = CodegenUnit::mangle_name(new_cgu_name);
-                    cgu.set_name(Symbol::intern(&new_cgu_name));
-                }
+                    Symbol::intern(&CodegenUnit::mangle_name(new_cgu_name))
+                };
+                cgu.set_name(new_cgu_name);
             }
         }