diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a4a1b4842..e313943cc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -79,14 +79,14 @@ jobs: - uses: Swatinem/rust-cache@v2 - name: Retrieve toml-test run: | - wget https://github.com/BurntSushi/toml-test/releases/download/v1.1.0/toml-test-v1.1.0-linux-amd64.gz - gunzip toml-test-v1.1.0-linux-amd64.gz - chmod +x toml-test-v1.1.0-linux-amd64 + wget https://github.com/toml-lang/toml-test/releases/download/v2.1.0/toml-test-v2.1.0-linux-amd64.gz + gunzip toml-test-v2.1.0-linux-amd64.gz + chmod +x toml-test-v2.1.0-linux-amd64 - name: Build taplo-cli run: | cargo build --bin taplo --no-default-features --features "rustls-tls,toml-test" - name: Run toml-test - run: ./toml-test-v1.1.0-linux-amd64 ./target/debug/taplo -- toml-test + run: ./toml-test-v2.1.0-linux-amd64 test -toml 1.1 -skip 'invalid/control/cr,invalid/control/multi-cr,invalid/control/rawmulti-cr,invalid/table/append-with-dotted-keys-04,invalid/table/super-twice,valid/array/array,valid/comment/everywhere,valid/comment/nonascii,valid/datetime/datetime,valid/datetime/edge,valid/datetime/leap-year,valid/datetime/local,valid/datetime/local-date,valid/datetime/local-time,valid/datetime/milliseconds,valid/datetime/no-seconds,valid/datetime/timezone,valid/example,valid/key/numeric-04,valid/key/quoted-unicode,valid/spec-1.1.0/common-12,valid/spec-1.1.0/common-27,valid/spec-1.1.0/common-28,valid/spec-1.1.0/common-29,valid/spec-1.1.0/common-30,valid/spec-1.1.0/common-31,valid/spec-1.1.0/common-32,valid/spec-1.1.0/common-33,valid/spec-1.1.0/common-34,valid/spec-1.1.0/common-44,valid/spec-example-1,valid/spec-example-1-compact,valid/string/escape-esc,valid/string/hex-escape,valid/string/quoted-unicode' -decoder "./target/debug/taplo toml-test" test-msrv-lib: name: Test libraries with MSRV diff --git a/Cargo.lock b/Cargo.lock index b6545349c..766d210fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,9 +42,9 @@ dependencies = [ [[package]] name = "aligned-vec" -version = "0.6.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0966165eaf052580bd70eb1b32cb3d6245774c0104d1b2793e9650bf83b52a" +checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b" dependencies = [ "equator", ] @@ -133,9 +133,9 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "assert-json-diff" @@ -165,7 +165,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -176,7 +176,7 @@ checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -281,9 +281,9 @@ checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" [[package]] name = "bytemuck" -version = "1.14.3" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" +checksum = "c8efb64bd706a16a1bdde310ae86b351e4d21550d98d056f22f8a7f7a2183fec" [[package]] name = "bytes" @@ -379,7 +379,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -438,9 +438,9 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpp_demangle" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8227005286ec39567949b33df9896bcadfa6051bccca2488129f108ca23119" +checksum = "f2bb79cb74d735044c972aae58ed0aaa9a837e85b01106a54c39e42e97f62253" dependencies = [ "cfg-if", ] @@ -599,22 +599,22 @@ dependencies = [ [[package]] name = "equator" -version = "0.2.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35da53b5a021d2484a7cc49b2ac7f2d840f8236a286f84202369bd338d761ea" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" dependencies = [ "equator-macro", ] [[package]] name = "equator-macro" -version = "0.2.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf679796c0322556351f287a51b49e48f7c4986e727b5dd78c972d30e2e16cc" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -770,7 +770,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -1017,9 +1017,9 @@ dependencies = [ [[package]] name = "inferno" -version = "0.11.19" +version = "0.11.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321f0f839cd44a4686e9504b0a62b4d69a50b62072144c71c68f5873c167b8d9" +checksum = "232929e1d75fe899576a3d5c7416ad0d88dbfbb3c3d6aa00873a7408a50ddb88" dependencies = [ "ahash", "indexmap", @@ -1238,9 +1238,9 @@ checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memmap2" -version = "0.9.4" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +checksum = "714098028fe011992e1c3962653c96b2d578c4b4bce9036e15ff220319b1e0e3" dependencies = [ "libc", ] @@ -1495,7 +1495,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -1614,9 +1614,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "pprof" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebbe2f8898beba44815fdc9e5a4ae9c929e21c5dc29b0c774a15555f7f58d6d0" +checksum = "afad4d4df7b31280028245f152d5a575083e2abb822d05736f5e47653e77689f" dependencies = [ "aligned-vec", "backtrace", @@ -1628,8 +1628,8 @@ dependencies = [ "log", "nix 0.26.4", "once_cell", - "parking_lot", "smallvec", + "spin 0.10.0", "symbolic-demangle", "tempfile", "thiserror", @@ -1647,9 +1647,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] @@ -1665,9 +1665,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4" dependencies = [ "proc-macro2", ] @@ -1791,9 +1791,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.37" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce" dependencies = [ "bytemuck", ] @@ -1807,7 +1807,7 @@ dependencies = [ "cc", "getrandom", "libc", - "spin", + "spin 0.9.8", "untrusted", "windows-sys 0.48.0", ] @@ -2012,7 +2012,7 @@ checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -2046,7 +2046,7 @@ checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -2121,11 +2121,20 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spin" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" +dependencies = [ + "lock_api", +] + [[package]] name = "stable_deref_trait" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" [[package]] name = "str_stack" @@ -2141,9 +2150,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "symbolic-common" -version = "12.10.0" +version = "12.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16629323a4ec5268ad23a575110a724ad4544aae623451de600c747bf87b36cf" +checksum = "71297dc3e250f7dbdf8adb99e235da783d690f5819fdeb4cce39d9cfb0aca9f1" dependencies = [ "debugid", "memmap2", @@ -2153,9 +2162,9 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "12.10.0" +version = "12.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c043a45f08f41187414592b3ceb53fb0687da57209cc77401767fb69d5b596" +checksum = "424fa2c9bf2c862891b9cfd354a752751a6730fd838a4691e7f6c2c7957b9daf" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -2175,9 +2184,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -2412,7 +2421,7 @@ checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -2507,7 +2516,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -2602,7 +2611,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] [[package]] @@ -2787,7 +2796,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", "wasm-bindgen-shared", ] @@ -2821,7 +2830,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3050,5 +3059,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.117", ] diff --git a/crates/taplo-cli/src/lib.rs b/crates/taplo-cli/src/lib.rs index abc4e2be3..01ddb1f09 100644 --- a/crates/taplo-cli/src/lib.rs +++ b/crates/taplo-cli/src/lib.rs @@ -139,7 +139,8 @@ impl Taplo { let excluded = total - files.len(); - tracing::info!(total, excluded, ?files, "found files"); + tracing::info!(total, excluded, "found files"); + tracing::debug!(?files, "file details"); Ok(files) } diff --git a/crates/taplo-lsp/src/handlers/hover.rs b/crates/taplo-lsp/src/handlers/hover.rs index c861a378e..165b660ac 100644 --- a/crates/taplo-lsp/src/handlers/hover.rs +++ b/crates/taplo-lsp/src/handlers/hover.rs @@ -112,7 +112,7 @@ pub(crate) async fn hover( keys = lookup_keys(doc.dom.clone(), &keys); // We're interested in the array itself, not its item type. - if let Some(KeyOrIndex::Index(_)) = keys.iter().last() { + while let Some(KeyOrIndex::Index(_)) = keys.iter().last() { keys = keys.skip_right(1); } diff --git a/crates/taplo/Cargo.toml b/crates/taplo/Cargo.toml index 85360cb23..4b530b62b 100644 --- a/crates/taplo/Cargo.toml +++ b/crates/taplo/Cargo.toml @@ -35,12 +35,14 @@ serde = { workspace = true, features = ["derive"], optional = true } [dev-dependencies] assert-json-diff = { version = "2" } -criterion = { version = "0.5" } # criterion -> clap +criterion = { version = "0.5" } # criterion -> clap difference = { version = "2.0.0" } -pprof = { version = "0.14", features = ["flamegraph", "criterion"] } # pprof -> criterion -> clap serde_json = { version = "1" } toml = { version = "0.7" } +[target.'cfg(unix)'.dev-dependencies] +pprof = { version = "0.14", features = ["flamegraph", "criterion"] } # pprof -> criterion -> clap + [package.metadata.docs.rs] features = ["serde", "schema"] diff --git a/crates/taplo/benches/profile.rs b/crates/taplo/benches/profile.rs index 6001e26f7..a1530ad65 100644 --- a/crates/taplo/benches/profile.rs +++ b/crates/taplo/benches/profile.rs @@ -1,7 +1,9 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use pprof::criterion::{Output, PProfProfiler}; use taplo::parser::parse; +#[cfg(unix)] +use pprof::criterion::{Output, PProfProfiler}; + pub fn syntax(c: &mut Criterion) { let source = include_str!("../../../test-data/example.toml"); c.bench_function("parse-toml", |b| b.iter(|| parse(black_box(source)))); @@ -14,9 +16,18 @@ pub fn dom(c: &mut Criterion) { }); } +#[cfg(unix)] criterion_group!( name = benches; config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); targets = syntax, dom ); + +#[cfg(not(unix))] +criterion_group!( + name = benches; + config = Criterion::default(); + targets = syntax, dom +); + criterion_main!(benches); diff --git a/crates/taplo/src/formatter/mod.rs b/crates/taplo/src/formatter/mod.rs index d5565c869..c64e029a4 100644 --- a/crates/taplo/src/formatter/mod.rs +++ b/crates/taplo/src/formatter/mod.rs @@ -804,11 +804,15 @@ fn format_key(node: SyntaxNode, formatted: &mut String, _options: &Options, _con fn format_value(node: SyntaxNode, options: &Options, context: &Context) -> impl FormattedItem { let mut value = String::new(); let mut comment = None; + + let mut scoped_options = options.clone(); + context.update_options(&mut scoped_options, node.text_range()); + for c in node.children_with_tokens() { match c { NodeOrToken::Node(n) => match n.kind() { ARRAY => { - let formatted = format_array(n, options, context); + let formatted = format_array(n, &scoped_options, context); let c = formatted.trailing_comment(); @@ -818,10 +822,10 @@ fn format_value(node: SyntaxNode, options: &Options, context: &Context) -> impl } debug_assert!(value.is_empty()); - formatted.write_to(&mut value, options); + formatted.write_to(&mut value, &scoped_options); } INLINE_TABLE => { - let formatted = format_inline_table(n, options, context); + let formatted = format_inline_table(n, &scoped_options, context); let c = formatted.trailing_comment(); @@ -832,7 +836,7 @@ fn format_value(node: SyntaxNode, options: &Options, context: &Context) -> impl debug_assert!(value.is_empty()); - formatted.write_to(&mut value, options); + formatted.write_to(&mut value, &scoped_options); } _ => unreachable!(), }, diff --git a/crates/taplo/src/parser/mod.rs b/crates/taplo/src/parser/mod.rs index d8de8ed2e..679f64f9c 100644 --- a/crates/taplo/src/parser/mod.rs +++ b/crates/taplo/src/parser/mod.rs @@ -787,11 +787,10 @@ impl<'p> Parser<'p> { } fn parse_inline_table(&mut self) -> ParserResult<()> { + // https://github.com/toml-lang/toml/blob/78fcf9dd7eab7acfbaf147c684b649477e7bdd9c/toml.abnf#L238 self.must_token_or(BRACE_START, r#"expected "{""#)?; - let mut first = true; - let mut comma_last = false; - let mut was_newline = false; + let mut expect_comma_or_end = false; loop { let t = match self.get_token() { @@ -801,52 +800,31 @@ impl<'p> Parser<'p> { match t { BRACE_END => { - if comma_last { - // it is still reported as a syntax error, - // but we can still analyze it as if it was a valid - // table. - let _ = self.report_error("expected value, trailing comma is not allowed"); - } - break self.add_token()?; + self.add_token()?; + break; } - NEWLINE => { - // To avoid infinite loop in case - // new lines are whitelisted. - if was_newline { - break; - } - - let _ = self.error("newline is not allowed in an inline table"); - was_newline = true; + WHITESPACE | NEWLINE | COMMENT => { + self.add_token()?; } COMMA => { - if comma_last { - let _ = self.report_error(r#"unexpected ",""#); - } - - if first { + if !expect_comma_or_end { let _ = self.error(r#"unexpected ",""#); - } else { - self.token()?; } - comma_last = true; - was_newline = false; + self.add_token()?; + expect_comma_or_end = false; } _ => { - was_newline = false; - if !comma_last && !first { - let _ = self.error(r#"expected ",""#); + if expect_comma_or_end { + let _ = self.error(r#"expected "," or "}""#); } let _ = whitelisted!( self, COMMA, with_node!(self.builder, ENTRY, self.parse_entry()) ); - comma_last = false; + expect_comma_or_end = true; } } - - first = false; } Ok(()) } diff --git a/crates/taplo/src/tests/formatter.rs b/crates/taplo/src/tests/formatter.rs index ecd27fd26..9c956d6f1 100644 --- a/crates/taplo/src/tests/formatter.rs +++ b/crates/taplo/src/tests/formatter.rs @@ -1,7 +1,6 @@ use difference::Changeset; -use crate::formatter; -use crate::formatter::Options; +use crate::formatter::{self, Options, OptionsIncomplete}; macro_rules! assert_format { ($expected:expr, $actual:expr) => { @@ -1176,3 +1175,31 @@ a = "b" # comment assert_format!(expected, &formatted); } + +#[test] +fn test_entry_rule() { + let src = r#" +[foo] +sort_me = ["3", "2", "1"] +sort_me_not = ["3", "2", "1"] +"#; + + let expected = r#" +[foo] +sort_me = ["1", "2", "3"] +sort_me_not = ["3", "2", "1"] +"#; + + let dom = crate::parser::parse(src).into_dom(); + let scopes = [( + "foo.sort_me", + OptionsIncomplete { + reorder_arrays: Some(true), + ..Default::default() + }, + )]; + let formatted = + crate::formatter::format_with_path_scopes(dom, Options::default(), &[], scopes).unwrap(); + + assert_format!(expected, &formatted); +} diff --git a/crates/taplo/src/tests/generated/invalid.rs b/crates/taplo/src/tests/generated/invalid.rs index 917c73323..89af61c48 100644 --- a/crates/taplo/src/tests/generated/invalid.rs +++ b/crates/taplo/src/tests/generated/invalid.rs @@ -65,12 +65,6 @@ fn inline_table_imutable_2() { assert!(!p.errors.is_empty() || p.into_dom().validate().is_err()); } #[test] -fn inline_table_trailing_comma() { - let src = "abc = { abc = 123, }\n"; - let p = crate::parser::parse(src); - assert!(!p.errors.is_empty() || p.into_dom().validate().is_err()); -} -#[test] fn int_0_padded() { let src = "int = 0123\n"; let p = crate::parser::parse(src); @@ -354,12 +348,6 @@ fn taplo_invalid_float() { assert!(!p.errors.is_empty() || p.into_dom().validate().is_err()); } #[test] -fn taplo_invalid_inline_table() { - let src = "cooldowns = { \n aggressive = true, \n}"; - let p = crate::parser::parse(src); - assert!(!p.errors.is_empty() || p.into_dom().validate().is_err()); -} -#[test] fn taplo_invalid_padding() { let src = "[int]\npadded_middle = 1__2\npadded_start = _1_2\npadded_end = 1_2_\n\npadded_plus = +_2\npadded_minus = -_2\n\n[int.bin]\npadded_middle = 0b1__0\npadded_start = 0b_1_0\npadded_end = 0b1_0_\n\n[int.hex]\npadded_middle = 0x1__0\npadded_start = 0x_1_0\npadded_end = 0x1_0_\n\n[int.oct]\npadded_middle = 0o1__0\npadded_start = 0o_1_0\npadded_end = 0o1_0_\n\n[float]\npadded_middle = 1__2.0\npadded_start = _1_2.0\npadded_end = 1_2_.0\n\npadded_plus = +_2.0\npadded_minus = -_2.0" ; let p = crate::parser::parse(src); diff --git a/crates/taplo/src/tests/mod.rs b/crates/taplo/src/tests/mod.rs index effdf1341..06975bcf9 100644 --- a/crates/taplo/src/tests/mod.rs +++ b/crates/taplo/src/tests/mod.rs @@ -41,3 +41,16 @@ fn dates_in_table_keys() { assert!(errors.is_empty(), "{:#?}", errors); } + +#[test] +fn inline_table_with_linebreaks_and_trailing_comma() { + let src = r#" +cooldowns = { + foo = "foo", + bar = "bar", +} +"#; + let errors = parse(src).errors; + + assert!(errors.is_empty(), "{:#?}", errors); +} diff --git a/test-data/invalid/inline-table-trailing-comma.toml b/test-data/invalid/inline-table-trailing-comma.toml deleted file mode 100644 index 59618e1a7..000000000 --- a/test-data/invalid/inline-table-trailing-comma.toml +++ /dev/null @@ -1 +0,0 @@ -abc = { abc = 123, } diff --git a/test-data/invalid/taplo-invalid-inline-table.toml b/test-data/invalid/taplo-invalid-inline-table.toml deleted file mode 100644 index 85c3c0a38..000000000 --- a/test-data/invalid/taplo-invalid-inline-table.toml +++ /dev/null @@ -1,3 +0,0 @@ -cooldowns = { - aggressive = true, -} \ No newline at end of file