+2021-04-22  Tom Tromey  <tom@tromey.com>
+
+       * rust-parse.c (rust_parser::parse_sizeof): Remove KW_MUT code.
+       (struct typed_val_int) <val>: Now ULONGEST.
+       (rust_parser::parse_array_type): Remove negative check.
+       (rust_lex_int_test): Change 'value' to ULONGEST.
+
 2021-04-22  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * arch-utils.c (default_addressable_memory_unit_size): Return a
 
 
 struct typed_val_int
 {
-  LONGEST val;
+  ULONGEST val;
   struct type *type;
 };
 
 {
   assume (KW_SIZEOF);
 
-  if (current_token == KW_MUT)
-    lex ();
-
   require ('(');
   operation_up result = make_operation<unop_sizeof_operation> (parse_expr ());
   require (')');
 
   if (current_token != INTEGER && current_token != DECIMAL_INTEGER)
     error (_("integer expected"));
-  LONGEST val = current_int_val.val;
-  if (val < 0)
-    error (_("Negative array length"));
+  ULONGEST val = current_int_val.val;
   lex ();
   require (']');
 
 
 static void
 rust_lex_int_test (rust_parser *parser, const char *input,
-                  LONGEST value, int kind)
+                  ULONGEST value, int kind)
 {
   rust_lex_test_one (parser, input, kind);
   SELF_CHECK (parser->current_int_val.val == value);
 
+2021-04-22  Tom Tromey  <tom@tromey.com>
+
+       * gdb.rust/modules.exp: Add checks for syntax errors.
+       * gdb.rust/expr.exp: Add checks for syntax errors.
+       * gdb.rust/simple.exp: Add checks for syntax errors.
+
 2021-04-21  Carl Love  <cel@us.ibm.com>
 
        * gdb.base/valgrind-bt.exp: Add gdb_test "break main".
 
 gdb_test "print \[1,2,3,4\]" " = \\\[1, 2, 3, 4\\\]"
 gdb_test "ptype \[1,2,3,4\]" "type = \\\[i32; 4\\\]"
 gdb_test "print \[mut 1,2,3,4\]" " = \\\[1, 2, 3, 4\\\]"
+gdb_test "print \[1,2 3" "',' or ']' expected"
+gdb_test "print \[1 2" "',', ';', or ']' expected"
 
 gdb_test "print b\"hi rust\"" " = b\"hi rust\""
 # This isn't rusty syntax yet, but that's another bug -- this is just
 
 }
 
 gdb_test "print ::TWENTY_THREE" " = 23"
+
+gdb_test "print super TWENTY_THREE" "'::' expected"
+gdb_test "print super::23" "identifier expected"
+gdb_test "ptype ::Generic::<::Generic<self::Type" "'>' expected"
 
 gdb_test "ptype j2" " = struct simple::Unit"
 gdb_test "print simple::Unit" " = simple::Unit"
 gdb_test "print simple::Unit{}" " = simple::Unit"
+gdb_test "print simple::Unit{23}" "'}', '\.\.', or identifier expected"
 
 gdb_test "print f" " = \"hi bob\""
 gdb_test "print fslice" " = \"bob\""
 gdb_test "print slice\[0\]" " = 3"
 gdb_test "print (slice as &\[i32\])\[0\]" " = 3"
 
+gdb_test "print slice as \[i32; 73.9\]" "integer expected"
+
 gdb_test_sequence "ptype slice" "" {
     " = struct &\\\[i32\\\] \\{"
     "  data_ptr: \\*mut i32,"
 }
 gdb_test "print z.1" " = 8"
 
+# Some error checks.
+gdb_test "print z.1_0" \
+    "'_' not allowed in integers in anonymous field references"
+gdb_test "print z.mut" "field name expected"
+
 gdb_test "print univariant" " = simple::Univariant::Foo{a: 1}"
 gdb_test "print univariant.a" " = 1"
 gdb_test "print univariant_anon" " = simple::UnivariantAnon::Foo\\(1\\)"
     "\\}"
 }
 
+# Test a parser error.
+gdb_test "print sizeof e" "'\\(' expected"
+
 gdb_test "print e.0" " = 73"
 gdb_test "print e.1" \
     "Cannot access field 1 of variant simple::MoreComplicated::Two, there are only 1 fields"
 
 gdb_test "print (diff2 as fn(i32, i32) -> i32)(19, -2)" " = 21"
 
+gdb_test "print diff2(73, 74 75" "',' or '\\\)' expected"
+gdb_test "print (diff2 as fn i32, i32) -> i32)(19, -2)" "'\\\(' expected"
+gdb_test "print (diff2 as fn (i32, i32) i32)(19, -2)" "'->' expected"
+
 gdb_test "print \"hello rust\"" " = \"hello rust.*\""
 gdb_test "print \"hello" "Unexpected EOF in string"
 gdb_test "print r##\"hello \" rust\"##" " = \"hello \\\\\" rust.*\""
 gdb_test "print (1,)" "Tuple expressions not supported yet"
 gdb_test "print (1)" " = 1"
 
+# Test a syntax error in tuple expressions.
+gdb_test "print (1,2,," "unexpected token"
+gdb_test "print (1,2 8" "',' or '\\\)' expected"
+
 gdb_test "print 23..97.0" "Range expression with different types"
 
 gdb_test "print (*parametrized.next.val)" \