-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Tracking issue for on_unimplemented
feature
#29628
Comments
I think this would be 'private' to rustc. |
@seanmonstar You may well be right, although it may be a useful feature for tailoring error messages around complicated user-space trait setups as well. |
As someone creating a library with complicated user-space trait setups, this would be an enormously useful feature. However I did notice an issue while using it, due to blanket impls. When adding this line, I would expect this compile fail test to contain "collections::string::String cannot be used in an expression of type yaqb::types::Serial". However, it doesn't even mention the annotated trait, since due to this blanket impl, it doesn't even mention the annotated trait (and therefore doesn't include my note). Only the one that would satisfy the constraints of that blanket impl. (This is likely another manifestation of #28894). Also worth noting that it's impossible to test these w/ compile-fail at the moment, but that's tangential to this feature. |
Is it possible to improve the default diagnostics, without an opt-in feature? |
Triage: no real change. apparently servo uses this. |
Update: I’m moving usage of nice to have but not really required (optimizations, compiler diagnostics like this, …) unstable features in Servo behind an optional Cargo feature flag. |
I would like to see an RFC for getting custom errors a la https://ghc.haskell.org/trac/ghc/wiki/Proposal/CustomTypeErrors in Rust. |
What needs to be done to get this or something similar stabilized? As some of you may know, error[E0277]: static assertion failed
--> tests/messages.rs:14:1
|
14 | assert_impl_one!(Foo: A, B, C);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| `Foo` must implement exactly one of the given traits
| required by `_::{{closure}}#0::AmbiguousIfMoreThanOne::some_item`
|
= help: the trait `_::{{closure}}#0::AmbiguousIfMoreThanOne<_>` is not implemented for `Foo`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) It would be wonderful if everyone who uses this crate can get decent error messages. |
This is an internal |
Ah, I wasn't aware it was meant to be internal-only. @estebank had recommended it to me earlier today, so I figured it was fair game. What's the path to make something like this publicly usable? |
An elaborate RFC. :) The current implementation is an ad-hoc one based solely on what the needs of rustc is and any design would need to make sure to handle errors holistically (e.g. taking into account const generics, GHCs way of doing things, etc.) and not be too tied to rustc nor rustc too tied to the attribute. At any rate, this is not a priority and I don't think the language team has the bandwidth to make it one. |
I'm surprised this is feature gated behind anything other than |
@varkor Yeah I agree; let's move it into |
gate rustc_on_unimplemented under rustc_attrs Move `rustc_on_implemented` from the `on_implemented` gate to `rustc_attrs` as it is internal. Closes rust-lang#29628 r? @varkor
gate rustc_on_unimplemented under rustc_attrs Move `rustc_on_implemented` from the `on_implemented` gate to `rustc_attrs` as it is internal. Closes rust-lang#29628 r? @varkor
The
on_unimplemented
feature provides the#[rustc_on_unimplemented]
attribute, which allows trait definitions to add specialized notes to error messages when an implementation was expected but not found.WARNING: This attribute, as all other
rustc_
attributes, is an internal implementation detail ofrustc
and is not meant to become stable.The text was updated successfully, but these errors were encountered: