about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2023-01-22 11:08:33 +0000
committerCamille GILLOT <gillot.camille@gmail.com>2023-01-22 11:13:19 +0000
commit4d11206ee78cd53bfd104c6073f3c8169da8828d (patch)
tree23685f8c4ada32a7e65bae6b41a9b41869fb04bf
parent6ecf30d67d7e82722ac7aff232378739e92f33e6 (diff)
downloadrust-4d11206ee78cd53bfd104c6073f3c8169da8828d.tar.gz
rust-4d11206ee78cd53bfd104c6073f3c8169da8828d.zip
Tweak comments.
-rw-r--r--compiler/rustc_metadata/src/rmeta/encoder.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 6227d01bcfa..0dba9a32f9c 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -1216,12 +1216,13 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
                     }
                 }
             ));
+        } else {
+            // For non-enum, there is only one variant, and its def_id is the adt's.
+            debug_assert_eq!(adt_def.variants().len(), 1);
+            debug_assert_eq!(adt_def.non_enum_variant().def_id, def_id);
+            // Therefore, the loop over variants will encode its fields as the adt's children.
         }
 
-        // In some cases, along with the item itself, we also
-        // encode some sub-items. Usually we want some info from the item
-        // so it's easier to do that here then to wait until we would encounter
-        // normally in the visitor walk.
         for variant in adt_def.variants().iter() {
             let data = VariantData {
                 discr: variant.discr,