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

wrappers: parse_*: file_name uses same bound as miette #18

Conversation

spikespaz
Copy link
Contributor

@spikespaz spikespaz commented Dec 29, 2024

The three parse functions, parse_ast, parse, and parse_with_context take file_name as the first argument. This argument is used to construct miette::NamedSource, the new constructor of which takes AsRef<str>. This change ensures that miette's choice bound is preserved.

Unfortunately, miette misuses the bound, and clones (to String) in library code which is unidiomatic. Perhaps miette does not need to clone, and they knew this when writing the function signature? Does a new version of miette address this?

The three parse functions, `parse_ast`, `parse`, and
`parse_with_context` take `file_name` as the first argument.
This argument is used to construct `miette::NamedSource`,
the `new` constructor of which takes `AsRef<str>`.
This change ensures that `miette`'s choice bound is preserved.

Unfortunately, `miette` misuses the bound, and clones (to `String`)
in library code which is unidiomatic. Perhaps `miette` does not need to
clone, and they knew this when writing the function signature? Does a
new version of `miette` address this?
@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 76.30%. Comparing base (163f329) to head (a92acec).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/wrappers.rs 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #18      +/-   ##
==========================================
+ Coverage   76.26%   76.30%   +0.03%     
==========================================
  Files          15       15              
  Lines        4272     4279       +7     
  Branches     4272     4279       +7     
==========================================
+ Hits         3258     3265       +7     
  Misses        872      872              
  Partials      142      142              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheLostLambda
Copy link
Owner

TheLostLambda commented Feb 10, 2025

Thanks for another helpful contribution! Have you / are you planning to submit that change to miette? If not, I'm happy to open a PR there and change the bounds to Into<String> if they really must be owned.

EDIT: But I'll merge this for now, since that would be a breaking miette change anyways

@TheLostLambda TheLostLambda merged commit 437d9e8 into TheLostLambda:main Feb 10, 2025
13 checks passed
@spikespaz
Copy link
Contributor Author

spikespaz commented Feb 11, 2025

The API of miette needs breaking changes to be correct, and it might be hard to get people to agree on what is correct. I tried to fix the problem but noticed that fixing the issue directly would be a sidegrade, not a fix. I don't remember exactly, but fixing miette properly is a rabbit hole.

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 this pull request may close these issues.

3 participants