-
-
Notifications
You must be signed in to change notification settings - Fork 705
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
diagnostic::on_unimplemented
for fundamental traits, providing better compile-time errors
#3549
Comments
I don’t see an issue bumping msrv for the 0.8 release, which should be out soonTM. Perhaps push to the leptos_0.8 branch
…On Wed, Feb 5, 2025, at 5:27 PM, Chris wrote:
@gbj <https://github.com/gbj> recently made a request in discord for some help in making use of the `diagnostic::on_unimplemented` <https://doc.rust-lang.org/beta/reference/attributes/diagnostics.html#the-diagnosticon_unimplemented-attribute> attribute
I do not have a ton of time to work on this, but I at least wanted to make an issue that can be referenced and used to store locations where this may help. Discord isn't great for aggregating lists of things over long periods of time.
I encourage others to reference / comment / discuss places where we currently have confusing, or convoluted errors regarding trait implementations. This is likely not something that can reasonably be "finished" in a single PR.
I am just putting down some initial thoughts in case I can work on this at all, or first time contributors are looking for a place to start.
`diagnostic::on_unimplemented` <https://doc.rust-lang.org/beta/reference/attributes/diagnostics.html#the-diagnosticon_unimplemented-attribute>
In short, this attribute is able to declare how a *compile-time error* is displayed when the user has an X that requires an implementation on Y, but Y is not implemented for X.
Traits that may benefit
• the traits in `reactive_graph` <https://docs.rs/leptos/latest/leptos/reactive/traits/index.html#traits> (signal related things) would definitely be low hanging fruit.
In the wild
• `axum::Handler` <https://docs.rs/axum/latest/src/axum/handler/mod.rs.html#128>: suggesting to use `#[axum::debug_handler]`
• `std::Sync` <https://doc.rust-lang.org/src/core/marker.rs.html#525>: shows an almost insane level of detail that is enabled through proper use of the attribute. Allowing someone to specify messages when the implementation is missing on a concrete type. *This use does not seem to be in the reference, so maybe they are doing some compiler-blessed tech there?*
• Thinking about closures capturing too much and thus not reaching the blanket impl for `IntoView`?
`diagnostic::do_not_recommend` <https://doc.rust-lang.org/beta/reference/attributes/diagnostics.html#the-diagnosticdo_not_recommend-attribute>
Could be useful for some lower level blanket implementations that exist for rendering? Likely a lower priority to using the above attribute.
Limitations
This attribute is only available since `1.78`, `leptos` currently has an msrv of `1.76`. Any uses may need to gate the attribute if we wish to keep that. Raising msrv is definitely semver breaking (I think)? `axum` uses `rustversion` crate to easily achieve this attribute configuration.
—
Reply to this email directly, view it on GitHub <#3549>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABVBTCLNS5WP5PCXMCCZDV32OK27JAVCNFSM6AAAAABWSMM3ICVHI2DSMVQWIX3LMV43ASLTON2WKOZSHAZTIMRYGU4DGMA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gbj recently made a request in discord for some help in making use of the
diagnostic::on_unimplemented
attributeI do not have a ton of time to work on this, but I at least wanted to make an issue that can be referenced and used to store locations where this may help. Discord isn't great for aggregating lists of things over long periods of time.
I encourage others to reference / comment / discuss places where we currently have confusing, or convoluted errors regarding trait implementations. This is likely not something that can reasonably be "finished" in a single PR.
I am just putting down some initial thoughts in case I can work on this at all, or first time contributors are looking for a place to start.
diagnostic::on_unimplemented
In short, this attribute is able to declare how a compile-time error is displayed when the user has an X that requires an implementation on Y, but Y is not implemented for X.
Traits that may benefit
reactive_graph
(signal related things) would definitely be low hanging fruit.In the wild
axum::Handler
: suggesting to use#[axum::debug_handler]
std::Sync
: shows an almost insane level of detail that is enabled through proper use of the attribute. Allowing someone to specify messages when the implementation is missing on a concrete type. This use does not seem to be in the reference, so maybe they are doing some compiler-blessed tech there?IntoView
?diagnostic::do_not_recommend
Could be useful for some lower level blanket implementations that exist for rendering? Likely a lower priority to using the above attribute.
Limitations
This attribute is only available since
1.78
,leptos
currently has an msrv of1.76
. Any uses may need to gate the attribute if we wish to keep that. Raising msrv is definitely semver breaking (I think)?axum
usesrustversion
crate to easily achieve this attribute configuration.The text was updated successfully, but these errors were encountered: