summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
45a54ee)
Rust prefers to not specify the return type of a function when it is unit
(`()`). The type is also referred to as "void" in debuginfo but not in actual
usage, so we should never be printing "void" when the language is Rust.
2016-06-27 Manish Goregaokar <manish@mozilla.com>
gdb/ChangeLog:
* rust-lang.c (rust_print_type): Print unit types as "()"
* rust-lang.c (rust_print_type): Omit return type for functions
returning unit
gdb/testsuite/ChangeLog:
* gdb.rust/simple.rs: Add test for returning unit in a function
* gdb.rust/simple.exp: Add expectation for functions returning unit
+2016-06-27 Manish Goregaokar <manish@mozilla.com>
+
+ * rust-lang.c (rust_print_type): Print unit types as "()"
+ * rust-lang.c (rust_print_type): Omit return type for functions
+ returning unit
+
2016-06-25 Pierre-Marie de Rodat <derodat@adacore.com>
* python/py-breakpoint.c (bppy_init): Clear bppy_pending_object
2016-06-25 Pierre-Marie de Rodat <derodat@adacore.com>
* python/py-breakpoint.c (bppy_init): Clear bppy_pending_object
if (show <= 0
&& TYPE_NAME (type) != NULL)
{
if (show <= 0
&& TYPE_NAME (type) != NULL)
{
- fputs_filtered (TYPE_NAME (type), stream);
+ /* Rust calls the unit type "void" in its debuginfo,
+ but we don't want to print it as that. */
+ if (TYPE_CODE (type) == TYPE_CODE_VOID)
+ fputs_filtered ("()", stream);
+ else
+ fputs_filtered (TYPE_NAME (type), stream);
return;
}
type = check_typedef (type);
switch (TYPE_CODE (type))
{
return;
}
type = check_typedef (type);
switch (TYPE_CODE (type))
{
+ case TYPE_CODE_VOID:
+ fputs_filtered ("()", stream);
+ break;
+
case TYPE_CODE_FUNC:
/* Delegate varargs to the C printer. */
if (TYPE_VARARGS (type))
case TYPE_CODE_FUNC:
/* Delegate varargs to the C printer. */
if (TYPE_VARARGS (type))
rust_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0,
flags);
}
rust_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0,
flags);
}
- fputs_filtered (") -> ", stream);
- rust_print_type (TYPE_TARGET_TYPE (type), "", stream, -1, 0, flags);
+ fputs_filtered (")", stream);
+ /* If it returns unit, we can omit the return type. */
+ if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
+ {
+ fputs_filtered (" -> ", stream);
+ rust_print_type (TYPE_TARGET_TYPE (type), "", stream, -1, 0, flags);
+ }
break;
case TYPE_CODE_ARRAY:
break;
case TYPE_CODE_ARRAY:
+2016-06-27 Manish Goregaokar <manish@mozilla.com>
+
+ * gdb.rust/simple.rs: Add test for returning unit in a function
+ * gdb.rust/simple.exp: Add expectation for functions returning unit
+
2016-06-27 Pierre-Marie de Rodat <derodat@adacore.com>
* gdb.python/py-breakpoint-create-fail.c,
2016-06-27 Pierre-Marie de Rodat <derodat@adacore.com>
* gdb.python/py-breakpoint-create-fail.c,
gdb_test "print ::diff2(23, -23)" " = 46"
gdb_test "ptype diff2" "fn \\(i32, i32\\) -> i32"
gdb_test "print ::diff2(23, -23)" " = 46"
gdb_test "ptype diff2" "fn \\(i32, i32\\) -> i32"
+gdb_test "ptype empty" "fn \\(\\)"
gdb_test "print (diff2 as fn(i32, i32) -> i32)(19, -2)" " = 21"
gdb_test "print (diff2 as fn(i32, i32) -> i32)(19, -2)" " = 21"
+// Empty function, should not have "void"
+// or "()" in its return type
+fn empty() {
+
+}
+
pub struct Unit;
// This triggers the non-zero optimization that yields a different
pub struct Unit;
// This triggers the non-zero optimization that yields a different
println!("{}, {}", x.0, x.1); // set breakpoint here
println!("{}", diff2(92, 45));
println!("{}, {}", x.0, x.1); // set breakpoint here
println!("{}", diff2(92, 45));