diff options
| author | Michael Goulet <michael@errs.io> | 2025-01-14 16:32:17 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-01-14 16:33:03 +0000 |
| commit | faafa5c3107344adc5e57dd6d6dc74e019bd7daf (patch) | |
| tree | 6247aab15e33818ec17d2b5799cf86f8a6bc4c9b | |
| parent | 2ae9916816a448fcaab3b2da461de754eda0055a (diff) | |
| download | rust-faafa5c3107344adc5e57dd6d6dc74e019bd7daf.tar.gz rust-faafa5c3107344adc5e57dd6d6dc74e019bd7daf.zip | |
Fix legacy symbol mangling of closures
| -rw-r--r-- | compiler/rustc_symbol_mangling/src/legacy.rs | 8 | ||||
| -rw-r--r-- | tests/codegen-units/item-collection/closures.rs | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 58c0a05df1f..879f3fac21f 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -19,15 +19,15 @@ pub(super) fn mangle<'tcx>( let def_id = instance.def_id(); // We want to compute the "type" of this item. Unfortunately, some - // kinds of items (e.g., closures) don't have an entry in the - // item-type array. So walk back up the find the closest parent - // that DOES have an entry. + // kinds of items (e.g., synthetic static allocations from const eval) + // don't have a proper implementation for the `type_of` query. So walk + // back up the find the closest parent that DOES have a type. let mut ty_def_id = def_id; let instance_ty; loop { let key = tcx.def_key(ty_def_id); match key.disambiguated_data.data { - DefPathData::TypeNs(_) | DefPathData::ValueNs(_) => { + DefPathData::TypeNs(_) | DefPathData::ValueNs(_) | DefPathData::Closure => { instance_ty = tcx.type_of(ty_def_id).instantiate_identity(); debug!(?instance_ty); break; diff --git a/tests/codegen-units/item-collection/closures.rs b/tests/codegen-units/item-collection/closures.rs index 5fc80230925..864f98817a8 100644 --- a/tests/codegen-units/item-collection/closures.rs +++ b/tests/codegen-units/item-collection/closures.rs @@ -10,3 +10,9 @@ pub async fn async_fn() {} pub fn closure() { let _ = || {}; } + +//~ MONO_ITEM fn A::{constant#0}::{closure#0} @@ +trait A where + [(); (|| {}, 1).1]: Sized, +{ +} |
