-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Why is Spanned sealed? #1441
Comments
Additionally, this doesn't seem to be documented in the release notes for syn 2, in the list of breaking changes. I see that
Previously, in syn 1.0, this was achieved in babcfc6 "Use quote's Spanned to provide impl for Span". That commit unseals The situation with syn 2 is rather strange, now. (As an example of a type that could be I can't see any logical reason why the combination " |
In general, I am finding something similar with a lot of the traits that are What exactly is |
Spanned was not sealed in syn 1. Currently in syn 2 it is nominally sealed, but since quote::ToTokens isn't sealed, Spanned *can* be implemented for any foreign type, provided one is willing to provide a (possibly broken) implemntation of ToTokens. This means that sealing Spanned has no semver advantage, and neither does it defend syn from any bad behaviour on the part of downstream implementors. See dtolnay#1441
That's right, using your own alternative trait is the way to go. For those use cases, bear in mind that a |
Why isn’t that signature what we want in most cases? |
I touched on this in the linked PR in #1524 (review). In stable Rust, a |
I saw that syn 2.0 seals the Spanned trait (and that it was previously also sealed in #439). This is an issue for my crate darling, which has some structs that
impl Spanned
but don’timpl ToTokens
.I could come up with a workaround, such as creating
darling::Spanned
with a blanket impl to the syn one, but I’d like to understand why the trait was sealed so that my workaround isn’t somehow flawed/doomed to failure.The text was updated successfully, but these errors were encountered: