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

Issue:
Parse error on comment after datetime
The following seems to fail to parse:

```toml
foo = 1979-05-27 # Comment
```

```
TOML parse error at line 2, column 18
  |
  2 | foo = 1979-05-27 # Comment
  |                  ^
  Unexpected `#`
expected 2 more elements
While parsing a Date-Time
```

But it works without the comment.

Currently using v0.10.0


Discussion / hints:
Thanks for reporting this! I'll try to get to this today, tomorrow at the latest.

Fix patch:
diff --git a/src/parser/datetime.rs b/src/parser/datetime.rs
index 97ac395f..53a362c3 100644
--- a/src/parser/datetime.rs
+++ b/src/parser/datetime.rs
@@ -19,7 +19,10 @@ parse!(date_time() -> Datetime, {
         (
             full_date(),
             optional((
-                satisfy(is_time_delim),
+                attempt((
+                    satisfy(is_time_delim),
+                    look_ahead(time_hour())
+                )),
                 partial_time(),
                 optional(time_offset()),
             ))
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index c5640d2b..3e9e0e0e 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -619,6 +619,8 @@ that
 key = "value"
 "#,
             r#"hello.world = "a"
+"#,
+            r#"foo = 1979-05-27 # Comment
 "#,
         ];
         for document in &documents {


Test patch:
diff --git a/tests/test_invalid.rs b/tests/test_invalid.rs
index f8e4a04b..5e7a64a1 100644
--- a/tests/test_invalid.rs
+++ b/tests/test_invalid.rs
@@ -1,13 +1,14 @@
 use toml_edit::Document;
 
+#[track_caller]
 fn run(toml: &str, msg: &str) {
     let doc = toml.parse::<Document>();
-    assert!(doc.is_err());
 
     let err = match doc {
         Err(e) => e.to_string(),
-        _ => unreachable!(""),
+        _ => unreachable!("must fail"),
     };
+    dbg!(&err);
     assert!(err.contains(msg));
 }