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

New workspace inheritance feature breaks sort #47

Open
matze opened this issue Sep 23, 2022 · 17 comments
Open

New workspace inheritance feature breaks sort #47

matze opened this issue Sep 23, 2022 · 17 comments

Comments

@matze
Copy link
Contributor

matze commented Sep 23, 2022

Using the new workspace inheritance feature breaks the sorting

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TomlError { message: "TOML parse error at line 3, column 8\n  |\n3 | version.workspace = true\n  |        ^\nUnexpected `.`\nExpected `=`\n" }', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/cargo-sort-1.0.7/src/sort.rs:113:46
@steviez
Copy link

steviez commented Sep 29, 2022

I ran into this as well; however, looking at the line from the panic, it seems the issue might actually be in toml_edit::Document's FromStr trait implementation:

let mut toml = input.parse::<Document>().unwrap();

@steviez
Copy link

steviez commented Sep 30, 2022

The toml_edit crate at below link supports these kv pairs of the form key.more = value:
https://github.com/toml-rs/toml
But, this repo has its' own copy of toml_edit code, so the issue is indeed with this repo's copy of toml_edit

@matze
Copy link
Contributor Author

matze commented Sep 30, 2022

I wonder why this project vendors toml_edit though …

@steviez
Copy link

steviez commented Oct 6, 2022

I wonder why this project vendors toml_edit though …

Good question, can you speak to that @DevinR528 ? Any reason not to rip out the copy and depend on the actively maintained crate ?

Edit; oh wait #29

@janpetschexain
Copy link

until this gets fixed you can work around that via

version = { workspace = true }

instead of

version.workspace = true

@DevinR528
Copy link
Owner

Sorry for the slow response. So toml_edit is vendored because it did not support sorting in a controllable way at that time. As @steviez noticed there is an issue to update it to the new toml_edit crate, which now will be even better since cargo now uses it for the new cargo add command. I just haven't had time to do this but it is defiantly on my TODO list!!

Thanks for the interest and the workaround!

@DevinR528
Copy link
Owner

Will be resolved with #29

@Jasperav
Copy link

@DevinR528 is there any timeline?

@DevinR528
Copy link
Owner

I, unfortunately, have not had much extra time sorry! I do have a start at moving to a non vendored toml_edit crate #29. I'd say I would for sure have some time over my schools winter break, end of December. Sorry I can't give a better timeline than that.

@jplatte
Copy link
Collaborator

jplatte commented Nov 2, 2022

I might be able to look into it earlier. Are you're okay having your PR taken over?

@DevinR528
Copy link
Owner

By all means, that would be great! Any questions I can at least prioritize answering. Thanks!

@jayvdb
Copy link

jayvdb commented Nov 17, 2022

Noting that cargo-make's "format-toml" rule can sort these. It is implemented using https://crates.io/crates/taplo-cli .
It needs a .taplo.toml file containing

[formatting]
reorder_keys = true

See https://taplo.tamasfe.dev/configuration/formatter-options.html for more options.

@Jasperav
Copy link

@jayvdb Thanks a bunch for mentioning that lib. I did not knew that exists, I switched over without any hassle :)

@haraldh
Copy link

haraldh commented Aug 17, 2023

any chance for this to land? 🥺

@Jasperav
Copy link

@haraldh why not use taplo?

@haraldh
Copy link

haraldh commented Aug 17, 2023

@Jasperav right... coincidentally just did that :)

@jplatte
Copy link
Collaborator

jplatte commented Dec 7, 2023

Fixed by #29, #65. There is a regression though, so I won't release yet.

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

No branches or pull requests

8 participants