Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to work with inline tables in Cargo.toml #57

Closed
ijackson opened this issue Mar 5, 2025 · 1 comment · Fixed by #58
Closed

Failure to work with inline tables in Cargo.toml #57

ijackson opened this issue Mar 5, 2025 · 1 comment · Fixed by #58

Comments

@ijackson
Copy link
Contributor

ijackson commented Mar 5, 2025

For complicated reasons, I am ending up running proc_macro_crate on a package whose Cargo.toml looks like this:

package = { name = "derive-deftly-tests-tests", version = "0.0.0", publish = false, edition = "2021" }
features = { beta = ["derive-deftly-tests/beta"], case = ["derive-deftly-tests/case"], default = ["derive-deftly-tests/default"], full = ["derive-deftly-tests/full"], meta-as-expr = ["derive-deftly-tests/meta-as-expr"], meta-as-items = ["derive-deftly-tests/meta-as-items"], recent = ["derive-deftly-tests/recent"], ui = ["derive-deftly-tests/ui"] }
dependencies = { derive-deftly = { version = "*", path = "/volatile/rustcargo/Rustup/Derive-Deftly/derive-deftly/tests/..", default-features = false, features = ["minimal-1"] }, derive-deftly-tests = { path = "/volatile/rustcargo/Rustup/Derive-Deftly/derive-deftly/tests", default-features = false }, easy-ext = { version = "1" }, educe = { version = ">=0.4.6, <0.7" }, glob = { version = "0.3" }, heck = { version = ">=0.4, <0.6" }, indexmap = { version = ">=1.8, <3" }, itertools = { version = ">=0.10.1, <0.16" }, paste = { version = "1" }, proc-macro-crate = { path = "/home/ian/Rustup/Derive-Deftly/proc-macro-crate" }, proc-macro2 = { version = "1.0.53" }, quote = { version = "1" }, regex = { version = "1" }, sha3 = { version = "0.10" }, static_assertions = { version = "1" }, strum = { version = ">=0.24, <0.28", features = ["derive"] }, syn = { version = "2.0.53", features = ["extra-traits", "full"] }, toml = { version = ">=0.5.0, <0.9" }, trybuild = { version = "1.0.46" }, void = { version = "1" } }
bin = [{ name = "derive-deftly-tests-tests", path = "main.rs" }, { name = "macrotest001", path = "/volatile/rustcargo/Rustup/Derive-Deftly/derive-deftly/tests/expand/clone.rs" }]
workspace = {}

This fails, because the code in proc_macro_crate uses Item::as_table to look up table values. Item::as_table returns None for Item::Value(Value::InlineTable(..)).

The proper call with toml_edit is as_table_like. I will prepare an MR for that.

Other ways of addressing this might be to switch to a different toml library altogether - #56, #37

@ijackson
Copy link
Contributor Author

ijackson commented Mar 5, 2025

Filed toml-rs/toml#838 about the API of toml_edit which IMO seems very likely to induce this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant