Commit 694fe05 1 parent f3dfd2a commit 694fe05 Copy full SHA for 694fe05
File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ fn main() {
25
25
println ! ( "cargo:rustc-check-cfg=cfg(no_std_atomic64)" ) ;
26
26
println ! ( "cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)" ) ;
27
27
println ! ( "cargo:rustc-check-cfg=cfg(no_target_has_atomic)" ) ;
28
+ println ! ( "cargo:rustc-check-cfg=cfg(no_diagnostic_namespace)" ) ;
28
29
}
29
30
30
31
let target = env:: var ( "TARGET" ) . unwrap ( ) ;
@@ -84,6 +85,12 @@ fn main() {
84
85
if minor < 74 {
85
86
println ! ( "cargo:rustc-cfg=no_core_num_saturating" ) ;
86
87
}
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
+ }
87
94
}
88
95
89
96
fn 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 {
532
532
/// deserializer lifetimes] for a more detailed explanation of these lifetimes.
533
533
///
534
534
/// [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
+ ) ]
535
542
pub trait Deserialize < ' de > : Sized {
536
543
/// Deserialize this value from the given Serde deserializer.
537
544
///
Original file line number Diff line number Diff line change @@ -215,6 +215,13 @@ declare_error_trait!(Error: Sized + Debug + Display);
215
215
/// [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
216
216
/// [`serde_derive`]: https://crates.io/crates/serde_derive
217
217
/// [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
+ ) ]
218
225
pub trait Serialize {
219
226
/// Serialize this value into the given Serde serializer.
220
227
///
You can’t perform that action at this time.
0 commit comments