I recently found out about the on_unimplemented
feature in an older version of the rust documentation.
Sadly, this no longer works with the newest rust-version.
So, I did a bit of digging and found here:
This isn't intended to ever be stabilised (in its current form) and any work towards making it user-definable would require an RFC. I think it would be appropriate to close this issue, and if people want such a feature in non-rustc crates, a new feature request issue could be opened.
So, I wanted to open "a new feature request issue". Here, it says "Please discuss language feature requests on the internals forum."
That's why I'm here today. I want to use rustc_on_unimplemented
is user code.
It's used in the std library, so we know that the feature still exists and is not broken.
The argument against using it in user code is that "it's not intended to be stable".
But it does't need to be stable.
If you decide to remove the rustc_on_unimplemented
, you can just ignore all occurrences of it. This wouldn't contradict rust's stability claims, because it only affects compiler error messages, which aren't stable in the first place. If your code compiled before such a change, it will still compile afterwards and do the same thing.
Similary, if you decide to change the syntax of what comes rustc_on_unimplemented
(let's say for example you want to replace
#[rustc_on_unimplemented(
message="message",
label="label",
note="note"
)]
with
#[rustc_on_unimplemented(
err_message="message",
label_of_this="label",
optional_note="note"
)]
all you need to do, is ignore all occurences of rustc_on_unimplemented
in user code that have invalid syntax (maybe warn).
TLDR:
The way that I see it, rustc_on_unimplemented
is a perfectly fine and useful feature that is locked away. Stability concers are invalid, because it only affects compiler error messages.