Design and Implementation of the `#[diagnostic]` attribute namespace
summary
Introduces a compiler attribute namespace stabilized in Rust 1.78 that lets crates override or hide compiler diagnostics; two attributes exist now: unimplemented replaces trait-bound error text with templated strings and type placeholders, and do not recommend hides specific trait impls so error output becomes concise. Implementation follows an AFC, edits to the rustc emitter, diagnostic tests that assert output diffs, and real-world usage in crates like diesel, and the feature is available on stable.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:11Motivation for better errors
- 2:34Diagnostic namespace overview
- 5:03Rules and limitations
- 5:24The #[unimplemented] attribute
- 7:53The #[do_not_recommend] attribute
- 12:06Combining attributes for errors
- 12:29Proposing Rust features
- 14:38Writing an RFC
- 16:25Implementing in Rust compiler
- 17:31Navigating Rust codebase
- 19:43Stabilizing the feature
- 21:08Summary
related talks
40mWe deserve helpful tools
31mThe Anatomy of Error Messages in Rust
15mSupercharging Your Code With Five Little-Known Attributes
26mFriendly Ferris: Developing Kind Compiler Errors
33mReplacing #[cfg] with Traits: The Inlinable Dyn Extension Trait Pattern
36mThe language that isn't
37mCompiler Errors in rustc: A UX Perspective
25m"Compiler-Driven Development: Making Rust Work for You"
