Repository: toml-rs/toml (language: rust)

Issue:
Missing "expected" grammar on error
This is a regression compared to toml-rs as found by cargo's tests
```
---- bad_config::malformed_override stdout ----                                                                                                    
running `/home/epage/src/personal/cargo/target/debug/cargo build`                                                                                  
thread 'bad_config::malformed_override' panicked at '                                                                                              
test failed running `/home/epage/src/personal/cargo/target/debug/cargo build`                                                                      
error: stderr did not match:                                                                                                                       
1   1     error: failed to parse manifest at `[..]`                                                                                                
2   2                                                                                                                                              
3   3     Caused by:                                                                                                                               
4   4       could not parse input as TOML                                                                                                          
5   5                                                                                                                                              
6   6     Caused by:                                                                                                                               
7        -  expected a table key, found a newline at line 8 column 27                                                                              
    7    +  TOML parse error at line 8, column 27                                                                                                  
    8    +    |                                                          
    9    +  8 |                 native = {                                                                                                         
    10   +    |                           ^                                                                                                        
    11   +  Unexpected `                                                 
    12   +  `                                                            
```


Discussion / hints:

Fix patch:
diff --git a/src/parser/key.rs b/src/parser/key.rs
index 64abb75c..c6ad7327 100644
--- a/src/parser/key.rs
+++ b/src/parser/key.rs
@@ -20,7 +20,7 @@ parse!(key() -> Vec<Key>, {
             Key::new(key).with_repr_unchecked(Repr::new_unchecked(raw)).with_decor(Decor::new(pre, suffix))
         }),
         byte(DOT_SEP)
-    )
+    ).expected("key")
 });
 
 // simple-key = quoted-key / unquoted-key
diff --git a/src/parser/trivia.rs b/src/parser/trivia.rs
index c1772e80..f50df7c1 100644
--- a/src/parser/trivia.rs
+++ b/src/parser/trivia.rs
@@ -62,7 +62,7 @@ pub(crate) const CR: u8 = b'\r';
 parse!(newline() -> char, {
     choice((lf(), crlf()))
         .map(|_| '\n')
-        .expected("a newline")
+        .expected("newline")
 });
 
 // ws-newline       = *( wschar / newline )


Test patch:
diff --git a/tests/fixtures/invalid/empty-table.stderr b/tests/fixtures/invalid/empty-table.stderr
index 066e2cf7..17e80f46 100644
--- a/tests/fixtures/invalid/empty-table.stderr
+++ b/tests/fixtures/invalid/empty-table.stderr
@@ -3,4 +3,5 @@ TOML parse error at line 1, column 2
 1 | []
   |  ^
 Unexpected `]`
+Expected `key`
 While parsing a Table Header
diff --git a/tests/fixtures/invalid/inline-table-newline.stderr b/tests/fixtures/invalid/inline-table-newline.stderr
new file mode 100644
index 00000000..488fec97
--- /dev/null
+++ b/tests/fixtures/invalid/inline-table-newline.stderr
@@ -0,0 +1,7 @@
+TOML parse error at line 7, column 11
+  |
+7 | native = {
+  |           ^
+Unexpected `
+`
+Expected `key`
diff --git a/tests/fixtures/invalid/inline-table-newline.toml b/tests/fixtures/invalid/inline-table-newline.toml
new file mode 100644
index 00000000..726bf3d4
--- /dev/null
+++ b/tests/fixtures/invalid/inline-table-newline.toml
@@ -0,0 +1,9 @@
+[package]
+name = "foo"
+version = "0.0.0"
+authors = []
+
+[target.x86_64-apple-darwin.freetype]
+native = {
+  foo: "bar"
+}
diff --git a/tests/fixtures/invalid/key-after-array.stderr b/tests/fixtures/invalid/key-after-array.stderr
index 3fbd9100..19630d79 100644
--- a/tests/fixtures/invalid/key-after-array.stderr
+++ b/tests/fixtures/invalid/key-after-array.stderr
@@ -3,5 +3,5 @@ TOML parse error at line 1, column 14
 1 | [[agencies]] owner = "S Cjelli"
   |              ^
 Unexpected `o`
-Expected `a newline` or `end of input`
+Expected `newline` or `end of input`
 While parsing a Table Header
diff --git a/tests/fixtures/invalid/key-after-table.stderr b/tests/fixtures/invalid/key-after-table.stderr
index 3499f699..b2def4d2 100644
--- a/tests/fixtures/invalid/key-after-table.stderr
+++ b/tests/fixtures/invalid/key-after-table.stderr
@@ -3,5 +3,5 @@ TOML parse error at line 1, column 9
 1 | [error] this = "should not be here"
   |         ^
 Unexpected `t`
-Expected `a newline` or `end of input`
+Expected `newline` or `end of input`
 While parsing a Table Header
diff --git a/tests/fixtures/invalid/key-empty.stderr b/tests/fixtures/invalid/key-empty.stderr
index 90a0ff41..367eecc5 100644
--- a/tests/fixtures/invalid/key-empty.stderr
+++ b/tests/fixtures/invalid/key-empty.stderr
@@ -3,3 +3,4 @@ TOML parse error at line 1, column 2
 1 |  = 1
   |  ^
 Unexpected `=`
+Expected `key`
diff --git a/tests/fixtures/invalid/key-no-eol.stderr b/tests/fixtures/invalid/key-no-eol.stderr
index 617196a2..3d9739b3 100644
--- a/tests/fixtures/invalid/key-no-eol.stderr
+++ b/tests/fixtures/invalid/key-no-eol.stderr
@@ -3,4 +3,4 @@ TOML parse error at line 1, column 7
 1 | a = 1 b = 2
   |       ^
 Unexpected `b`
-Expected `a newline` or `end of input`
+Expected `newline` or `end of input`
diff --git a/tests/fixtures/invalid/key-single-open-bracket.stderr b/tests/fixtures/invalid/key-single-open-bracket.stderr
index bf5cdfa4..27971465 100644
--- a/tests/fixtures/invalid/key-single-open-bracket.stderr
+++ b/tests/fixtures/invalid/key-single-open-bracket.stderr
@@ -3,4 +3,5 @@ TOML parse error at line 1, column 2
 1 | [
   |  ^
 Unexpected `end of input`
+Expected `key`
 While parsing a Table Header
diff --git a/tests/fixtures/invalid/llbrace.stderr b/tests/fixtures/invalid/llbrace.stderr
index 9e30a72f..0d95f37e 100644
--- a/tests/fixtures/invalid/llbrace.stderr
+++ b/tests/fixtures/invalid/llbrace.stderr
@@ -4,4 +4,5 @@ TOML parse error at line 1, column 3
   |   ^
 Unexpected `[`
 Unexpected ` `
+Expected `key`
 While parsing a Table Header
diff --git a/tests/fixtures/invalid/string-no-quotes-in-array.stderr b/tests/fixtures/invalid/string-no-quotes-in-array.stderr
index 07f80118..825bc38d 100644
--- a/tests/fixtures/invalid/string-no-quotes-in-array.stderr
+++ b/tests/fixtures/invalid/string-no-quotes-in-array.stderr
@@ -3,4 +3,4 @@ TOML parse error at line 1, column 10
 1 | value = [ZZZ]
   |          ^
 Unexpected `Z`
-Expected `a newline` or `#`
+Expected `newline` or `#`
diff --git a/tests/fixtures/invalid/table-array-malformed-empty.stderr b/tests/fixtures/invalid/table-array-malformed-empty.stderr
index 8b02ceaa..56633687 100644
--- a/tests/fixtures/invalid/table-array-malformed-empty.stderr
+++ b/tests/fixtures/invalid/table-array-malformed-empty.stderr
@@ -3,4 +3,5 @@ TOML parse error at line 1, column 3
 1 | [[]]
   |   ^
 Unexpected `]`
+Expected `key`
 While parsing a Table Header
diff --git a/tests/fixtures/invalid/table-empty.stderr b/tests/fixtures/invalid/table-empty.stderr
index 066e2cf7..17e80f46 100644
--- a/tests/fixtures/invalid/table-empty.stderr
+++ b/tests/fixtures/invalid/table-empty.stderr
@@ -3,4 +3,5 @@ TOML parse error at line 1, column 2
 1 | []
   |  ^
 Unexpected `]`
+Expected `key`
 While parsing a Table Header
diff --git a/tests/fixtures/invalid/text-after-integer.stderr b/tests/fixtures/invalid/text-after-integer.stderr
index 9d887a0d..4852e792 100644
--- a/tests/fixtures/invalid/text-after-integer.stderr
+++ b/tests/fixtures/invalid/text-after-integer.stderr
@@ -3,4 +3,4 @@ TOML parse error at line 1, column 13
 1 | answer = 42 the ultimate answer?
   |             ^
 Unexpected `t`
-Expected `a newline` or `end of input`
+Expected `newline` or `end of input`
diff --git a/tests/fixtures/invalid/text-after-string.stderr b/tests/fixtures/invalid/text-after-string.stderr
index af5f8f2a..4f8a2c8c 100644
--- a/tests/fixtures/invalid/text-after-string.stderr
+++ b/tests/fixtures/invalid/text-after-string.stderr
@@ -3,4 +3,4 @@ TOML parse error at line 1, column 41
 1 | string = "Is there life after strings?" No.
   |                                         ^
 Unexpected `N`
-Expected `a newline` or `end of input`
+Expected `newline` or `end of input`
diff --git a/tests/fixtures/invalid/text-after-table.stderr b/tests/fixtures/invalid/text-after-table.stderr
index 376e09c3..4c0be520 100644
--- a/tests/fixtures/invalid/text-after-table.stderr
+++ b/tests/fixtures/invalid/text-after-table.stderr
@@ -3,5 +3,5 @@ TOML parse error at line 1, column 9
 1 | [error] this shouldn't be here
   |         ^
 Unexpected `t`
-Expected `a newline` or `end of input`
+Expected `newline` or `end of input`
 While parsing a Table Header