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

Use diagnostic::on_unimplemented to improve blanket impl debugging #1563

Open
tarcieri opened this issue May 3, 2024 · 3 comments
Open

Use diagnostic::on_unimplemented to improve blanket impl debugging #1563

tarcieri opened this issue May 3, 2024 · 3 comments

Comments

@tarcieri
Copy link
Member

tarcieri commented May 3, 2024

Rust 1.78 added a new diagnostic::on_unimplemented attribute which can be used to add additional context in the event a trait isn't impl'd in the form of note messages that appear in the diagnostics:

https://rust-lang.github.io/rfcs/3368-diagnostic-attribute-namespace.html#guide-level-explanation

These seem very helpful for improving debugging of missing trait impls which are expected to be received via a blanket impl, i.e. the note can include the name of the other trait the user is expected to implement.

It will be awhile before we can consider Rust 1.78, however I thought I'd go ahead and open this as a tracking / planning issue for using this feature.

@tarcieri
Copy link
Member Author

tarcieri commented May 3, 2024

Actually, is it a problem to go ahead and start using this now? It's just an attribute, so older Rust versions should ignore it, right?

@newpavlov
Copy link
Member

newpavlov commented May 3, 2024

Unfortunately, no, it will result in "error[E0658]: #[diagnostic] attribute name space is experimental" compilation error or "error[E0433]: failed to resolve: use of undeclared type or module diagnostic" on older Rust versions.

@tarcieri
Copy link
Member Author

With recent MSRV bumps / plans to bump MSRV, we can start considering this

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

No branches or pull requests

2 participants