diff options
author | Manish Goregaokar <manish@mozilla.com> | 2016-06-27 21:16:59 +0530 |
---|---|---|
committer | Manish Goregaokar <manish@mozilla.com> | 2016-06-27 22:19:42 +0530 |
commit | 921d8f549f9e35d3f83c7b1a381146a7dc1246f4 (patch) | |
tree | 362a359483a10ddf87a0d47243c4e761e8f15fac /gdb/testsuite | |
parent | 45a54ee57764e34fe2fe8b7655fabef38936a696 (diff) | |
download | gdb-921d8f549f9e35d3f83c7b1a381146a7dc1246f4.zip gdb-921d8f549f9e35d3f83c7b1a381146a7dc1246f4.tar.gz gdb-921d8f549f9e35d3f83c7b1a381146a7dc1246f4.tar.bz2 |
Print void types correctly in Rust
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
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.rust/simple.exp | 1 | ||||
-rw-r--r-- | gdb/testsuite/gdb.rust/simple.rs | 7 |
3 files changed, 13 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f5bdb40..b7e30f5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +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, diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index 88f1c89..4622f75 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -149,6 +149,7 @@ gdb_test "print self::diff2(8, 9)" " = -1" 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" diff --git a/gdb/testsuite/gdb.rust/simple.rs b/gdb/testsuite/gdb.rust/simple.rs index 32da580..3d28e27 100644 --- a/gdb/testsuite/gdb.rust/simple.rs +++ b/gdb/testsuite/gdb.rust/simple.rs @@ -48,6 +48,12 @@ fn diff2(x: i32, y: i32) -> i32 { x - y } +// 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 @@ -111,4 +117,5 @@ fn main () { println!("{}, {}", x.0, x.1); // set breakpoint here println!("{}", diff2(92, 45)); + empty(); } |