From f0ad594b3283f2d35259c4e7f9fe62c09bf5d0da Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 3 Apr 2025 13:50:36 +0200 Subject: [PATCH 1/4] Update --- .github/workflows/rust-ci.yml | 10 +- Cargo.lock | 146 ++++++++++-------- Cargo.toml | 2 +- deny.toml | 2 +- integ-tests/Cargo.toml | 2 +- ...e__table_then_dotted_then_table_again.snap | 4 +- toml-span/Cargo.toml | 2 +- 7 files changed, 94 insertions(+), 74 deletions(-) diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 1412563..49529d2 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -14,7 +14,7 @@ name: CI jobs: lint: name: Lint - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -34,7 +34,7 @@ jobs: test: name: Test - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -46,14 +46,14 @@ jobs: deny: name: cargo-deny - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: EmbarkStudios/cargo-deny-action@v2 publish-check: name: Publish Check - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -62,7 +62,7 @@ jobs: run: cargo publish --dry-run -p toml-span test_success: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 needs: [lint,test,deny,publish-check] steps: - run: echo "All test jobs passed" \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 6eb6790..70e89be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,23 +4,24 @@ version = 4 [[package]] name = "codespan-reporting" -version = "0.11.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +checksum = "fe6d2e5af09e8c8ad56c969f2157a3d4238cebc7c55f0a517728c38f7b200f81" dependencies = [ + "serde", "termcolor", "unicode-width", ] [[package]] name = "console" -version = "0.15.8" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" dependencies = [ "encode_unicode", - "lazy_static", "libc", + "once_cell", "windows-sys", ] @@ -32,19 +33,20 @@ checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" [[package]] name = "insta" -version = "1.39.0" +version = "1.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "810ae6042d48e2c9e9215043563a58a80b877bc863228a74cf10c49d4620a6f5" +checksum = "50259abbaa67d11d2bcafc7ba1d094ed7a0c70e3ce893f0d0997f73558cb3084" dependencies = [ "console", - "lazy_static", "linked-hash-map", + "once_cell", + "pin-project", "serde", "similar", ] @@ -59,17 +61,11 @@ dependencies = [ "toml-span", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.155" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "linked-hash-map" @@ -77,11 +73,37 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" dependencies = [ "diff", "yansi", @@ -89,36 +111,36 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.85" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] name = "serde" -version = "1.0.203" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -127,21 +149,21 @@ dependencies = [ [[package]] name = "similar" -version = "2.5.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa42c91313f1d05da9b26f267f931cf178d4aba455b4c4622dd7355eb80c6640" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "syn" -version = "2.0.66" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -168,39 +190,39 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ "windows-sys", ] [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -214,54 +236,54 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "yansi" -version = "0.5.1" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" diff --git a/Cargo.toml b/Cargo.toml index d672eb0..f0e43c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["integ-tests", "toml-span"] [workspace.package] authors = ["Embark "] -edition = "2021" +edition = "2024" license = "MIT OR Apache-2.0" homepage = "https://github.com/EmbarkStudios/toml-span" repository = "https://github.com/EmbarkStudios/toml-span" diff --git a/deny.toml b/deny.toml index cdc0f95..3ea543d 100644 --- a/deny.toml +++ b/deny.toml @@ -12,4 +12,4 @@ all-features = true multiple-versions = "deny" [licenses] -allow = ["MIT", "Apache-2.0"] +allow = ["MIT", "Apache-2.0", "Unicode-3.0"] diff --git a/integ-tests/Cargo.toml b/integ-tests/Cargo.toml index 659481d..70ce730 100644 --- a/integ-tests/Cargo.toml +++ b/integ-tests/Cargo.toml @@ -6,7 +6,7 @@ license.workspace = true publish = false [dependencies] -codespan-reporting = "0.11" +codespan-reporting = "0.12" insta = { version = "1.34", features = ["json"] } pretty_assertions = "1.4" toml-span = { workspace = true, features = ["reporting", "serde"] } diff --git a/integ-tests/tests/snapshots/parser__redefine__table_then_dotted_then_table_again.snap b/integ-tests/tests/snapshots/parser__redefine__table_then_dotted_then_table_again.snap index 11f12f7..1c145b5 100644 --- a/integ-tests/tests/snapshots/parser__redefine__table_then_dotted_then_table_again.snap +++ b/integ-tests/tests/snapshots/parser__redefine__table_then_dotted_then_table_again.snap @@ -8,9 +8,7 @@ error[duplicate-table]: 2 │ ╭ [a] 3 │ │ foo="bar" │ ╰──' first table instance - · │ + · 6 │ ╭ [a] 7 │ │ │ ╰^ duplicate table - - diff --git a/toml-span/Cargo.toml b/toml-span/Cargo.toml index 59ca589..f7800c6 100644 --- a/toml-span/Cargo.toml +++ b/toml-span/Cargo.toml @@ -14,7 +14,7 @@ serde = ["dep:serde"] reporting = ["dep:codespan-reporting"] [dependencies] -codespan-reporting = { version = "0.11", optional = true } +codespan-reporting = { version = "0.12", optional = true } serde = { version = "1.0", optional = true } smallvec = "1.13" From 3438e5537f1e032453891df4d325af5d165c2dc3 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 3 Apr 2025 13:54:44 +0200 Subject: [PATCH 2/4] Format --- integ-tests/tests/de.rs | 2 +- integ-tests/tests/valid.rs | 5 +++- toml-span/src/de.rs | 6 ++-- toml-span/src/de_helpers.rs | 2 +- toml-span/src/error.rs | 60 +++++++++++++++++++------------------ toml-span/src/impl_serde.rs | 2 +- toml-span/src/tokens.rs | 2 +- 7 files changed, 42 insertions(+), 37 deletions(-) diff --git a/integ-tests/tests/de.rs b/integ-tests/tests/de.rs index a2bfca9..8a79ed9 100644 --- a/integ-tests/tests/de.rs +++ b/integ-tests/tests/de.rs @@ -2,10 +2,10 @@ use integ_tests::{invalid_de, valid_de}; use toml_span::{ + DeserError, Deserialize, de_helpers::*, span::Spanned, value::{Value, ValueInner}, - DeserError, Deserialize, }; #[derive(Debug)] diff --git a/integ-tests/tests/valid.rs b/integ-tests/tests/valid.rs index 3eb3961..c1acefc 100644 --- a/integ-tests/tests/valid.rs +++ b/integ-tests/tests/valid.rs @@ -86,7 +86,10 @@ name = "Born in the USA" "# ); valid!(sub_empty, "[a]\n[a.b]"); - valid!(table_span, "\n[workspace]\nmembers = true\nother = false\n[workspace.foo]\nbar=3\n\n[workspace.bar]\ninline = { foo = 3 }\n\n"); + valid!( + table_span, + "\n[workspace]\nmembers = true\nother = false\n[workspace.foo]\nbar=3\n\n[workspace.bar]\ninline = { foo = 3 }\n\n" + ); } mod numbers { diff --git a/toml-span/src/de.rs b/toml-span/src/de.rs index fe1443e..b555cee 100644 --- a/toml-span/src/de.rs +++ b/toml-span/src/de.rs @@ -1,15 +1,15 @@ //! Core deserialization logic that deserializes toml content to [`Value`] use crate::{ + Span, error::{Error, ErrorKind}, tokens::{Error as TokenError, Token, Tokenizer}, value::{self, Key, Value, ValueInner}, - Span, }; use smallvec::SmallVec; use std::{ borrow::Cow, - collections::{btree_map::Entry, BTreeMap}, + collections::{BTreeMap, btree_map::Entry}, }; type DeStr<'de> = Cow<'de, str>; @@ -719,7 +719,7 @@ impl<'a> Deserializer<'a> { start, Some(start + s.len()), ErrorKind::InvalidNumber, - )) + )); } } } else { diff --git a/toml-span/src/de_helpers.rs b/toml-span/src/de_helpers.rs index 3cb7aa1..0215fb1 100644 --- a/toml-span/src/de_helpers.rs +++ b/toml-span/src/de_helpers.rs @@ -1,9 +1,9 @@ //! Provides helpers for deserializing [`Value`]/[`ValueInner`] into Rust types use crate::{ + DeserError, Deserialize, Error, ErrorKind, Span, span::Spanned, value::{self, Table, Value, ValueInner}, - DeserError, Deserialize, Error, ErrorKind, Span, }; use std::{fmt::Display, str::FromStr}; diff --git a/toml-span/src/error.rs b/toml-span/src/error.rs index 40b94f7..cec0c90 100644 --- a/toml-span/src/error.rs +++ b/toml-span/src/error.rs @@ -267,46 +267,48 @@ impl Error { Label::secondary(fid, *first).with_message("first key instance"), Label::primary(fid, self.span).with_message("duplicate key"), ]), - ErrorKind::Unexpected(c) => diag.with_labels(vec![Label::primary(fid, self.span) - .with_message(format!("unexpected character '{}'", Escape(*c)))]), - ErrorKind::InvalidCharInString(c) => { - diag.with_labels(vec![Label::primary(fid, self.span) - .with_message(format!("invalid character '{}' in string", Escape(*c)))]) - } - ErrorKind::InvalidEscape(c) => diag.with_labels(vec![Label::primary(fid, self.span) - .with_message(format!( + ErrorKind::Unexpected(c) => diag.with_labels(vec![ + Label::primary(fid, self.span) + .with_message(format!("unexpected character '{}'", Escape(*c))), + ]), + ErrorKind::InvalidCharInString(c) => diag.with_labels(vec![ + Label::primary(fid, self.span) + .with_message(format!("invalid character '{}' in string", Escape(*c))), + ]), + ErrorKind::InvalidEscape(c) => { + diag.with_labels(vec![Label::primary(fid, self.span).with_message(format!( "invalid escape character '{}' in string", Escape(*c) - ))]), - ErrorKind::InvalidEscapeValue(_) => diag - .with_labels(vec![ - Label::primary(fid, self.span).with_message("invalid escape value") - ]), + ))]) + } + ErrorKind::InvalidEscapeValue(_) => diag.with_labels(vec![ + Label::primary(fid, self.span).with_message("invalid escape value"), + ]), ErrorKind::InvalidNumber => diag.with_labels(vec![ - Label::primary(fid, self.span).with_message("unable to parse number") + Label::primary(fid, self.span).with_message("unable to parse number"), ]), ErrorKind::OutOfRange(kind) => diag .with_message(format!("number is out of range of '{kind}'")) .with_labels(vec![Label::primary(fid, self.span)]), - ErrorKind::Wanted { expected, .. } => diag - .with_labels(vec![ - Label::primary(fid, self.span).with_message(format!("expected {expected}")) - ]), + ErrorKind::Wanted { expected, .. } => diag.with_labels(vec![ + Label::primary(fid, self.span).with_message(format!("expected {expected}")), + ]), ErrorKind::MultilineStringKey => diag.with_labels(vec![ - Label::primary(fid, self.span).with_message("multiline keys are not allowed") + Label::primary(fid, self.span).with_message("multiline keys are not allowed"), + ]), + ErrorKind::UnterminatedString => diag.with_labels(vec![ + Label::primary(fid, self.span).with_message("eof reached before string terminator"), ]), - ErrorKind::UnterminatedString => diag - .with_labels(vec![Label::primary(fid, self.span) - .with_message("eof reached before string terminator")]), ErrorKind::DuplicateTable { first, .. } => diag.with_labels(vec![ Label::secondary(fid, *first).with_message("first table instance"), Label::primary(fid, self.span).with_message("duplicate table"), ]), - ErrorKind::InvalidHexEscape(c) => diag - .with_labels(vec![Label::primary(fid, self.span) - .with_message(format!("invalid hex escape '{}'", Escape(*c)))]), + ErrorKind::InvalidHexEscape(c) => diag.with_labels(vec![ + Label::primary(fid, self.span) + .with_message(format!("invalid hex escape '{}'", Escape(*c))), + ]), ErrorKind::UnquotedString => diag.with_labels(vec![ - Label::primary(fid, self.span).with_message("string is not quoted") + Label::primary(fid, self.span).with_message("string is not quoted"), ]), ErrorKind::UnexpectedKeys { keys, expected } => diag .with_message(format!( @@ -321,19 +323,19 @@ impl Error { ErrorKind::MissingField(field) => diag .with_message(format!("missing field '{field}'")) .with_labels(vec![ - Label::primary(fid, self.span).with_message("table with missing field") + Label::primary(fid, self.span).with_message("table with missing field"), ]), ErrorKind::Deprecated { new, .. } => diag .with_message(format!( "deprecated field enountered, '{new}' should be used instead" )) .with_labels(vec![ - Label::primary(fid, self.span).with_message("deprecated field") + Label::primary(fid, self.span).with_message("deprecated field"), ]), ErrorKind::UnexpectedValue { expected, .. } => diag .with_message(format!("expected '{expected:?}'")) .with_labels(vec![ - Label::primary(fid, self.span).with_message("unexpected value") + Label::primary(fid, self.span).with_message("unexpected value"), ]), ErrorKind::UnexpectedEof => diag .with_message("unexpected end of file") diff --git a/toml-span/src/impl_serde.rs b/toml-span/src/impl_serde.rs index ba75581..c719264 100644 --- a/toml-span/src/impl_serde.rs +++ b/toml-span/src/impl_serde.rs @@ -3,8 +3,8 @@ //! Provides [`serde::Serialize`] support for [`Value`] and [`Spanned`] use crate::{ - value::{Value, ValueInner}, Spanned, + value::{Value, ValueInner}, }; use serde::ser::{SerializeMap, SerializeSeq}; diff --git a/toml-span/src/tokens.rs b/toml-span/src/tokens.rs index 0ba1f9d..05f2c4e 100644 --- a/toml-span/src/tokens.rs +++ b/toml-span/src/tokens.rs @@ -1,7 +1,7 @@ #![allow(missing_docs)] //! The tokenizer is publicly exposed if you wish to use it instead -use crate::{value::Key, Span}; +use crate::{Span, value::Key}; use std::{borrow::Cow, char, str}; #[derive(Eq, PartialEq, Debug)] From a663dccf500867c9dc0c36f9eb6f6d93b406e4b2 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 3 Apr 2025 14:04:26 +0200 Subject: [PATCH 3/4] Update CHANGELOG --- toml-span/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/toml-span/CHANGELOG.md b/toml-span/CHANGELOG.md index 3b9730d..dddc371 100644 --- a/toml-span/CHANGELOG.md +++ b/toml-span/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#12](https://github.com/EmbarkStudios/toml-span/pull/12) updated `codespan-reporting` to 0.12, and update to edition 2024. + ## [0.4.1] - 2024-12-19 ### Added - [PR#11](https://github.com/EmbarkStudios/toml-span/pull/11) resolved [#10](https://github.com/EmbarkStudios/toml-span/issues/10) by adding span information for tables. From 78b22bf8131beff09ca74fc6e7e25c6b0f1cf911 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 3 Apr 2025 14:08:32 +0200 Subject: [PATCH 4/4] Satisfy clippy --- toml-span/src/de.rs | 2 +- toml-span/src/tokens.rs | 1 - toml-span/src/value.rs | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/toml-span/src/de.rs b/toml-span/src/de.rs index b555cee..360ddba 100644 --- a/toml-span/src/de.rs +++ b/toml-span/src/de.rs @@ -840,7 +840,7 @@ impl<'a> Deserializer<'a> { /// # Parameters /// /// * `key_parts`: Each segment of the dotted key, e.g. `part.one` maps to - /// `vec![Cow::Borrowed("part"), Cow::Borrowed("one")].` + /// `vec![Cow::Borrowed("part"), Cow::Borrowed("one")].` /// * `value`: The parsed value. /// * `values`: The `Vec` to store the value in. fn add_dotted_key( diff --git a/toml-span/src/tokens.rs b/toml-span/src/tokens.rs index 05f2c4e..73ba1c4 100644 --- a/toml-span/src/tokens.rs +++ b/toml-span/src/tokens.rs @@ -398,7 +398,6 @@ impl<'a> Tokenizer<'a> { match ch { ' ' | '\t' => { me.chars.next(); - continue; } '\n' => { me.chars.next(); diff --git a/toml-span/src/value.rs b/toml-span/src/value.rs index d01ab27..84985d2 100644 --- a/toml-span/src/value.rs +++ b/toml-span/src/value.rs @@ -52,7 +52,7 @@ impl<'de> Value<'de> { /// Returns true if the value is a table and is non-empty #[inline] pub fn has_keys(&self) -> bool { - self.value.as_ref().map_or(false, |val| { + self.value.as_ref().is_some_and(|val| { if let ValueInner::Table(table) = val { !table.is_empty() } else { @@ -64,7 +64,7 @@ impl<'de> Value<'de> { /// Returns true if the value is a table and has the specified key #[inline] pub fn has_key(&self, key: &str) -> bool { - self.value.as_ref().map_or(false, |val| { + self.value.as_ref().is_some_and(|val| { if let ValueInner::Table(table) = val { table.contains_key(key) } else {