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

feat(source): derive common traits for NamedSource, SourceSpan, and SourceOffset #340

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

TheLostLambda
Copy link
Contributor

One-liner sanding off a small rough edge I came across: using NamedSource<String> (instead of simply String) severely limits which traits can be derived for the wrapping diagnostic. In my case, I lost the ability to clone my error!

image

I've brought things in line with https://rust-lang.github.io/api-guidelines/interoperability.html#types-eagerly-implement-common-traits-c-common-traits, leaving out Copy, Display, and Default, since those derives are either not possible or don't feel useful. The ones I've added here make sure people can .clone() errors, compare them, sort them, and use them in HashSets / HashMaps.

I also added Ord derives to the SourceSpan and SourceOffset types for the same reason!

@zkat zkat merged commit 6f09250 into zkat:main Feb 8, 2024
14 checks passed
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.

2 participants