[pushed] Trivially simplify rust_language::print_enum

Message ID 20230209191609.493729-1-tom@tromey.com
State Committed
Commit 8ac460b742bc7f49acbcd78f8822386f56814055
Headers
Series [pushed] Trivially simplify rust_language::print_enum |

Commit Message

Tom Tromey Feb. 9, 2023, 7:16 p.m. UTC
  rust_language::print_enum computes:

  int nfields = variant_type->num_fields ();

... but then does not reuse this in one spot.  This patch corrects the
oversight.
---
 gdb/rust-lang.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 6653f7a9c64..f2017f95211 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -495,7 +495,7 @@  rust_language::print_enum (struct value *val, struct ui_file *stream,
     }
 
   bool first_field = true;
-  for (int j = 0; j < variant_type->num_fields (); j++)
+  for (int j = 0; j < nfields; j++)
     {
       if (!first_field)
 	gdb_puts (", ", stream);