public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [FYI 1/3] Use std::string in Rust code
  2017-02-03  4:28 [FYI 0/3] some trivial Rust changes Tom Tromey
@ 2017-02-03  4:28 ` Tom Tromey
  2017-02-03  4:28 ` [FYI 3/3] Use bool " Tom Tromey
  2017-02-03  4:28 ` [FYI 2/3] Reindent rust-lang.c Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2017-02-03  4:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes a couple of spots in the Rust support to use std::string.
In one spot this removes some manual memory management; in the other
spot this allows the removal of a call to xstrdup.

2017-02-02  Tom Tromey  <tom@tromey.com>

	* rust-lang.h (rust_crate_for_block): Update.
	* rust-lang.c (rust_crate_for_block): Return std::string.
	(rust_get_disr_info): Use std:;string, not
	gdb::unique_xmalloc_ptr.
	* rust-exp.y (crate_name): Update.
---
 gdb/ChangeLog   |  8 ++++++++
 gdb/rust-exp.y  |  7 +++----
 gdb/rust-lang.c | 14 ++++++--------
 gdb/rust-lang.h |  7 +++----
 4 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 202c90c..cb47f73 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2017-02-02  Tom Tromey  <tom@tromey.com>
+
+	* rust-lang.h (rust_crate_for_block): Update.
+	* rust-lang.c (rust_crate_for_block): Return std::string.
+	(rust_get_disr_info): Use std:;string, not
+	gdb::unique_xmalloc_ptr.
+	* rust-exp.y (crate_name): Update.
+
 2017-02-02  Pedro Alves  <palves@redhat.com>
 
 	* disasm-selftests.c (print_one_insn_test): Move the "verbose"
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index a97ca67..98301a4 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -941,16 +941,15 @@ rust_concat3 (const char *s1, const char *s2, const char *s3)
 static const struct rust_op *
 crate_name (const struct rust_op *name)
 {
-  char *crate = rust_crate_for_block (expression_context_block);
+  std::string crate = rust_crate_for_block (expression_context_block);
   struct stoken result;
 
   gdb_assert (name->opcode == OP_VAR_VALUE);
 
-  if (crate == NULL)
+  if (crate.empty ())
     error (_("Could not find crate for current location"));
-  result = make_stoken (obconcat (&work_obstack, "::", crate, "::",
+  result = make_stoken (obconcat (&work_obstack, "::", crate.c_str (), "::",
 				  name->left.sval.ptr, (char *) NULL));
-  xfree (crate);
 
   return ast_path (result, name->right.params);
 }
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index dd72cd9..17df6bb 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -51,19 +51,17 @@ rust_last_path_segment (const char * path)
   return result + 1;
 }
 
-/* Find the Rust crate for BLOCK.  If no crate can be found, returns
-   NULL.  Otherwise, returns a newly allocated string that the caller
-   is responsible for freeing.  */
+/* See rust-lang.h.  */
 
-char *
+std::string
 rust_crate_for_block (const struct block *block)
 {
   const char *scope = block_scope (block);
 
   if (scope[0] == '\0')
-    return NULL;
+    return std::string ();
 
-  return xstrndup (scope, cp_find_first_component (scope));
+  return std::string (scope, cp_find_first_component (scope));
 }
 
 /* Information about the discriminant/variant of an enum */
@@ -157,8 +155,8 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
       /* Optimized enums have only one field.  */
       member_type = TYPE_FIELD_TYPE (type, 0);
 
-      gdb::unique_xmalloc_ptr<char> name (xstrdup (TYPE_FIELD_NAME (type, 0)));
-      tail = name.get () + strlen (RUST_ENUM_PREFIX);
+      std::string name (TYPE_FIELD_NAME (type, 0));
+      tail = &name[0] + strlen (RUST_ENUM_PREFIX);
 
       /* The location of the value that doubles as a discriminant is
          stored in the name of the field, as
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 70da69f..6c627ae 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -35,10 +35,9 @@ extern int rust_tuple_type_p (struct type *type);
 /* Return true if TYPE is a tuple struct type; otherwise false.  */
 extern int rust_tuple_struct_type_p (struct type *type);
 
-/* Given a block, find the name of the block's crate.  The name must
-   be freed by the caller.  Returns NULL if no crate name can be
-   found.  */
-extern char *rust_crate_for_block (const struct block *block);
+/* Given a block, find the name of the block's crate. Returns an empty
+   stringif no crate name can be found.  */
+extern std::string rust_crate_for_block (const struct block *block);
 
 /* Create a new slice type.  NAME is the name of the type.  ELT_TYPE
    is the type of the elements of the slice.  USIZE_TYPE is the Rust
-- 
2.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FYI 3/3] Use bool in Rust code
  2017-02-03  4:28 [FYI 0/3] some trivial Rust changes Tom Tromey
  2017-02-03  4:28 ` [FYI 1/3] Use std::string in Rust code Tom Tromey
@ 2017-02-03  4:28 ` Tom Tromey
  2017-02-03  4:28 ` [FYI 2/3] Reindent rust-lang.c Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2017-02-03  4:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes various functions in the Rust code to use a bool rather
than an int when a boolean is intended.

2017-02-02  Tom Tromey  <tom@tromey.com>

	* rust-exp.y (ends_raw_string, space_then_number)
	(rust_identifier_start_p): Return bool.
	* rust-lang.c (rust_tuple_type_p, rust_underscore_fields)
	(rust_tuple_struct_type_p, rust_tuple_variant_type_p)
	(rust_slice_type_p, rust_range_type_p, rust_u8_type_p)
	(rust_chartype_p): Return bool.
	(val_print_struct, rust_print_struct_def, rust_print_type):
	Update.
	* rust-lang.h (rust_tuple_type_p, rust_tuple_struct_type_p):
	Return bool.
---
 gdb/ChangeLog   | 13 +++++++++++++
 gdb/rust-exp.y  | 12 ++++++------
 gdb/rust-lang.c | 39 ++++++++++++++++++++-------------------
 gdb/rust-lang.h |  4 ++--
 4 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d133a2e..2f5ba2f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
 2017-02-02  Tom Tromey  <tom@tromey.com>
 
+	* rust-exp.y (ends_raw_string, space_then_number)
+	(rust_identifier_start_p): Return bool.
+	* rust-lang.c (rust_tuple_type_p, rust_underscore_fields)
+	(rust_tuple_struct_type_p, rust_tuple_variant_type_p)
+	(rust_slice_type_p, rust_range_type_p, rust_u8_type_p)
+	(rust_chartype_p): Return bool.
+	(val_print_struct, rust_print_struct_def, rust_print_type):
+	Update.
+	* rust-lang.h (rust_tuple_type_p, rust_tuple_struct_type_p):
+	Return bool.
+
+2017-02-02  Tom Tromey  <tom@tromey.com>
+
 	* rust-lang.c: Reindent.
 
 2017-02-02  Tom Tromey  <tom@tromey.com>
diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
index 98301a4..b3e0366 100644
--- a/gdb/rust-exp.y
+++ b/gdb/rust-exp.y
@@ -1197,7 +1197,7 @@ starts_raw_string (const char *str)
 /* Return true if STR looks like the end of a raw string that had N
    hashes at the start.  */
 
-static int
+static bool
 ends_raw_string (const char *str, int n)
 {
   int i;
@@ -1205,8 +1205,8 @@ ends_raw_string (const char *str, int n)
   gdb_assert (str[0] == '"');
   for (i = 0; i < n; ++i)
     if (str[i + 1] != '#')
-      return 0;
-  return 1;
+      return false;
+  return true;
 }
 
 /* Lex a string constant.  */
@@ -1283,7 +1283,7 @@ lex_string (void)
 
 /* Return true if STRING starts with whitespace followed by a digit.  */
 
-static int
+static bool
 space_then_number (const char *string)
 {
   const char *p = string;
@@ -1291,14 +1291,14 @@ space_then_number (const char *string)
   while (p[0] == ' ' || p[0] == '\t')
     ++p;
   if (p == string)
-    return 0;
+    return false;
 
   return *p >= '0' && *p <= '9';
 }
 
 /* Return true if C can start an identifier.  */
 
-static int
+static bool
 rust_identifier_start_p (char c)
 {
   return ((c >= 'a' && c <= 'z')
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index a483b96..a804824 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -272,7 +272,7 @@ rust_get_disr_info (struct type *type, const gdb_byte *valaddr,
 
 /* See rust-lang.h.  */
 
-int
+bool
 rust_tuple_type_p (struct type *type)
 {
   /* The current implementation is a bit of a hack, but there's
@@ -287,7 +287,7 @@ rust_tuple_type_p (struct type *type)
 /* Return true if all non-static fields of a structlike type are in a
    sequence like __0, __1, __2.  OFFSET lets us skip fields.  */
 
-static int
+static bool
 rust_underscore_fields (struct type *type, int offset)
 {
   int i, field_number;
@@ -295,7 +295,7 @@ rust_underscore_fields (struct type *type, int offset)
   field_number = 0;
 
   if (TYPE_CODE (type) != TYPE_CODE_STRUCT)
-    return 0;
+    return false;
   for (i = 0; i < TYPE_NFIELDS (type); ++i)
     {
       if (!field_is_static (&TYPE_FIELD (type, i)))
@@ -308,17 +308,17 @@ rust_underscore_fields (struct type *type, int offset)
 
 	      xsnprintf (buf, sizeof (buf), "__%d", field_number);
 	      if (strcmp (buf, TYPE_FIELD_NAME (type, i)) != 0)
-		return 0;
+		return false;
 	      field_number++;
 	    }
 	}
     }
-  return 1;
+  return true;
 }
 
 /* See rust-lang.h.  */
 
-int
+bool
 rust_tuple_struct_type_p (struct type *type)
 {
   /* This is just an approximation until DWARF can represent Rust more
@@ -329,7 +329,7 @@ rust_tuple_struct_type_p (struct type *type)
 
 /* Return true if a variant TYPE is a tuple variant, false otherwise.  */
 
-static int
+static bool
 rust_tuple_variant_type_p (struct type *type)
 {
   /* First field is discriminant */
@@ -338,7 +338,7 @@ rust_tuple_variant_type_p (struct type *type)
 
 /* Return true if TYPE is a slice type, otherwise false.  */
 
-static int
+static bool
 rust_slice_type_p (struct type *type)
 {
   return (TYPE_CODE (type) == TYPE_CODE_STRUCT
@@ -348,7 +348,7 @@ rust_slice_type_p (struct type *type)
 
 /* Return true if TYPE is a range type, otherwise false.  */
 
-static int
+static bool
 rust_range_type_p (struct type *type)
 {
   int i;
@@ -357,22 +357,22 @@ rust_range_type_p (struct type *type)
       || TYPE_NFIELDS (type) > 2
       || TYPE_TAG_NAME (type) == NULL
       || strstr (TYPE_TAG_NAME (type), "::Range") == NULL)
-    return 0;
+    return false;
 
   if (TYPE_NFIELDS (type) == 0)
-    return 1;
+    return true;
 
   i = 0;
   if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
     {
       if (TYPE_NFIELDS (type) == 1)
-	return 1;
+	return true;
       i = 1;
     }
   else if (TYPE_NFIELDS (type) == 2)
     {
       /* First field had to be "start".  */
-      return 0;
+      return false;
     }
 
   return strcmp (TYPE_FIELD_NAME (type, i), "end") == 0;
@@ -380,7 +380,7 @@ rust_range_type_p (struct type *type)
 
 /* Return true if TYPE seems to be the type "u8", otherwise false.  */
 
-static int
+static bool
 rust_u8_type_p (struct type *type)
 {
   return (TYPE_CODE (type) == TYPE_CODE_INT
@@ -390,7 +390,7 @@ rust_u8_type_p (struct type *type)
 
 /* Return true if TYPE is a Rust character type.  */
 
-static int
+static bool
 rust_chartype_p (struct type *type)
 {
   return (TYPE_CODE (type) == TYPE_CODE_CHAR
@@ -479,8 +479,8 @@ val_print_struct (struct type *type, int embedded_offset,
 {
   int i;
   int first_field;
-  int is_tuple = rust_tuple_type_p (type);
-  int is_tuple_struct = !is_tuple && rust_tuple_struct_type_p (type);
+  bool is_tuple = rust_tuple_type_p (type);
+  bool is_tuple_struct = !is_tuple && rust_tuple_struct_type_p (type);
   struct value_print_options opts;
 
   if (!is_tuple)
@@ -763,7 +763,8 @@ rust_print_struct_def (struct type *type, const char *varstring,
 		       struct ui_file *stream, int show, int level,
 		       const struct type_print_options *flags)
 {
-  int is_tuple_struct, i;
+  bool is_tuple_struct;
+  int i;
 
   /* Print a tuple type simply.  */
   if (rust_tuple_type_p (type))
@@ -988,7 +989,7 @@ rust_print_type (struct type *type, const char *varstring,
 	    if (TYPE_NFIELDS (variant_type) > skip_to)
 	      {
 		int first = 1;
-		int is_tuple = rust_tuple_variant_type_p (variant_type);
+		bool is_tuple = rust_tuple_variant_type_p (variant_type);
 		int j;
 
 		fputs_filtered (is_tuple ? "(" : "{", stream);
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 6c627ae..8f2b682 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -30,10 +30,10 @@ extern int rust_parse (struct parser_state *);
 extern void rustyyerror (char *);
 
 /* Return true if TYPE is a tuple type; otherwise false.  */
-extern int rust_tuple_type_p (struct type *type);
+extern bool rust_tuple_type_p (struct type *type);
 
 /* Return true if TYPE is a tuple struct type; otherwise false.  */
-extern int rust_tuple_struct_type_p (struct type *type);
+extern bool rust_tuple_struct_type_p (struct type *type);
 
 /* Given a block, find the name of the block's crate. Returns an empty
    stringif no crate name can be found.  */
-- 
2.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FYI 2/3] Reindent rust-lang.c
  2017-02-03  4:28 [FYI 0/3] some trivial Rust changes Tom Tromey
  2017-02-03  4:28 ` [FYI 1/3] Use std::string in Rust code Tom Tromey
  2017-02-03  4:28 ` [FYI 3/3] Use bool " Tom Tromey
@ 2017-02-03  4:28 ` Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2017-02-03  4:28 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

I noticed a few spots in rust-lang.c had incorrect indentation.  This
patch fixes this.

2017-02-02  Tom Tromey  <tom@tromey.com>

	* rust-lang.c: Reindent.
---
 gdb/ChangeLog   |   4 ++
 gdb/rust-lang.c | 146 ++++++++++++++++++++++++++++----------------------------
 2 files changed, 77 insertions(+), 73 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cb47f73..d133a2e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2017-02-02  Tom Tromey  <tom@tromey.com>
 
+	* rust-lang.c: Reindent.
+
+2017-02-02  Tom Tromey  <tom@tromey.com>
+
 	* rust-lang.h (rust_crate_for_block): Update.
 	* rust-lang.c (rust_crate_for_block): Return std::string.
 	(rust_get_disr_info): Use std:;string, not
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 17df6bb..a483b96 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -100,7 +100,7 @@ rust_union_is_untagged (struct type *type)
   if (TYPE_NFIELDS (type) == 0)
     return false;
   /* If the first field is named, but the name has the rust enum prefix,
-      it is an enum.  */
+     it is an enum.  */
   if (strncmp (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX,
 	       strlen (RUST_ENUM_PREFIX)) == 0)
     return false;
@@ -514,8 +514,8 @@ val_print_struct (struct type *type, int embedded_offset,
 
       if (options->prettyformat)
         {
-    fputs_filtered ("\n", stream);
-    print_spaces_filtered (2 + 2 * recurse, stream);
+	  fputs_filtered ("\n", stream);
+	  print_spaces_filtered (2 + 2 * recurse, stream);
         }
       else if (!first_field)
         fputs_filtered (" ", stream);
@@ -524,15 +524,15 @@ val_print_struct (struct type *type, int embedded_offset,
 
       if (!is_tuple && !is_tuple_struct)
         {
-    fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
-    fputs_filtered (": ", stream);
+	  fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
+	  fputs_filtered (": ", stream);
         }
 
       val_print (TYPE_FIELD_TYPE (type, i),
-           embedded_offset + TYPE_FIELD_BITPOS (type, i) / 8,
-           address,
-           stream, recurse + 1, val, &opts,
-           current_language);
+		 embedded_offset + TYPE_FIELD_BITPOS (type, i) / 8,
+		 address,
+		 stream, recurse + 1, val, &opts,
+		 current_language);
     }
 
   if (options->prettyformat)
@@ -659,17 +659,17 @@ rust_val_print (struct type *type, int embedded_offset,
 	struct disr_info disr;
 	struct value_print_options opts;
 
-  /* Untagged unions are printed as if they are structs.
-     Since the field bit positions overlap in the debuginfo,
-     the code for printing a union is same as that for a struct,
-     the only difference is that the input type will have overlapping
-     fields.  */
-  if (rust_union_is_untagged (type))
-    {
-      val_print_struct (type, embedded_offset, address, stream,
-			  recurse, val, options);
-      break;
-    }
+	/* Untagged unions are printed as if they are structs.
+	   Since the field bit positions overlap in the debuginfo,
+	   the code for printing a union is same as that for a struct,
+	   the only difference is that the input type will have overlapping
+	   fields.  */
+	if (rust_union_is_untagged (type))
+	  {
+	    val_print_struct (type, embedded_offset, address, stream,
+			      recurse, val, options);
+	    break;
+	  }
 
 	opts = *options;
 	opts.deref_ref = 0;
@@ -760,62 +760,62 @@ rust_print_type (struct type *type, const char *varstring,
 /* Print a struct or union typedef.  */
 static void
 rust_print_struct_def (struct type *type, const char *varstring,
-		                   struct ui_file *stream, int show, int level,
-		                   const struct type_print_options *flags)
+		       struct ui_file *stream, int show, int level,
+		       const struct type_print_options *flags)
 {
-	int is_tuple_struct, i;
+  int is_tuple_struct, i;
 
-	/* Print a tuple type simply.  */
-	if (rust_tuple_type_p (type))
-	  {
-	    fputs_filtered (TYPE_TAG_NAME (type), stream);
-	    return;
-	  }
+  /* Print a tuple type simply.  */
+  if (rust_tuple_type_p (type))
+    {
+      fputs_filtered (TYPE_TAG_NAME (type), stream);
+      return;
+    }
 
-	/* If we see a base class, delegate to C.  */
-	if (TYPE_N_BASECLASSES (type) > 0)
-	  c_print_type (type, varstring, stream, show, level, flags);
+  /* If we see a base class, delegate to C.  */
+  if (TYPE_N_BASECLASSES (type) > 0)
+    c_print_type (type, varstring, stream, show, level, flags);
 
   /* This code path is also used by unions.  */
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
-	  fputs_filtered ("struct ", stream);
+    fputs_filtered ("struct ", stream);
   else
-	  fputs_filtered ("union ", stream);
+    fputs_filtered ("union ", stream);
 
-	if (TYPE_TAG_NAME (type) != NULL)
-	  fputs_filtered (TYPE_TAG_NAME (type), stream);
+  if (TYPE_TAG_NAME (type) != NULL)
+    fputs_filtered (TYPE_TAG_NAME (type), stream);
 
-	is_tuple_struct = rust_tuple_struct_type_p (type);
+  is_tuple_struct = rust_tuple_struct_type_p (type);
 
-	if (TYPE_NFIELDS (type) == 0 && !rust_tuple_type_p (type))
-	  return;
-	fputs_filtered (is_tuple_struct ? " (\n" : " {\n", stream);
+  if (TYPE_NFIELDS (type) == 0 && !rust_tuple_type_p (type))
+    return;
+  fputs_filtered (is_tuple_struct ? " (\n" : " {\n", stream);
 
-	for (i = 0; i < TYPE_NFIELDS (type); ++i)
-	  {
-	    const char *name;
+  for (i = 0; i < TYPE_NFIELDS (type); ++i)
+    {
+      const char *name;
 
-	    QUIT;
-	    if (field_is_static (&TYPE_FIELD (type, i)))
-	      continue;
-
-	    /* We'd like to print "pub" here as needed, but rustc
-	       doesn't emit the debuginfo, and our types don't have
-	       cplus_struct_type attached.  */
-
-	    /* For a tuple struct we print the type but nothing
-	       else.  */
-	    print_spaces_filtered (level + 2, stream);
-	    if (!is_tuple_struct)
-	      fprintf_filtered (stream, "%s: ", TYPE_FIELD_NAME (type, i));
-
-	    rust_print_type (TYPE_FIELD_TYPE (type, i), NULL,
-			     stream, show - 1, level + 2,
-			     flags);
-	    fputs_filtered (",\n", stream);
-	  }
+      QUIT;
+      if (field_is_static (&TYPE_FIELD (type, i)))
+	continue;
+
+      /* We'd like to print "pub" here as needed, but rustc
+	 doesn't emit the debuginfo, and our types don't have
+	 cplus_struct_type attached.  */
+
+      /* For a tuple struct we print the type but nothing
+	 else.  */
+      print_spaces_filtered (level + 2, stream);
+      if (!is_tuple_struct)
+	fprintf_filtered (stream, "%s: ", TYPE_FIELD_NAME (type, i));
+
+      rust_print_type (TYPE_FIELD_TYPE (type, i), NULL,
+		       stream, show - 1, level + 2,
+		       flags);
+      fputs_filtered (",\n", stream);
+    }
 
-	fprintfi_filtered (level, stream, is_tuple_struct ? ")" : "}");
+  fprintfi_filtered (level, stream, is_tuple_struct ? ")" : "}");
 }
 
 /* la_print_typedef implementation for Rust.  */
@@ -906,7 +906,7 @@ rust_print_type (struct type *type, const char *varstring,
       break;
 
     case TYPE_CODE_STRUCT:
-    	rust_print_struct_def (type, varstring, stream, show, level, flags);
+      rust_print_struct_def (type, varstring, stream, show, level, flags);
       break;
 
     case TYPE_CODE_ENUM:
@@ -947,15 +947,15 @@ rust_print_type (struct type *type, const char *varstring,
 	/* Skip the discriminant field.  */
 	int skip_to = 1;
 
-  /* Unions and structs have the same syntax in Rust,
-     the only difference is that structs are declared with `struct`
-     and union with `union`. This difference is handled in the struct
-     printer.  */
-  if (rust_union_is_untagged (type))
-    {
-      rust_print_struct_def (type, varstring, stream, show, level, flags);
-      break;
-    }
+	/* Unions and structs have the same syntax in Rust,
+	   the only difference is that structs are declared with `struct`
+	   and union with `union`. This difference is handled in the struct
+	   printer.  */
+	if (rust_union_is_untagged (type))
+	  {
+	    rust_print_struct_def (type, varstring, stream, show, level, flags);
+	    break;
+	  }
 
 	fputs_filtered ("enum ", stream);
 	if (TYPE_TAG_NAME (type) != NULL)
-- 
2.9.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FYI 0/3] some trivial Rust changes
@ 2017-02-03  4:28 Tom Tromey
  2017-02-03  4:28 ` [FYI 1/3] Use std::string in Rust code Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Tromey @ 2017-02-03  4:28 UTC (permalink / raw)
  To: gdb-patches

This series cleans up a few minor things in the Rust code -- removes
some manual memory management, reindents, and introduces the use of
bool.

I'm checking this in.

Tested on x86-64 Fedora 25, using the Rust that comes with Fedora.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-03  4:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-03  4:28 [FYI 0/3] some trivial Rust changes Tom Tromey
2017-02-03  4:28 ` [FYI 1/3] Use std::string in Rust code Tom Tromey
2017-02-03  4:28 ` [FYI 3/3] Use bool " Tom Tromey
2017-02-03  4:28 ` [FYI 2/3] Reindent rust-lang.c Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).