diff options
| author | Ralf Jung <post@ralfj.de> | 2024-12-01 13:12:43 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-12-18 11:00:21 +0100 |
| commit | 4d1e772f97043c1b327af5ee2cdc3a21efa951c1 (patch) | |
| tree | e938768bae83d44794831ae698e26698e150ba96 | |
| parent | a845ca75a09e743b9ad07075e5344cf6dbd042ab (diff) | |
| download | rust-4d1e772f97043c1b327af5ee2cdc3a21efa951c1.tar.gz rust-4d1e772f97043c1b327af5ee2cdc3a21efa951c1.zip | |
Variants::Single: do not use invalid VariantIdx for uninhabited enums
| -rw-r--r-- | src/type_of.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/type_of.rs b/src/type_of.rs index 0efdf36da48..426d28f4ed7 100644 --- a/src/type_of.rs +++ b/src/type_of.rs @@ -99,14 +99,14 @@ fn uncached_gcc_type<'gcc, 'tcx>( if !cx.sess().fewer_names() => { let mut name = with_no_trimmed_paths!(layout.ty.to_string()); - if let (&ty::Adt(def, _), &Variants::Single { index }) = + if let (&ty::Adt(def, _), &Variants::Single { index: Some(index) }) = (layout.ty.kind(), &layout.variants) { if def.is_enum() && !def.variants().is_empty() { write!(&mut name, "::{}", def.variant(index).name).unwrap(); } } - if let (&ty::Coroutine(_, _), &Variants::Single { index }) = + if let (&ty::Coroutine(_, _), &Variants::Single { index: Some(index) }) = (layout.ty.kind(), &layout.variants) { write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap(); @@ -230,7 +230,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> { // Check the cache. let variant_index = match self.variants { - Variants::Single { index } => Some(index), + Variants::Single { index } => index, _ => None, }; let cached_type = cx.types.borrow().get(&(self.ty, variant_index)).cloned(); |
