File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ fn main() {
2525 println ! ( "cargo:rustc-check-cfg=cfg(no_std_atomic64)" ) ;
2626 println ! ( "cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)" ) ;
2727 println ! ( "cargo:rustc-check-cfg=cfg(no_target_has_atomic)" ) ;
28+ println ! ( "cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)" ) ;
2829 }
2930
3031 let target = env:: var ( "TARGET" ) . unwrap ( ) ;
@@ -84,6 +85,12 @@ fn main() {
8485 if minor < 74 {
8586 println ! ( "cargo:rustc-cfg=no_core_num_saturating" ) ;
8687 }
88+
89+ // Support for the `#[diagnostic]` tool attribute namespace
90+ // https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#diagnostic-attributes
91+ if minor < 78 {
92+ println ! ( "cargo:rustc-cfg=no_diagnostic_namespace" ) ;
93+ }
8794}
8895
8996fn rustc_minor_version ( ) -> Option < u32 > {
Original file line number Diff line number Diff line change @@ -532,6 +532,13 @@ impl<'a> Display for Expected + 'a {
532532/// deserializer lifetimes] for a more detailed explanation of these lifetimes.
533533///
534534/// [Understanding deserializer lifetimes]: https://serde.rs/lifetimes.html
535+ #[ cfg_attr(
536+ not( no_diagnostic_namespace) ,
537+ diagnostic:: on_unimplemented(
538+ note = "for local types consider adding `#[derive(serde::Deserialize)]` to your `{Self}` type" ,
539+ note = "for types from other crates check whether the crate offers a `serde` feature flag" ,
540+ )
541+ ) ]
535542pub trait Deserialize < ' de > : Sized {
536543 /// Deserialize this value from the given Serde deserializer.
537544 ///
Original file line number Diff line number Diff line change @@ -215,6 +215,13 @@ declare_error_trait!(Error: Sized + Debug + Display);
215215/// [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
216216/// [`serde_derive`]: https://crates.io/crates/serde_derive
217217/// [derive section of the manual]: https://serde.rs/derive.html
218+ #[ cfg_attr(
219+ not( no_diagnostic_namespace) ,
220+ diagnostic:: on_unimplemented(
221+ note = "for local types consider adding `#[derive(serde::Serialize)]` to your `{Self}` type" ,
222+ note = "for types from other crates check whether the crate offers a `serde` feature flag" ,
223+ )
224+ ) ]
218225pub trait Serialize {
219226 /// Serialize this value into the given Serde serializer.
220227 ///
You can’t perform that action at this time.
0 commit comments