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

Expose span in Document #571

Closed
baszalmstra opened this issue Jun 20, 2023 · 5 comments
Closed

Expose span in Document #571

baszalmstra opened this issue Jun 20, 2023 · 5 comments
Labels
A-edit Area: TOML editing API C-enhancement Category: Raise on the bar on expectations

Comments

@baszalmstra
Copy link

If I read the docs correctly it looks like span is kept private to the crate is there are reason not to expose this information? It would be beneficial to query a document and ascertain where something is in the document to display friendly diagnostics.

@epage epage added C-enhancement Category: Raise on the bar on expectations A-edit Area: TOML editing API labels Jun 20, 2023
@epage
Copy link
Member

epage commented Jun 20, 2023

The priority for implementing span support was for the serde API so that toml 0.6 could retain feature parity with 0.5.

However, in doing so, spans slowed things down by quite a bit. We were able to speed things back up by making spans exclusive to the serde API (see #429). It will take some experimentation and iteration to get span support in the toml_edit API without data corruption, panics, and performance loss.

@dtolnay
Copy link
Contributor

dtolnay commented Oct 26, 2023

For now, here is a workaround that makes it possible to access the span of an arbitrary node, using only the existing public API of toml_edit. https://play.rust-lang.org/?version=stable&edition=2021&gist=0d457da235449046bd30932a91e45d96

@epage
Copy link
Member

epage commented Oct 27, 2023

I wonder if error reporting is faster or using Spanned. I'm assuming error reporting because it won't recurse.

@epage
Copy link
Member

epage commented Mar 8, 2024

#698 allows access to spans if you parse with an ImDocument as that works around the limitation with exposing spans in Document.

Is that sufficient?

@epage
Copy link
Member

epage commented Mar 22, 2024

Without further feedback, I'm going to consider this resolved. If there is a reason we should re-open this, let us know!

@epage epage closed this as completed Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edit Area: TOML editing API C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

3 participants